Revision: 12312
Author: [email protected]
Date: Wed Aug 15 02:39:13 2012
Log: Improved constructor inlining unit tests.
Currently we inline functions with different contexts only on ia32, so we
have
to move the helper functions for the various contexts to the top level.
Further
more, "new Object()" seems to prevent inlining, too, so we us a simple
object
literal.
Although things get consistently inlined now, something strange seems to
happen
in test/effect contexts: The DEOPT output seems to contain too few frames,
and
we don't get any DEOPT ouput after the first time for those contexts. This
has
to be investigated...
[email protected]
Review URL: https://chromiumcodereview.appspot.com/10836258
http://code.google.com/p/v8/source/detail?r=12312
Modified:
/branches/bleeding_edge/test/mjsunit/compiler/inline-construct.js
=======================================
--- /branches/bleeding_edge/test/mjsunit/compiler/inline-construct.js Fri
May 4 02:16:38 2012
+++ /branches/bleeding_edge/test/mjsunit/compiler/inline-construct.js Wed
Aug 15 02:39:13 2012
@@ -29,50 +29,54 @@
// Test inlining of constructor calls.
-function TestInlinedConstructor(closure) {
+function TestInlinedConstructor(constructor, closure) {
var result;
var counter = { value:0 };
- result = closure(11, 12, counter);
+
+ result = closure(constructor, 11, 12, counter);
assertEquals(23, result);
assertEquals(1, counter.value);
- result = closure(23, 19, counter);
+
+ result = closure(constructor, 23, 19, counter);
assertEquals(42, result);
assertEquals(2, counter.value);
+
%OptimizeFunctionOnNextCall(closure);
- result = closure(1, 42, counter)
+ result = closure(constructor, 1, 42, counter);
assertEquals(43, result);
assertEquals(3, counter.value);
- result = closure("foo", "bar", counter)
+
+ result = closure(constructor, "foo", "bar", counter);
assertEquals("foobar", result)
assertEquals(4, counter.value);
+
+ %DeoptimizeFunction(closure);
+ %ClearFunctionTypeFeedback(closure);
}
-function TestInAllContexts(constructor) {
- function value_context(a, b, counter) {
- var obj = new constructor(a, b, counter);
- return obj.x;
+function value_context(constructor, a, b, counter) {
+ var obj = new constructor(a, b, counter);
+ return obj.x;
+}
+
+function test_context(constructor, a, b, counter) {
+ if (!new constructor(a, b, counter)) {
+ assertUnreachable("should not happen");
}
- function test_context(a, b, counter) {
- if (!new constructor(a, b, counter)) {
- assertUnreachable("should not happen");
- }
- return a + b;
- }
- function effect_context(a, b, counter) {
- new constructor(a, b, counter);
- return a + b;
- }
- TestInlinedConstructor(value_context);
- TestInlinedConstructor(test_context);
- TestInlinedConstructor(effect_context);
- %DeoptimizeFunction(value_context);
- %DeoptimizeFunction(test_context);
- %DeoptimizeFunction(effect_context);
- %ClearFunctionTypeFeedback(value_context);
- %ClearFunctionTypeFeedback(test_context);
- %ClearFunctionTypeFeedback(effect_context);
+ return a + b;
}
+function effect_context(constructor, a, b, counter) {
+ new constructor(a, b, counter);
+ return a + b;
+}
+
+function TestInAllContexts(constructor) {
+ TestInlinedConstructor(constructor, value_context);
+ TestInlinedConstructor(constructor, test_context);
+ TestInlinedConstructor(constructor, effect_context);
+}
+
// Test constructor returning nothing in all contexts.
function c1(a, b, counter) {
@@ -84,7 +88,7 @@
// Test constructor returning an object in all contexts.
function c2(a, b, counter) {
- var obj = new Object();
+ var obj = {};
obj.x = a + b;
counter.value++;
return obj;
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev