Index: test/cctest/test-deoptimization.cc |
diff --git a/test/cctest/test-deoptimization.cc b/test/cctest/test-deoptimization.cc |
index a201ccd7e47d1b1725b2c99fd6e783e300991dcf..262ffc1c3036eea8359ebea1cbd973df6dfd91c4 100644 |
--- a/test/cctest/test-deoptimization.cc |
+++ b/test/cctest/test-deoptimization.cc |
@@ -98,8 +98,8 @@ class AllowNativesSyntaxNoInlining { |
// Abort any ongoing incremental marking to make sure that all weak global |
// handle callbacks are processed. |
-static void NonIncrementalGC(i::Isolate* isolate) { |
- isolate->heap()->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); |
+static void NonIncrementalGC() { |
+ CcTest::heap()->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask); |
} |
@@ -127,7 +127,7 @@ TEST(DeoptimizeSimple) { |
"function f() { g(); };" |
"f();"); |
} |
- NonIncrementalGC(CcTest::i_isolate()); |
+ NonIncrementalGC(); |
CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); |
CHECK(!GetJSFunction(env->Global(), "f")->IsOptimized()); |
@@ -143,7 +143,7 @@ TEST(DeoptimizeSimple) { |
"function f(x) { if (x) { g(); } else { return } };" |
"f(true);"); |
} |
- NonIncrementalGC(CcTest::i_isolate()); |
+ NonIncrementalGC(); |
CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); |
CHECK(!GetJSFunction(env->Global(), "f")->IsOptimized()); |
@@ -167,7 +167,7 @@ TEST(DeoptimizeSimpleWithArguments) { |
"function f(x, y, z) { g(1,x); y+z; };" |
"f(1, \"2\", false);"); |
} |
- NonIncrementalGC(CcTest::i_isolate()); |
+ NonIncrementalGC(); |
CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); |
CHECK(!GetJSFunction(env->Global(), "f")->IsOptimized()); |
@@ -184,7 +184,7 @@ TEST(DeoptimizeSimpleWithArguments) { |
"function f(x, y, z) { if (x) { g(x, y); } else { return y + z; } };" |
"f(true, 1, \"2\");"); |
} |
- NonIncrementalGC(CcTest::i_isolate()); |
+ NonIncrementalGC(); |
CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); |
CHECK(!GetJSFunction(env->Global(), "f")->IsOptimized()); |
@@ -209,7 +209,7 @@ TEST(DeoptimizeSimpleNested) { |
"function g(z) { count++; %DeoptimizeFunction(f); return z;}" |
"function f(x,y,z) { return h(x, y, g(z)); };" |
"result = f(1, 2, 3);"); |
- NonIncrementalGC(CcTest::i_isolate()); |
+ NonIncrementalGC(); |
CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); |
CHECK_EQ(6, env->Global()->Get(v8_str("result"))->Int32Value()); |
@@ -235,7 +235,7 @@ TEST(DeoptimizeRecursive) { |
"function f(x) { calls++; if (x > 0) { f(x - 1); } else { g(); } };" |
"f(10);"); |
} |
- NonIncrementalGC(CcTest::i_isolate()); |
+ NonIncrementalGC(); |
CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); |
CHECK_EQ(11, env->Global()->Get(v8_str("calls"))->Int32Value()); |
@@ -268,7 +268,7 @@ TEST(DeoptimizeMultiple) { |
"function f1(x) { return f2(x + 1, x + 1) + x; };" |
"result = f1(1);"); |
} |
- NonIncrementalGC(CcTest::i_isolate()); |
+ NonIncrementalGC(); |
CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); |
CHECK_EQ(14, env->Global()->Get(v8_str("result"))->Int32Value()); |
@@ -290,7 +290,7 @@ TEST(DeoptimizeConstructor) { |
"function f() { g(); };" |
"result = new f() instanceof f;"); |
} |
- NonIncrementalGC(CcTest::i_isolate()); |
+ NonIncrementalGC(); |
CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); |
CHECK(env->Global()->Get(v8_str("result"))->IsTrue()); |
@@ -307,7 +307,7 @@ TEST(DeoptimizeConstructor) { |
"result = new f(1, 2);" |
"result = result.x + result.y;"); |
} |
- NonIncrementalGC(CcTest::i_isolate()); |
+ NonIncrementalGC(); |
CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); |
CHECK_EQ(3, env->Global()->Get(v8_str("result"))->Int32Value()); |
@@ -337,7 +337,7 @@ TEST(DeoptimizeConstructorMultiple) { |
"function f1(x) { this.result = new f2(x + 1, x + 1).result + x; };" |
"result = new f1(1).result;"); |
} |
- NonIncrementalGC(CcTest::i_isolate()); |
+ NonIncrementalGC(); |
CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); |
CHECK_EQ(14, env->Global()->Get(v8_str("result"))->Int32Value()); |
@@ -345,61 +345,51 @@ TEST(DeoptimizeConstructorMultiple) { |
} |
-UNINITIALIZED_TEST(DeoptimizeBinaryOperationADDString) { |
+TEST(DeoptimizeBinaryOperationADDString) { |
i::FLAG_turbo_deoptimization = true; |
i::FLAG_concurrent_recompilation = false; |
AllowNativesSyntaxNoInlining options; |
- v8::Isolate* isolate = v8::Isolate::New(); |
- i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
- isolate->Enter(); |
- { |
- LocalContext env(isolate); |
- v8::HandleScope scope(env->GetIsolate()); |
- |
- const char* f_source = "function f(x, y) { return x + y; };"; |
- |
- { |
- // Compile function f and collect to type feedback to insert binary op |
- // stub call in the optimized code. |
- i::FLAG_prepare_always_opt = true; |
- CompileRun( |
- "var count = 0;" |
- "var result = 0;" |
- "var deopt = false;" |
- "function X() { };" |
- "X.prototype.toString = function () {" |
- " if (deopt) { count++; %DeoptimizeFunction(f); } return 'an X'" |
- "};"); |
- CompileRun(f_source); |
- CompileRun( |
- "for (var i = 0; i < 5; i++) {" |
- " f('a+', new X());" |
- "};"); |
- |
- // Compile an optimized version of f. |
- i::FLAG_always_opt = true; |
- CompileRun(f_source); |
- CompileRun("f('a+', new X());"); |
- CHECK(!i_isolate->use_crankshaft() || |
- GetJSFunction(env->Global(), "f")->IsOptimized()); |
- |
- // Call f and force deoptimization while processing the binary operation. |
- CompileRun( |
- "deopt = true;" |
- "var result = f('a+', new X());"); |
- } |
- NonIncrementalGC(i_isolate); |
+ LocalContext env; |
+ v8::HandleScope scope(env->GetIsolate()); |
- CHECK(!GetJSFunction(env->Global(), "f")->IsOptimized()); |
- CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); |
- v8::Handle<v8::Value> result = env->Global()->Get(v8_str("result")); |
- CHECK(result->IsString()); |
- v8::String::Utf8Value utf8(result); |
- CHECK_EQ("a+an X", *utf8); |
- CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(i_isolate)); |
+ const char* f_source = "function f(x, y) { return x + y; };"; |
+ |
+ { |
+ // Compile function f and collect to type feedback to insert binary op stub |
+ // call in the optimized code. |
+ i::FLAG_prepare_always_opt = true; |
+ CompileRun("var count = 0;" |
+ "var result = 0;" |
+ "var deopt = false;" |
+ "function X() { };" |
+ "X.prototype.toString = function () {" |
+ " if (deopt) { count++; %DeoptimizeFunction(f); } return 'an X'" |
+ "};"); |
+ CompileRun(f_source); |
+ CompileRun("for (var i = 0; i < 5; i++) {" |
+ " f('a+', new X());" |
+ "};"); |
+ |
+ // Compile an optimized version of f. |
+ i::FLAG_always_opt = true; |
+ CompileRun(f_source); |
+ CompileRun("f('a+', new X());"); |
+ CHECK(!CcTest::i_isolate()->use_crankshaft() || |
+ GetJSFunction(env->Global(), "f")->IsOptimized()); |
+ |
+ // Call f and force deoptimization while processing the binary operation. |
+ CompileRun("deopt = true;" |
+ "var result = f('a+', new X());"); |
} |
- isolate->Exit(); |
- isolate->Dispose(); |
+ NonIncrementalGC(); |
+ |
+ CHECK(!GetJSFunction(env->Global(), "f")->IsOptimized()); |
+ CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); |
+ v8::Handle<v8::Value> result = env->Global()->Get(v8_str("result")); |
+ CHECK(result->IsString()); |
+ v8::String::Utf8Value utf8(result); |
+ CHECK_EQ("a+an X", *utf8); |
+ CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(CcTest::i_isolate())); |
} |
@@ -416,7 +406,6 @@ static void CompileConstructorWithDeoptimizingValueOf() { |
static void TestDeoptimizeBinaryOpHelper(LocalContext* env, |
const char* binary_op) { |
- i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>((*env)->GetIsolate()); |
EmbeddedVector<char, SMALL_STRING_BUFFER_SIZE> f_source_buffer; |
SNPrintF(f_source_buffer, |
"function f(x, y) { return x %s y; };", |
@@ -437,355 +426,290 @@ static void TestDeoptimizeBinaryOpHelper(LocalContext* env, |
i::FLAG_always_opt = true; |
CompileRun(f_source); |
CompileRun("f(7, new X());"); |
- CHECK(!i_isolate->use_crankshaft() || |
+ CHECK(!CcTest::i_isolate()->use_crankshaft() || |
GetJSFunction((*env)->Global(), "f")->IsOptimized()); |
// Call f and force deoptimization while processing the binary operation. |
CompileRun("deopt = true;" |
"var result = f(7, new X());"); |
- NonIncrementalGC(i_isolate); |
+ NonIncrementalGC(); |
CHECK(!GetJSFunction((*env)->Global(), "f")->IsOptimized()); |
} |
-UNINITIALIZED_TEST(DeoptimizeBinaryOperationADD) { |
+TEST(DeoptimizeBinaryOperationADD) { |
i::FLAG_turbo_deoptimization = true; |
i::FLAG_concurrent_recompilation = false; |
- v8::Isolate* isolate = v8::Isolate::New(); |
- i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
- isolate->Enter(); |
- { |
- LocalContext env(isolate); |
- v8::HandleScope scope(env->GetIsolate()); |
+ LocalContext env; |
+ v8::HandleScope scope(env->GetIsolate()); |
- TestDeoptimizeBinaryOpHelper(&env, "+"); |
+ TestDeoptimizeBinaryOpHelper(&env, "+"); |
- CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); |
- CHECK_EQ(15, env->Global()->Get(v8_str("result"))->Int32Value()); |
- CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(i_isolate)); |
- } |
- isolate->Exit(); |
- isolate->Dispose(); |
+ CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); |
+ CHECK_EQ(15, env->Global()->Get(v8_str("result"))->Int32Value()); |
+ CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(CcTest::i_isolate())); |
} |
-UNINITIALIZED_TEST(DeoptimizeBinaryOperationSUB) { |
+TEST(DeoptimizeBinaryOperationSUB) { |
i::FLAG_turbo_deoptimization = true; |
i::FLAG_concurrent_recompilation = false; |
- v8::Isolate* isolate = v8::Isolate::New(); |
- i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
- isolate->Enter(); |
- { |
- LocalContext env(isolate); |
- v8::HandleScope scope(env->GetIsolate()); |
+ LocalContext env; |
+ v8::HandleScope scope(env->GetIsolate()); |
- TestDeoptimizeBinaryOpHelper(&env, "-"); |
+ TestDeoptimizeBinaryOpHelper(&env, "-"); |
- CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); |
- CHECK_EQ(-1, env->Global()->Get(v8_str("result"))->Int32Value()); |
- CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(i_isolate)); |
- } |
- isolate->Exit(); |
- isolate->Dispose(); |
+ CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); |
+ CHECK_EQ(-1, env->Global()->Get(v8_str("result"))->Int32Value()); |
+ CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(CcTest::i_isolate())); |
} |
-UNINITIALIZED_TEST(DeoptimizeBinaryOperationMUL) { |
+TEST(DeoptimizeBinaryOperationMUL) { |
i::FLAG_turbo_deoptimization = true; |
i::FLAG_concurrent_recompilation = false; |
- v8::Isolate* isolate = v8::Isolate::New(); |
- i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
- isolate->Enter(); |
- { |
- LocalContext env(isolate); |
- v8::HandleScope scope(env->GetIsolate()); |
+ LocalContext env; |
+ v8::HandleScope scope(env->GetIsolate()); |
- TestDeoptimizeBinaryOpHelper(&env, "*"); |
+ TestDeoptimizeBinaryOpHelper(&env, "*"); |
- CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); |
- CHECK_EQ(56, env->Global()->Get(v8_str("result"))->Int32Value()); |
- CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(i_isolate)); |
- } |
- isolate->Exit(); |
- isolate->Dispose(); |
+ CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); |
+ CHECK_EQ(56, env->Global()->Get(v8_str("result"))->Int32Value()); |
+ CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(CcTest::i_isolate())); |
} |
-UNINITIALIZED_TEST(DeoptimizeBinaryOperationDIV) { |
+TEST(DeoptimizeBinaryOperationDIV) { |
i::FLAG_turbo_deoptimization = true; |
i::FLAG_concurrent_recompilation = false; |
- v8::Isolate* isolate = v8::Isolate::New(); |
- i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
- isolate->Enter(); |
- { |
- LocalContext env(isolate); |
- v8::HandleScope scope(env->GetIsolate()); |
+ LocalContext env; |
+ v8::HandleScope scope(env->GetIsolate()); |
- TestDeoptimizeBinaryOpHelper(&env, "/"); |
+ TestDeoptimizeBinaryOpHelper(&env, "/"); |
- CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); |
- CHECK_EQ(0, env->Global()->Get(v8_str("result"))->Int32Value()); |
- CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(i_isolate)); |
- } |
- isolate->Exit(); |
- isolate->Dispose(); |
+ CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); |
+ CHECK_EQ(0, env->Global()->Get(v8_str("result"))->Int32Value()); |
+ CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(CcTest::i_isolate())); |
} |
-UNINITIALIZED_TEST(DeoptimizeBinaryOperationMOD) { |
+TEST(DeoptimizeBinaryOperationMOD) { |
i::FLAG_turbo_deoptimization = true; |
i::FLAG_concurrent_recompilation = false; |
- v8::Isolate* isolate = v8::Isolate::New(); |
- i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
- isolate->Enter(); |
- { |
- LocalContext env(isolate); |
- v8::HandleScope scope(env->GetIsolate()); |
+ LocalContext env; |
+ v8::HandleScope scope(env->GetIsolate()); |
- TestDeoptimizeBinaryOpHelper(&env, "%"); |
+ TestDeoptimizeBinaryOpHelper(&env, "%"); |
- CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); |
- CHECK_EQ(7, env->Global()->Get(v8_str("result"))->Int32Value()); |
- CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(i_isolate)); |
- } |
- isolate->Exit(); |
- isolate->Dispose(); |
+ CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); |
+ CHECK_EQ(7, env->Global()->Get(v8_str("result"))->Int32Value()); |
+ CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(CcTest::i_isolate())); |
} |
-UNINITIALIZED_TEST(DeoptimizeCompare) { |
+TEST(DeoptimizeCompare) { |
i::FLAG_turbo_deoptimization = true; |
i::FLAG_concurrent_recompilation = false; |
- v8::Isolate* isolate = v8::Isolate::New(); |
- i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
- isolate->Enter(); |
- { |
- LocalContext env(isolate); |
- v8::HandleScope scope(env->GetIsolate()); |
- |
- const char* f_source = "function f(x, y) { return x < y; };"; |
- |
- { |
- AllowNativesSyntaxNoInlining options; |
- // Compile function f and collect to type feedback to insert compare ic |
- // call in the optimized code. |
- i::FLAG_prepare_always_opt = true; |
- CompileRun( |
- "var count = 0;" |
- "var result = 0;" |
- "var deopt = false;" |
- "function X() { };" |
- "X.prototype.toString = function () {" |
- " if (deopt) { count++; %DeoptimizeFunction(f); } return 'b'" |
- "};"); |
- CompileRun(f_source); |
- CompileRun( |
- "for (var i = 0; i < 5; i++) {" |
- " f('a', new X());" |
- "};"); |
- |
- // Compile an optimized version of f. |
- i::FLAG_always_opt = true; |
- CompileRun(f_source); |
- CompileRun("f('a', new X());"); |
- CHECK(!i_isolate->use_crankshaft() || |
- GetJSFunction(env->Global(), "f")->IsOptimized()); |
- |
- // Call f and force deoptimization while processing the comparison. |
- CompileRun( |
- "deopt = true;" |
- "var result = f('a', new X());"); |
- } |
- NonIncrementalGC(i_isolate); |
+ LocalContext env; |
+ v8::HandleScope scope(env->GetIsolate()); |
- CHECK(!GetJSFunction(env->Global(), "f")->IsOptimized()); |
- CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); |
- CHECK_EQ(true, env->Global()->Get(v8_str("result"))->BooleanValue()); |
- CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(i_isolate)); |
+ const char* f_source = "function f(x, y) { return x < y; };"; |
+ |
+ { |
+ AllowNativesSyntaxNoInlining options; |
+ // Compile function f and collect to type feedback to insert compare ic |
+ // call in the optimized code. |
+ i::FLAG_prepare_always_opt = true; |
+ CompileRun("var count = 0;" |
+ "var result = 0;" |
+ "var deopt = false;" |
+ "function X() { };" |
+ "X.prototype.toString = function () {" |
+ " if (deopt) { count++; %DeoptimizeFunction(f); } return 'b'" |
+ "};"); |
+ CompileRun(f_source); |
+ CompileRun("for (var i = 0; i < 5; i++) {" |
+ " f('a', new X());" |
+ "};"); |
+ |
+ // Compile an optimized version of f. |
+ i::FLAG_always_opt = true; |
+ CompileRun(f_source); |
+ CompileRun("f('a', new X());"); |
+ CHECK(!CcTest::i_isolate()->use_crankshaft() || |
+ GetJSFunction(env->Global(), "f")->IsOptimized()); |
+ |
+ // Call f and force deoptimization while processing the comparison. |
+ CompileRun("deopt = true;" |
+ "var result = f('a', new X());"); |
} |
- isolate->Exit(); |
- isolate->Dispose(); |
+ NonIncrementalGC(); |
+ |
+ CHECK(!GetJSFunction(env->Global(), "f")->IsOptimized()); |
+ CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); |
+ CHECK_EQ(true, env->Global()->Get(v8_str("result"))->BooleanValue()); |
+ CHECK_EQ(0, Deoptimizer::GetDeoptimizedCodeCount(CcTest::i_isolate())); |
} |
-UNINITIALIZED_TEST(DeoptimizeLoadICStoreIC) { |
+TEST(DeoptimizeLoadICStoreIC) { |
i::FLAG_turbo_deoptimization = true; |
i::FLAG_concurrent_recompilation = false; |
- v8::Isolate* isolate = v8::Isolate::New(); |
- i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
- isolate->Enter(); |
+ LocalContext env; |
+ v8::HandleScope scope(env->GetIsolate()); |
+ |
+ // Functions to generate load/store/keyed load/keyed store IC calls. |
+ const char* f1_source = "function f1(x) { return x.y; };"; |
+ const char* g1_source = "function g1(x) { x.y = 1; };"; |
+ const char* f2_source = "function f2(x, y) { return x[y]; };"; |
+ const char* g2_source = "function g2(x, y) { x[y] = 1; };"; |
+ |
{ |
- LocalContext env(isolate); |
- v8::HandleScope scope(env->GetIsolate()); |
- |
- // Functions to generate load/store/keyed load/keyed store IC calls. |
- const char* f1_source = "function f1(x) { return x.y; };"; |
- const char* g1_source = "function g1(x) { x.y = 1; };"; |
- const char* f2_source = "function f2(x, y) { return x[y]; };"; |
- const char* g2_source = "function g2(x, y) { x[y] = 1; };"; |
- |
- { |
- AllowNativesSyntaxNoInlining options; |
- // Compile functions and collect to type feedback to insert ic |
- // calls in the optimized code. |
- i::FLAG_prepare_always_opt = true; |
- CompileRun( |
- "var count = 0;" |
- "var result = 0;" |
- "var deopt = false;" |
- "function X() { };" |
- "X.prototype.__defineGetter__('y', function () {" |
- " if (deopt) { count++; %DeoptimizeFunction(f1); };" |
- " return 13;" |
- "});" |
- "X.prototype.__defineSetter__('y', function () {" |
- " if (deopt) { count++; %DeoptimizeFunction(g1); };" |
- "});" |
- "X.prototype.__defineGetter__('z', function () {" |
- " if (deopt) { count++; %DeoptimizeFunction(f2); };" |
- " return 13;" |
- "});" |
- "X.prototype.__defineSetter__('z', function () {" |
- " if (deopt) { count++; %DeoptimizeFunction(g2); };" |
- "});"); |
- CompileRun(f1_source); |
- CompileRun(g1_source); |
- CompileRun(f2_source); |
- CompileRun(g2_source); |
- CompileRun( |
- "for (var i = 0; i < 5; i++) {" |
- " f1(new X());" |
- " g1(new X());" |
- " f2(new X(), 'z');" |
- " g2(new X(), 'z');" |
- "};"); |
- |
- // Compile an optimized version of the functions. |
- i::FLAG_always_opt = true; |
- CompileRun(f1_source); |
- CompileRun(g1_source); |
- CompileRun(f2_source); |
- CompileRun(g2_source); |
- CompileRun("f1(new X());"); |
- CompileRun("g1(new X());"); |
- CompileRun("f2(new X(), 'z');"); |
- CompileRun("g2(new X(), 'z');"); |
- if (i_isolate->use_crankshaft()) { |
- CHECK(GetJSFunction(env->Global(), "f1")->IsOptimized()); |
- CHECK(GetJSFunction(env->Global(), "g1")->IsOptimized()); |
- CHECK(GetJSFunction(env->Global(), "f2")->IsOptimized()); |
- CHECK(GetJSFunction(env->Global(), "g2")->IsOptimized()); |
- } |
- |
- // Call functions and force deoptimization while processing the ics. |
- CompileRun( |
- "deopt = true;" |
- "var result = f1(new X());" |
- "g1(new X());" |
- "f2(new X(), 'z');" |
- "g2(new X(), 'z');"); |
+ AllowNativesSyntaxNoInlining options; |
+ // Compile functions and collect to type feedback to insert ic |
+ // calls in the optimized code. |
+ i::FLAG_prepare_always_opt = true; |
+ CompileRun("var count = 0;" |
+ "var result = 0;" |
+ "var deopt = false;" |
+ "function X() { };" |
+ "X.prototype.__defineGetter__('y', function () {" |
+ " if (deopt) { count++; %DeoptimizeFunction(f1); };" |
+ " return 13;" |
+ "});" |
+ "X.prototype.__defineSetter__('y', function () {" |
+ " if (deopt) { count++; %DeoptimizeFunction(g1); };" |
+ "});" |
+ "X.prototype.__defineGetter__('z', function () {" |
+ " if (deopt) { count++; %DeoptimizeFunction(f2); };" |
+ " return 13;" |
+ "});" |
+ "X.prototype.__defineSetter__('z', function () {" |
+ " if (deopt) { count++; %DeoptimizeFunction(g2); };" |
+ "});"); |
+ CompileRun(f1_source); |
+ CompileRun(g1_source); |
+ CompileRun(f2_source); |
+ CompileRun(g2_source); |
+ CompileRun("for (var i = 0; i < 5; i++) {" |
+ " f1(new X());" |
+ " g1(new X());" |
+ " f2(new X(), 'z');" |
+ " g2(new X(), 'z');" |
+ "};"); |
+ |
+ // Compile an optimized version of the functions. |
+ i::FLAG_always_opt = true; |
+ CompileRun(f1_source); |
+ CompileRun(g1_source); |
+ CompileRun(f2_source); |
+ CompileRun(g2_source); |
+ CompileRun("f1(new X());"); |
+ CompileRun("g1(new X());"); |
+ CompileRun("f2(new X(), 'z');"); |
+ CompileRun("g2(new X(), 'z');"); |
+ if (CcTest::i_isolate()->use_crankshaft()) { |
+ CHECK(GetJSFunction(env->Global(), "f1")->IsOptimized()); |
+ CHECK(GetJSFunction(env->Global(), "g1")->IsOptimized()); |
+ CHECK(GetJSFunction(env->Global(), "f2")->IsOptimized()); |
+ CHECK(GetJSFunction(env->Global(), "g2")->IsOptimized()); |
} |
- NonIncrementalGC(i_isolate); |
- |
- CHECK(!GetJSFunction(env->Global(), "f1")->IsOptimized()); |
- CHECK(!GetJSFunction(env->Global(), "g1")->IsOptimized()); |
- CHECK(!GetJSFunction(env->Global(), "f2")->IsOptimized()); |
- CHECK(!GetJSFunction(env->Global(), "g2")->IsOptimized()); |
- CHECK_EQ(4, env->Global()->Get(v8_str("count"))->Int32Value()); |
- CHECK_EQ(13, env->Global()->Get(v8_str("result"))->Int32Value()); |
+ |
+ // Call functions and force deoptimization while processing the ics. |
+ CompileRun("deopt = true;" |
+ "var result = f1(new X());" |
+ "g1(new X());" |
+ "f2(new X(), 'z');" |
+ "g2(new X(), 'z');"); |
} |
- isolate->Exit(); |
- isolate->Dispose(); |
+ NonIncrementalGC(); |
+ |
+ CHECK(!GetJSFunction(env->Global(), "f1")->IsOptimized()); |
+ CHECK(!GetJSFunction(env->Global(), "g1")->IsOptimized()); |
+ CHECK(!GetJSFunction(env->Global(), "f2")->IsOptimized()); |
+ CHECK(!GetJSFunction(env->Global(), "g2")->IsOptimized()); |
+ CHECK_EQ(4, env->Global()->Get(v8_str("count"))->Int32Value()); |
+ CHECK_EQ(13, env->Global()->Get(v8_str("result"))->Int32Value()); |
} |
-UNINITIALIZED_TEST(DeoptimizeLoadICStoreICNested) { |
+TEST(DeoptimizeLoadICStoreICNested) { |
i::FLAG_turbo_deoptimization = true; |
i::FLAG_concurrent_recompilation = false; |
- v8::Isolate* isolate = v8::Isolate::New(); |
- i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
- isolate->Enter(); |
+ LocalContext env; |
+ v8::HandleScope scope(env->GetIsolate()); |
+ |
+ // Functions to generate load/store/keyed load/keyed store IC calls. |
+ const char* f1_source = "function f1(x) { return x.y; };"; |
+ const char* g1_source = "function g1(x) { x.y = 1; };"; |
+ const char* f2_source = "function f2(x, y) { return x[y]; };"; |
+ const char* g2_source = "function g2(x, y) { x[y] = 1; };"; |
+ |
{ |
- LocalContext env(isolate); |
- v8::HandleScope scope(env->GetIsolate()); |
- |
- // Functions to generate load/store/keyed load/keyed store IC calls. |
- const char* f1_source = "function f1(x) { return x.y; };"; |
- const char* g1_source = "function g1(x) { x.y = 1; };"; |
- const char* f2_source = "function f2(x, y) { return x[y]; };"; |
- const char* g2_source = "function g2(x, y) { x[y] = 1; };"; |
- |
- { |
- AllowNativesSyntaxNoInlining options; |
- // Compile functions and collect to type feedback to insert ic |
- // calls in the optimized code. |
- i::FLAG_prepare_always_opt = true; |
- CompileRun( |
- "var count = 0;" |
- "var result = 0;" |
- "var deopt = false;" |
- "function X() { };" |
- "X.prototype.__defineGetter__('y', function () {" |
- " g1(this);" |
- " return 13;" |
- "});" |
- "X.prototype.__defineSetter__('y', function () {" |
- " f2(this, 'z');" |
- "});" |
- "X.prototype.__defineGetter__('z', function () {" |
- " g2(this, 'z');" |
- "});" |
- "X.prototype.__defineSetter__('z', function () {" |
- " if (deopt) {" |
- " count++;" |
- " %DeoptimizeFunction(f1);" |
- " %DeoptimizeFunction(g1);" |
- " %DeoptimizeFunction(f2);" |
- " %DeoptimizeFunction(g2); };" |
- "});"); |
- CompileRun(f1_source); |
- CompileRun(g1_source); |
- CompileRun(f2_source); |
- CompileRun(g2_source); |
- CompileRun( |
- "for (var i = 0; i < 5; i++) {" |
- " f1(new X());" |
- " g1(new X());" |
- " f2(new X(), 'z');" |
- " g2(new X(), 'z');" |
- "};"); |
- |
- // Compile an optimized version of the functions. |
- i::FLAG_always_opt = true; |
- CompileRun(f1_source); |
- CompileRun(g1_source); |
- CompileRun(f2_source); |
- CompileRun(g2_source); |
- CompileRun("f1(new X());"); |
- CompileRun("g1(new X());"); |
- CompileRun("f2(new X(), 'z');"); |
- CompileRun("g2(new X(), 'z');"); |
- if (i_isolate->use_crankshaft()) { |
- CHECK(GetJSFunction(env->Global(), "f1")->IsOptimized()); |
- CHECK(GetJSFunction(env->Global(), "g1")->IsOptimized()); |
- CHECK(GetJSFunction(env->Global(), "f2")->IsOptimized()); |
- CHECK(GetJSFunction(env->Global(), "g2")->IsOptimized()); |
- } |
- |
- // Call functions and force deoptimization while processing the ics. |
- CompileRun( |
- "deopt = true;" |
- "var result = f1(new X());"); |
+ AllowNativesSyntaxNoInlining options; |
+ // Compile functions and collect to type feedback to insert ic |
+ // calls in the optimized code. |
+ i::FLAG_prepare_always_opt = true; |
+ CompileRun("var count = 0;" |
+ "var result = 0;" |
+ "var deopt = false;" |
+ "function X() { };" |
+ "X.prototype.__defineGetter__('y', function () {" |
+ " g1(this);" |
+ " return 13;" |
+ "});" |
+ "X.prototype.__defineSetter__('y', function () {" |
+ " f2(this, 'z');" |
+ "});" |
+ "X.prototype.__defineGetter__('z', function () {" |
+ " g2(this, 'z');" |
+ "});" |
+ "X.prototype.__defineSetter__('z', function () {" |
+ " if (deopt) {" |
+ " count++;" |
+ " %DeoptimizeFunction(f1);" |
+ " %DeoptimizeFunction(g1);" |
+ " %DeoptimizeFunction(f2);" |
+ " %DeoptimizeFunction(g2); };" |
+ "});"); |
+ CompileRun(f1_source); |
+ CompileRun(g1_source); |
+ CompileRun(f2_source); |
+ CompileRun(g2_source); |
+ CompileRun("for (var i = 0; i < 5; i++) {" |
+ " f1(new X());" |
+ " g1(new X());" |
+ " f2(new X(), 'z');" |
+ " g2(new X(), 'z');" |
+ "};"); |
+ |
+ // Compile an optimized version of the functions. |
+ i::FLAG_always_opt = true; |
+ CompileRun(f1_source); |
+ CompileRun(g1_source); |
+ CompileRun(f2_source); |
+ CompileRun(g2_source); |
+ CompileRun("f1(new X());"); |
+ CompileRun("g1(new X());"); |
+ CompileRun("f2(new X(), 'z');"); |
+ CompileRun("g2(new X(), 'z');"); |
+ if (CcTest::i_isolate()->use_crankshaft()) { |
+ CHECK(GetJSFunction(env->Global(), "f1")->IsOptimized()); |
+ CHECK(GetJSFunction(env->Global(), "g1")->IsOptimized()); |
+ CHECK(GetJSFunction(env->Global(), "f2")->IsOptimized()); |
+ CHECK(GetJSFunction(env->Global(), "g2")->IsOptimized()); |
} |
- NonIncrementalGC(i_isolate); |
- CHECK(!GetJSFunction(env->Global(), "f1")->IsOptimized()); |
- CHECK(!GetJSFunction(env->Global(), "g1")->IsOptimized()); |
- CHECK(!GetJSFunction(env->Global(), "f2")->IsOptimized()); |
- CHECK(!GetJSFunction(env->Global(), "g2")->IsOptimized()); |
- CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); |
- CHECK_EQ(13, env->Global()->Get(v8_str("result"))->Int32Value()); |
+ // Call functions and force deoptimization while processing the ics. |
+ CompileRun("deopt = true;" |
+ "var result = f1(new X());"); |
} |
- isolate->Exit(); |
- isolate->Dispose(); |
+ NonIncrementalGC(); |
+ |
+ CHECK(!GetJSFunction(env->Global(), "f1")->IsOptimized()); |
+ CHECK(!GetJSFunction(env->Global(), "g1")->IsOptimized()); |
+ CHECK(!GetJSFunction(env->Global(), "f2")->IsOptimized()); |
+ CHECK(!GetJSFunction(env->Global(), "g2")->IsOptimized()); |
+ CHECK_EQ(1, env->Global()->Get(v8_str("count"))->Int32Value()); |
+ CHECK_EQ(13, env->Global()->Get(v8_str("result"))->Int32Value()); |
} |