Chromium Code Reviews| Index: test/cctest/test-heap.cc |
| diff --git a/test/cctest/test-heap.cc b/test/cctest/test-heap.cc |
| index 2824d5b242465f2784656c386938750df435ac67..cf18384e2d9b7acbee35a01155640300631d1224 100644 |
| --- a/test/cctest/test-heap.cc |
| +++ b/test/cctest/test-heap.cc |
| @@ -40,6 +40,11 @@ |
| using namespace v8::internal; |
| +static v8::Local<v8::Object> GetGlobal() { |
|
Michael Starzinger
2013/09/23 09:24:47
Can we move that onto the CcTest class, maybe as a
|
| + return CcTest::isolate()->GetCurrentContext()->Global(); |
| +} |
| + |
| + |
| // Go through all incremental marking steps in one swoop. |
| static void SimulateIncrementalMarking() { |
| MarkCompactCollector* collector = CcTest::heap()->mark_compact_collector(); |
| @@ -1897,7 +1902,7 @@ TEST(InstanceOfStubWriteBarrier) { |
| Handle<JSFunction> f = |
| v8::Utils::OpenHandle( |
| *v8::Handle<v8::Function>::Cast( |
| - v8::Context::GetCurrent()->Global()->Get(v8_str("f")))); |
| + GetGlobal()->Get(v8_str("f")))); |
| CHECK(f->IsOptimized()); |
| @@ -1912,7 +1917,7 @@ TEST(InstanceOfStubWriteBarrier) { |
| { |
| v8::HandleScope scope(CcTest::isolate()); |
| - v8::Handle<v8::Object> global = v8::Context::GetCurrent()->Global(); |
| + v8::Handle<v8::Object> global = GetGlobal(); |
| v8::Handle<v8::Function> g = |
| v8::Handle<v8::Function>::Cast(global->Get(v8_str("g"))); |
| g->Call(global, 0, NULL); |
| @@ -1942,7 +1947,7 @@ TEST(PrototypeTransitionClearing) { |
| Handle<JSObject> baseObject = |
| v8::Utils::OpenHandle( |
| *v8::Handle<v8::Object>::Cast( |
| - v8::Context::GetCurrent()->Global()->Get(v8_str("base")))); |
| + GetGlobal()->Get(v8_str("base")))); |
| // Verify that only dead prototype transitions are cleared. |
| CHECK_EQ(10, baseObject->map()->NumberOfProtoTransitions()); |
| @@ -2009,7 +2014,7 @@ TEST(ResetSharedFunctionInfoCountersDuringIncrementalMarking) { |
| Handle<JSFunction> f = |
| v8::Utils::OpenHandle( |
| *v8::Handle<v8::Function>::Cast( |
| - v8::Context::GetCurrent()->Global()->Get(v8_str("f")))); |
| + GetGlobal()->Get(v8_str("f")))); |
| CHECK(f->IsOptimized()); |
| IncrementalMarking* marking = CcTest::heap()->incremental_marking(); |
| @@ -2066,7 +2071,7 @@ TEST(ResetSharedFunctionInfoCountersDuringMarkSweep) { |
| Handle<JSFunction> f = |
| v8::Utils::OpenHandle( |
| *v8::Handle<v8::Function>::Cast( |
| - v8::Context::GetCurrent()->Global()->Get(v8_str("f")))); |
| + GetGlobal()->Get(v8_str("f")))); |
| CHECK(f->IsOptimized()); |
| CcTest::heap()->incremental_marking()->Abort(); |
| @@ -2475,7 +2480,7 @@ TEST(Regress1465) { |
| Handle<JSObject> root = |
| v8::Utils::OpenHandle( |
| *v8::Handle<v8::Object>::Cast( |
| - v8::Context::GetCurrent()->Global()->Get(v8_str("root")))); |
| + GetGlobal()->Get(v8_str("root")))); |
| // Count number of live transitions before marking. |
| int transitions_before = CountMapTransitions(root->map()); |
| @@ -2525,7 +2530,7 @@ TEST(Regress2143a) { |
| Handle<JSObject> root = |
| v8::Utils::OpenHandle( |
| *v8::Handle<v8::Object>::Cast( |
| - v8::Context::GetCurrent()->Global()->Get(v8_str("root")))); |
| + GetGlobal()->Get(v8_str("root")))); |
| // The root object should be in a sane state. |
| CHECK(root->IsJSObject()); |
| @@ -2569,7 +2574,7 @@ TEST(Regress2143b) { |
| Handle<JSObject> root = |
| v8::Utils::OpenHandle( |
| *v8::Handle<v8::Object>::Cast( |
| - v8::Context::GetCurrent()->Global()->Get(v8_str("root")))); |
| + GetGlobal()->Get(v8_str("root")))); |
| // The root object should be in a sane state. |
| CHECK(root->IsJSObject()); |
| @@ -2665,7 +2670,7 @@ TEST(PrintSharedFunctionInfo) { |
| Handle<JSFunction> g = |
| v8::Utils::OpenHandle( |
| *v8::Handle<v8::Function>::Cast( |
| - v8::Context::GetCurrent()->Global()->Get(v8_str("g")))); |
| + GetGlobal()->Get(v8_str("g")))); |
| DisallowHeapAllocation no_allocation; |
| g->shared()->PrintLn(); |
| @@ -2728,13 +2733,13 @@ TEST(IncrementalMarkingClearsTypeFeedbackCells) { |
| // Prepare function f that contains type feedback for closures |
| // originating from two different native contexts. |
| - v8::Context::GetCurrent()->Global()->Set(v8_str("fun1"), fun1); |
| - v8::Context::GetCurrent()->Global()->Set(v8_str("fun2"), fun2); |
| + GetGlobal()->Set(v8_str("fun1"), fun1); |
| + GetGlobal()->Set(v8_str("fun2"), fun2); |
| CompileRun("function f(a, b) { a(); b(); } f(fun1, fun2);"); |
| Handle<JSFunction> f = |
| v8::Utils::OpenHandle( |
| *v8::Handle<v8::Function>::Cast( |
| - v8::Context::GetCurrent()->Global()->Get(v8_str("f")))); |
| + GetGlobal()->Get(v8_str("f")))); |
| Handle<TypeFeedbackCells> cells(TypeFeedbackInfo::cast( |
| f->shared()->code()->type_feedback_info())->type_feedback_cells()); |
| @@ -2779,7 +2784,7 @@ TEST(IncrementalMarkingPreservesMonomorhpicIC) { |
| Handle<JSFunction> f = |
| v8::Utils::OpenHandle( |
| *v8::Handle<v8::Function>::Cast( |
| - v8::Context::GetCurrent()->Global()->Get(v8_str("f")))); |
| + GetGlobal()->Get(v8_str("f")))); |
| Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC); |
| CHECK(ic_before->ic_state() == MONOMORPHIC); |
| @@ -2806,12 +2811,12 @@ TEST(IncrementalMarkingClearsMonomorhpicIC) { |
| // Prepare function f that contains a monomorphic IC for object |
| // originating from a different native context. |
| - v8::Context::GetCurrent()->Global()->Set(v8_str("obj1"), obj1); |
| + GetGlobal()->Set(v8_str("obj1"), obj1); |
| CompileRun("function f(o) { return o.x; } f(obj1); f(obj1);"); |
| Handle<JSFunction> f = |
| v8::Utils::OpenHandle( |
| *v8::Handle<v8::Function>::Cast( |
| - v8::Context::GetCurrent()->Global()->Get(v8_str("f")))); |
| + GetGlobal()->Get(v8_str("f")))); |
| Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC); |
| CHECK(ic_before->ic_state() == MONOMORPHIC); |
| @@ -2846,13 +2851,13 @@ TEST(IncrementalMarkingClearsPolymorhpicIC) { |
| // Prepare function f that contains a polymorphic IC for objects |
| // originating from two different native contexts. |
| - v8::Context::GetCurrent()->Global()->Set(v8_str("obj1"), obj1); |
| - v8::Context::GetCurrent()->Global()->Set(v8_str("obj2"), obj2); |
| + GetGlobal()->Set(v8_str("obj1"), obj1); |
| + GetGlobal()->Set(v8_str("obj2"), obj2); |
| CompileRun("function f(o) { return o.x; } f(obj1); f(obj1); f(obj2);"); |
| Handle<JSFunction> f = |
| v8::Utils::OpenHandle( |
| *v8::Handle<v8::Function>::Cast( |
| - v8::Context::GetCurrent()->Global()->Get(v8_str("f")))); |
| + GetGlobal()->Get(v8_str("f")))); |
| Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC); |
| CHECK(ic_before->ic_state() == POLYMORPHIC); |
| @@ -3057,14 +3062,14 @@ TEST(Regress159140) { |
| Handle<JSFunction> f = |
| v8::Utils::OpenHandle( |
| *v8::Handle<v8::Function>::Cast( |
| - v8::Context::GetCurrent()->Global()->Get(v8_str("f")))); |
| + GetGlobal()->Get(v8_str("f")))); |
| CHECK(f->is_compiled()); |
| CompileRun("f = null;"); |
| Handle<JSFunction> g = |
| v8::Utils::OpenHandle( |
| *v8::Handle<v8::Function>::Cast( |
| - v8::Context::GetCurrent()->Global()->Get(v8_str("g")))); |
| + GetGlobal()->Get(v8_str("g")))); |
| CHECK(g->is_compiled()); |
| const int kAgingThreshold = 6; |
| for (int i = 0; i < kAgingThreshold; i++) { |
| @@ -3112,7 +3117,7 @@ TEST(Regress165495) { |
| Handle<JSFunction> f = |
| v8::Utils::OpenHandle( |
| *v8::Handle<v8::Function>::Cast( |
| - v8::Context::GetCurrent()->Global()->Get(v8_str("f")))); |
| + GetGlobal()->Get(v8_str("f")))); |
| CHECK(f->is_compiled()); |
| const int kAgingThreshold = 6; |
| for (int i = 0; i < kAgingThreshold; i++) { |
| @@ -3160,7 +3165,7 @@ TEST(Regress169209) { |
| Handle<JSFunction> f = |
| v8::Utils::OpenHandle( |
| *v8::Handle<v8::Function>::Cast( |
| - v8::Context::GetCurrent()->Global()->Get(v8_str("f")))); |
| + GetGlobal()->Get(v8_str("f")))); |
| CHECK(f->is_compiled()); |
| const int kAgingThreshold = 6; |
| for (int i = 0; i < kAgingThreshold; i++) { |
| @@ -3181,7 +3186,7 @@ TEST(Regress169209) { |
| Handle<JSFunction> f = |
| v8::Utils::OpenHandle( |
| *v8::Handle<v8::Function>::Cast( |
| - v8::Context::GetCurrent()->Global()->Get(v8_str("flushMe")))); |
| + GetGlobal()->Get(v8_str("flushMe")))); |
| CHECK(f->is_compiled()); |
| const int kAgingThreshold = 6; |
| for (int i = 0; i < kAgingThreshold; i++) { |
| @@ -3251,7 +3256,7 @@ TEST(Regress169928) { |
| v8_str("fastliteralcase(mote, 2.5);"); |
| v8::Local<v8::String> array_name = v8_str("mote"); |
| - v8::Context::GetCurrent()->Global()->Set(array_name, v8::Int32::New(0)); |
| + GetGlobal()->Set(array_name, v8::Int32::New(0)); |
| // First make sure we flip spaces |
| CcTest::heap()->CollectGarbage(NEW_SPACE); |
| @@ -3285,7 +3290,7 @@ TEST(Regress169928) { |
| // Give the array a name, making sure not to allocate strings. |
| v8::Handle<v8::Object> array_obj = v8::Utils::ToLocal(array); |
| - v8::Context::GetCurrent()->Global()->Set(array_name, array_obj); |
| + GetGlobal()->Set(array_name, array_obj); |
| // This should crash with a protection violation if we are running a build |
| // with the bug. |
| @@ -3323,7 +3328,7 @@ TEST(Regress168801) { |
| Handle<JSFunction> f = |
| v8::Utils::OpenHandle( |
| *v8::Handle<v8::Function>::Cast( |
| - v8::Context::GetCurrent()->Global()->Get(v8_str("f")))); |
| + GetGlobal()->Get(v8_str("f")))); |
| CHECK(f->is_compiled()); |
| const int kAgingThreshold = 6; |
| for (int i = 0; i < kAgingThreshold; i++) { |
| @@ -3379,7 +3384,7 @@ TEST(Regress173458) { |
| Handle<JSFunction> f = |
| v8::Utils::OpenHandle( |
| *v8::Handle<v8::Function>::Cast( |
| - v8::Context::GetCurrent()->Global()->Get(v8_str("f")))); |
| + GetGlobal()->Get(v8_str("f")))); |
| CHECK(f->is_compiled()); |
| const int kAgingThreshold = 6; |
| for (int i = 0; i < kAgingThreshold; i++) { |