Revision: 12315
Author:   [email protected]
Date:     Thu Aug 16 02:13:25 2012
Log:      Extend constructor inlining test case.

This makes sure that deoptimization really happens in each hydrogen
context by not using binary operations but loads instead. This is
needed because we cannot clear BinaryOpICs explicitly.

[email protected]
TEST=mjsunit/compiler/inline-construct

Review URL: https://chromiumcodereview.appspot.com/10825382
http://code.google.com/p/v8/source/detail?r=12315

Modified:
 /branches/bleeding_edge/test/mjsunit/compiler/inline-construct.js

=======================================
--- /branches/bleeding_edge/test/mjsunit/compiler/inline-construct.js Wed Aug 15 02:39:13 2012 +++ /branches/bleeding_edge/test/mjsunit/compiler/inline-construct.js Thu Aug 16 02:13:25 2012
@@ -32,43 +32,46 @@
 function TestInlinedConstructor(constructor, closure) {
   var result;
   var counter = { value:0 };
+  var noDeopt = { deopt:0 };
+  var forceDeopt = { /*empty*/ };

-  result = closure(constructor, 11, 12, counter);
-  assertEquals(23, result);
+  result = closure(constructor, 11, noDeopt, counter);
+  assertEquals(11, result);
   assertEquals(1, counter.value);

-  result = closure(constructor, 23, 19, counter);
-  assertEquals(42, result);
+  result = closure(constructor, 23, noDeopt, counter);
+  assertEquals(23, result);
   assertEquals(2, counter.value);

   %OptimizeFunctionOnNextCall(closure);
-  result = closure(constructor, 1, 42, counter);
-  assertEquals(43, result);
+  result = closure(constructor, 42, noDeopt, counter);
+  assertEquals(42, result);
   assertEquals(3, counter.value);

-  result = closure(constructor, "foo", "bar", counter);
-  assertEquals("foobar", result)
+  result = closure(constructor, 127, forceDeopt, counter);
+  assertEquals(127, result)
   assertEquals(4, counter.value);

   %DeoptimizeFunction(closure);
   %ClearFunctionTypeFeedback(closure);
+  %ClearFunctionTypeFeedback(constructor);
 }

-function value_context(constructor, a, b, counter) {
-  var obj = new constructor(a, b, counter);
+function value_context(constructor, val, deopt, counter) {
+  var obj = new constructor(val, deopt, counter);
   return obj.x;
 }

-function test_context(constructor, a, b, counter) {
-  if (!new constructor(a, b, counter)) {
+function test_context(constructor, val, deopt, counter) {
+  if (!new constructor(val, deopt, counter)) {
     assertUnreachable("should not happen");
   }
-  return a + b;
+  return val;
 }

-function effect_context(constructor, a, b, counter) {
-  new constructor(a, b, counter);
-  return a + b;
+function effect_context(constructor, val, deopt, counter) {
+  new constructor(val, deopt, counter);
+  return val;
 }

 function TestInAllContexts(constructor) {
@@ -79,17 +82,19 @@


 // Test constructor returning nothing in all contexts.
-function c1(a, b, counter) {
-  this.x = a + b;
+function c1(val, deopt, counter) {
+  deopt.deopt;
+  this.x = val;
   counter.value++;
 }
 TestInAllContexts(c1);


 // Test constructor returning an object in all contexts.
-function c2(a, b, counter) {
+function c2(val, deopt, counter) {
   var obj = {};
-  obj.x = a + b;
+  deopt.deopt;
+  obj.x = val;
   counter.value++;
   return obj;
 }
@@ -97,8 +102,9 @@


 // Test constructor returning a primitive value in all contexts.
-function c3(a, b, counter) {
-  this.x = a + b;
+function c3(val, deopt, counter) {
+  deopt.deopt;
+  this.x = val;
   counter.value++;
   return "not an object";
 }
@@ -137,9 +143,10 @@


 // Test constructor that cannot be inlined.
-function c_unsupported_syntax(a, b, counter) {
+function c_unsupported_syntax(val, deopt, counter) {
   try {
-    this.x = a + b;
+    deopt.deopt;
+    this.x = val;
     counter.value++;
   } catch(e) {
     throw new Error();
@@ -150,9 +157,10 @@

// Regression test: Inlined constructors called as functions do not get their
 // implicit receiver object set to undefined, even in strict mode.
-function c_strict(a, b, counter) {
+function c_strict(val, deopt, counter) {
   "use strict";
-  this.x = a + b;
+  deopt.deopt;
+  this.x = val;
   counter.value++;
 }
 TestInAllContexts(c_strict);

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to