diff options
Diffstat (limited to 'deps/v8/test/cctest/test-heap.cc')
-rw-r--r-- | deps/v8/test/cctest/test-heap.cc | 752 |
1 files changed, 409 insertions, 343 deletions
diff --git a/deps/v8/test/cctest/test-heap.cc b/deps/v8/test/cctest/test-heap.cc index 9d74011fd..74c2b7581 100644 --- a/deps/v8/test/cctest/test-heap.cc +++ b/deps/v8/test/cctest/test-heap.cc @@ -42,8 +42,8 @@ using namespace v8::internal; // Go through all incremental marking steps in one swoop. static void SimulateIncrementalMarking() { - MarkCompactCollector* collector = HEAP->mark_compact_collector(); - IncrementalMarking* marking = HEAP->incremental_marking(); + MarkCompactCollector* collector = CcTest::heap()->mark_compact_collector(); + IncrementalMarking* marking = CcTest::heap()->incremental_marking(); if (collector->IsConcurrentSweepingInProgress()) { collector->WaitUntilSweepingCompleted(); } @@ -62,9 +62,9 @@ static void SimulateIncrementalMarking() { static void CheckMap(Map* map, int type, int instance_size) { CHECK(map->IsHeapObject()); #ifdef DEBUG - CHECK(HEAP->Contains(map)); + CHECK(CcTest::heap()->Contains(map)); #endif - CHECK_EQ(HEAP->meta_map(), map->map()); + CHECK_EQ(CcTest::heap()->meta_map(), map->map()); CHECK_EQ(type, map->instance_type()); CHECK_EQ(instance_size, map->instance_size()); } @@ -72,10 +72,11 @@ static void CheckMap(Map* map, int type, int instance_size) { TEST(HeapMaps) { CcTest::InitializeVM(); - CheckMap(HEAP->meta_map(), MAP_TYPE, Map::kSize); - CheckMap(HEAP->heap_number_map(), HEAP_NUMBER_TYPE, HeapNumber::kSize); - CheckMap(HEAP->fixed_array_map(), FIXED_ARRAY_TYPE, kVariableSizeSentinel); - CheckMap(HEAP->string_map(), STRING_TYPE, kVariableSizeSentinel); + Heap* heap = CcTest::heap(); + CheckMap(heap->meta_map(), MAP_TYPE, Map::kSize); + CheckMap(heap->heap_number_map(), HEAP_NUMBER_TYPE, HeapNumber::kSize); + CheckMap(heap->fixed_array_map(), FIXED_ARRAY_TYPE, kVariableSizeSentinel); + CheckMap(heap->string_map(), STRING_TYPE, kVariableSizeSentinel); } @@ -99,7 +100,7 @@ static void CheckSmi(Isolate* isolate, int value, const char* string) { static void CheckNumber(Isolate* isolate, double value, const char* string) { - Object* obj = HEAP->NumberFromDouble(value)->ToObjectChecked(); + Object* obj = CcTest::heap()->NumberFromDouble(value)->ToObjectChecked(); CHECK(obj->IsNumber()); bool exc; Handle<Object> handle(obj, isolate); @@ -148,7 +149,7 @@ static void CheckFindCodeObject(Isolate* isolate) { TEST(HeapObjects) { CcTest::InitializeVM(); - Isolate* isolate = Isolate::Current(); + Isolate* isolate = CcTest::i_isolate(); Factory* factory = isolate->factory(); Heap* heap = isolate->heap(); @@ -209,10 +210,9 @@ TEST(HeapObjects) { CHECK(s->IsString()); CHECK_EQ(10, s->length()); - String* object_string = String::cast(heap->Object_string()); - CHECK( - Isolate::Current()->context()->global_object()->HasLocalProperty( - object_string)); + Handle<String> object_string = Handle<String>::cast(factory->Object_string()); + Handle<GlobalObject> global(CcTest::i_isolate()->context()->global_object()); + CHECK(JSReceiver::HasLocalProperty(global, object_string)); // Check ToString for oddballs CheckOddball(isolate, heap->true_value(), "true"); @@ -250,7 +250,7 @@ TEST(Tagging) { TEST(GarbageCollection) { CcTest::InitializeVM(); - Isolate* isolate = Isolate::Current(); + Isolate* isolate = CcTest::i_isolate(); Heap* heap = isolate->heap(); Factory* factory = isolate->factory(); @@ -258,10 +258,13 @@ TEST(GarbageCollection) { // Check GC. heap->CollectGarbage(NEW_SPACE); + Handle<GlobalObject> global(CcTest::i_isolate()->context()->global_object()); Handle<String> name = factory->InternalizeUtf8String("theFunction"); Handle<String> prop_name = factory->InternalizeUtf8String("theSlot"); Handle<String> prop_namex = factory->InternalizeUtf8String("theSlotx"); Handle<String> obj_name = factory->InternalizeUtf8String("theObject"); + Handle<Smi> twenty_three(Smi::FromInt(23), isolate); + Handle<Smi> twenty_four(Smi::FromInt(24), isolate); { HandleScope inner_scope(isolate); @@ -271,14 +274,11 @@ TEST(GarbageCollection) { Handle<Map> initial_map = factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); function->set_initial_map(*initial_map); - Isolate::Current()->context()->global_object()->SetProperty( - *name, *function, NONE, kNonStrictMode)->ToObjectChecked(); + JSReceiver::SetProperty(global, name, function, NONE, kNonStrictMode); // Allocate an object. Unrooted after leaving the scope. Handle<JSObject> obj = factory->NewJSObject(function); - obj->SetProperty( - *prop_name, Smi::FromInt(23), NONE, kNonStrictMode)->ToObjectChecked(); - obj->SetProperty( - *prop_namex, Smi::FromInt(24), NONE, kNonStrictMode)->ToObjectChecked(); + JSReceiver::SetProperty(obj, prop_name, twenty_three, NONE, kNonStrictMode); + JSReceiver::SetProperty(obj, prop_namex, twenty_four, NONE, kNonStrictMode); CHECK_EQ(Smi::FromInt(23), obj->GetProperty(*prop_name)); CHECK_EQ(Smi::FromInt(24), obj->GetProperty(*prop_namex)); @@ -287,10 +287,9 @@ TEST(GarbageCollection) { heap->CollectGarbage(NEW_SPACE); // Function should be alive. - CHECK(Isolate::Current()->context()->global_object()-> - HasLocalProperty(*name)); + CHECK(JSReceiver::HasLocalProperty(global, name)); // Check function is retained. - Object* func_value = Isolate::Current()->context()->global_object()-> + Object* func_value = CcTest::i_isolate()->context()->global_object()-> GetProperty(*name)->ToObjectChecked(); CHECK(func_value->IsJSFunction()); Handle<JSFunction> function(JSFunction::cast(func_value)); @@ -299,20 +298,17 @@ TEST(GarbageCollection) { HandleScope inner_scope(isolate); // Allocate another object, make it reachable from global. Handle<JSObject> obj = factory->NewJSObject(function); - Isolate::Current()->context()->global_object()->SetProperty( - *obj_name, *obj, NONE, kNonStrictMode)->ToObjectChecked(); - obj->SetProperty( - *prop_name, Smi::FromInt(23), NONE, kNonStrictMode)->ToObjectChecked(); + JSReceiver::SetProperty(global, obj_name, obj, NONE, kNonStrictMode); + JSReceiver::SetProperty(obj, prop_name, twenty_three, NONE, kNonStrictMode); } // After gc, it should survive. heap->CollectGarbage(NEW_SPACE); - CHECK(Isolate::Current()->context()->global_object()-> - HasLocalProperty(*obj_name)); - CHECK(Isolate::Current()->context()->global_object()-> + CHECK(JSReceiver::HasLocalProperty(global, obj_name)); + CHECK(CcTest::i_isolate()->context()->global_object()-> GetProperty(*obj_name)->ToObjectChecked()->IsJSObject()); - Object* obj = Isolate::Current()->context()->global_object()-> + Object* obj = CcTest::i_isolate()->context()->global_object()-> GetProperty(*obj_name)->ToObjectChecked(); JSObject* js_obj = JSObject::cast(obj); CHECK_EQ(Smi::FromInt(23), js_obj->GetProperty(*prop_name)); @@ -343,7 +339,7 @@ TEST(String) { TEST(LocalHandles) { CcTest::InitializeVM(); - Isolate* isolate = Isolate::Current(); + Isolate* isolate = CcTest::i_isolate(); Factory* factory = isolate->factory(); v8::HandleScope scope(CcTest::isolate()); @@ -355,7 +351,7 @@ TEST(LocalHandles) { TEST(GlobalHandles) { CcTest::InitializeVM(); - Isolate* isolate = Isolate::Current(); + Isolate* isolate = CcTest::i_isolate(); Heap* heap = isolate->heap(); Factory* factory = isolate->factory(); GlobalHandles* global_handles = isolate->global_handles(); @@ -408,7 +404,7 @@ static void TestWeakGlobalHandleCallback(v8::Isolate* isolate, TEST(WeakGlobalHandlesScavenge) { i::FLAG_stress_compaction = false; CcTest::InitializeVM(); - Isolate* isolate = Isolate::Current(); + Isolate* isolate = CcTest::i_isolate(); Heap* heap = isolate->heap(); Factory* factory = isolate->factory(); GlobalHandles* global_handles = isolate->global_handles(); @@ -449,7 +445,7 @@ TEST(WeakGlobalHandlesScavenge) { TEST(WeakGlobalHandlesMark) { CcTest::InitializeVM(); - Isolate* isolate = Isolate::Current(); + Isolate* isolate = CcTest::i_isolate(); Heap* heap = isolate->heap(); Factory* factory = isolate->factory(); GlobalHandles* global_handles = isolate->global_handles(); @@ -495,7 +491,7 @@ TEST(WeakGlobalHandlesMark) { TEST(DeleteWeakGlobalHandle) { i::FLAG_stress_compaction = false; CcTest::InitializeVM(); - Isolate* isolate = Isolate::Current(); + Isolate* isolate = CcTest::i_isolate(); Heap* heap = isolate->heap(); Factory* factory = isolate->factory(); GlobalHandles* global_handles = isolate->global_handles(); @@ -594,12 +590,12 @@ static const char* not_so_random_string_table[] = { static void CheckInternalizedStrings(const char** strings) { for (const char* string = *strings; *strings != 0; string = *strings++) { Object* a; - MaybeObject* maybe_a = HEAP->InternalizeUtf8String(string); + MaybeObject* maybe_a = CcTest::heap()->InternalizeUtf8String(string); // InternalizeUtf8String may return a failure if a GC is needed. if (!maybe_a->ToObject(&a)) continue; CHECK(a->IsInternalizedString()); Object* b; - MaybeObject* maybe_b = HEAP->InternalizeUtf8String(string); + MaybeObject* maybe_b = CcTest::heap()->InternalizeUtf8String(string); if (!maybe_b->ToObject(&b)) continue; CHECK_EQ(b, a); CHECK(String::cast(b)->IsUtf8EqualTo(CStrVector(string))); @@ -617,7 +613,7 @@ TEST(StringTable) { TEST(FunctionAllocation) { CcTest::InitializeVM(); - Isolate* isolate = Isolate::Current(); + Isolate* isolate = CcTest::i_isolate(); Factory* factory = isolate->factory(); v8::HandleScope sc(CcTest::isolate()); @@ -628,26 +624,28 @@ TEST(FunctionAllocation) { factory->NewMap(JS_OBJECT_TYPE, JSObject::kHeaderSize); function->set_initial_map(*initial_map); + Handle<Smi> twenty_three(Smi::FromInt(23), isolate); + Handle<Smi> twenty_four(Smi::FromInt(24), isolate); + Handle<String> prop_name = factory->InternalizeUtf8String("theSlot"); Handle<JSObject> obj = factory->NewJSObject(function); - obj->SetProperty( - *prop_name, Smi::FromInt(23), NONE, kNonStrictMode)->ToObjectChecked(); + JSReceiver::SetProperty(obj, prop_name, twenty_three, NONE, kNonStrictMode); CHECK_EQ(Smi::FromInt(23), obj->GetProperty(*prop_name)); // Check that we can add properties to function objects. - function->SetProperty( - *prop_name, Smi::FromInt(24), NONE, kNonStrictMode)->ToObjectChecked(); + JSReceiver::SetProperty(function, prop_name, twenty_four, NONE, + kNonStrictMode); CHECK_EQ(Smi::FromInt(24), function->GetProperty(*prop_name)); } TEST(ObjectProperties) { CcTest::InitializeVM(); - Isolate* isolate = Isolate::Current(); + Isolate* isolate = CcTest::i_isolate(); Factory* factory = isolate->factory(); v8::HandleScope sc(CcTest::isolate()); - String* object_string = String::cast(HEAP->Object_string()); - Object* raw_object = Isolate::Current()->context()->global_object()-> + String* object_string = String::cast(CcTest::heap()->Object_string()); + Object* raw_object = CcTest::i_isolate()->context()->global_object()-> GetProperty(object_string)->ToObjectChecked(); JSFunction* object_function = JSFunction::cast(raw_object); Handle<JSFunction> constructor(object_function); @@ -655,69 +653,65 @@ TEST(ObjectProperties) { Handle<String> first = factory->InternalizeUtf8String("first"); Handle<String> second = factory->InternalizeUtf8String("second"); + Handle<Smi> one(Smi::FromInt(1), isolate); + Handle<Smi> two(Smi::FromInt(2), isolate); + // check for empty - CHECK(!obj->HasLocalProperty(*first)); + CHECK(!JSReceiver::HasLocalProperty(obj, first)); // add first - obj->SetProperty( - *first, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked(); - CHECK(obj->HasLocalProperty(*first)); + JSReceiver::SetProperty(obj, first, one, NONE, kNonStrictMode); + CHECK(JSReceiver::HasLocalProperty(obj, first)); // delete first JSReceiver::DeleteProperty(obj, first, JSReceiver::NORMAL_DELETION); - CHECK(!obj->HasLocalProperty(*first)); + CHECK(!JSReceiver::HasLocalProperty(obj, first)); // add first and then second - obj->SetProperty( - *first, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked(); - obj->SetProperty( - *second, Smi::FromInt(2), NONE, kNonStrictMode)->ToObjectChecked(); - CHECK(obj->HasLocalProperty(*first)); - CHECK(obj->HasLocalProperty(*second)); + JSReceiver::SetProperty(obj, first, one, NONE, kNonStrictMode); + JSReceiver::SetProperty(obj, second, two, NONE, kNonStrictMode); + CHECK(JSReceiver::HasLocalProperty(obj, first)); + CHECK(JSReceiver::HasLocalProperty(obj, second)); // delete first and then second JSReceiver::DeleteProperty(obj, first, JSReceiver::NORMAL_DELETION); - CHECK(obj->HasLocalProperty(*second)); + CHECK(JSReceiver::HasLocalProperty(obj, second)); JSReceiver::DeleteProperty(obj, second, JSReceiver::NORMAL_DELETION); - CHECK(!obj->HasLocalProperty(*first)); - CHECK(!obj->HasLocalProperty(*second)); + CHECK(!JSReceiver::HasLocalProperty(obj, first)); + CHECK(!JSReceiver::HasLocalProperty(obj, second)); // add first and then second - obj->SetProperty( - *first, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked(); - obj->SetProperty( - *second, Smi::FromInt(2), NONE, kNonStrictMode)->ToObjectChecked(); - CHECK(obj->HasLocalProperty(*first)); - CHECK(obj->HasLocalProperty(*second)); + JSReceiver::SetProperty(obj, first, one, NONE, kNonStrictMode); + JSReceiver::SetProperty(obj, second, two, NONE, kNonStrictMode); + CHECK(JSReceiver::HasLocalProperty(obj, first)); + CHECK(JSReceiver::HasLocalProperty(obj, second)); // delete second and then first JSReceiver::DeleteProperty(obj, second, JSReceiver::NORMAL_DELETION); - CHECK(obj->HasLocalProperty(*first)); + CHECK(JSReceiver::HasLocalProperty(obj, first)); JSReceiver::DeleteProperty(obj, first, JSReceiver::NORMAL_DELETION); - CHECK(!obj->HasLocalProperty(*first)); - CHECK(!obj->HasLocalProperty(*second)); + CHECK(!JSReceiver::HasLocalProperty(obj, first)); + CHECK(!JSReceiver::HasLocalProperty(obj, second)); // check string and internalized string match const char* string1 = "fisk"; Handle<String> s1 = factory->NewStringFromAscii(CStrVector(string1)); - obj->SetProperty( - *s1, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked(); + JSReceiver::SetProperty(obj, s1, one, NONE, kNonStrictMode); Handle<String> s1_string = factory->InternalizeUtf8String(string1); - CHECK(obj->HasLocalProperty(*s1_string)); + CHECK(JSReceiver::HasLocalProperty(obj, s1_string)); // check internalized string and string match const char* string2 = "fugl"; Handle<String> s2_string = factory->InternalizeUtf8String(string2); - obj->SetProperty( - *s2_string, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked(); + JSReceiver::SetProperty(obj, s2_string, one, NONE, kNonStrictMode); Handle<String> s2 = factory->NewStringFromAscii(CStrVector(string2)); - CHECK(obj->HasLocalProperty(*s2)); + CHECK(JSReceiver::HasLocalProperty(obj, s2)); } TEST(JSObjectMaps) { CcTest::InitializeVM(); - Isolate* isolate = Isolate::Current(); + Isolate* isolate = CcTest::i_isolate(); Factory* factory = isolate->factory(); v8::HandleScope sc(CcTest::isolate()); @@ -732,8 +726,8 @@ TEST(JSObjectMaps) { Handle<JSObject> obj = factory->NewJSObject(function); // Set a propery - obj->SetProperty( - *prop_name, Smi::FromInt(23), NONE, kNonStrictMode)->ToObjectChecked(); + Handle<Smi> twenty_three(Smi::FromInt(23), isolate); + JSReceiver::SetProperty(obj, prop_name, twenty_three, NONE, kNonStrictMode); CHECK_EQ(Smi::FromInt(23), obj->GetProperty(*prop_name)); // Check the map has changed @@ -743,12 +737,12 @@ TEST(JSObjectMaps) { TEST(JSArray) { CcTest::InitializeVM(); - Isolate* isolate = Isolate::Current(); + Isolate* isolate = CcTest::i_isolate(); Factory* factory = isolate->factory(); v8::HandleScope sc(CcTest::isolate()); Handle<String> name = factory->InternalizeUtf8String("Array"); - Object* raw_object = Isolate::Current()->context()->global_object()-> + Object* raw_object = CcTest::i_isolate()->context()->global_object()-> GetProperty(*name)->ToObjectChecked(); Handle<JSFunction> function = Handle<JSFunction>( JSFunction::cast(raw_object)); @@ -792,12 +786,12 @@ TEST(JSArray) { TEST(JSObjectCopy) { CcTest::InitializeVM(); - Isolate* isolate = Isolate::Current(); + Isolate* isolate = CcTest::i_isolate(); Factory* factory = isolate->factory(); v8::HandleScope sc(CcTest::isolate()); - String* object_string = String::cast(HEAP->Object_string()); - Object* raw_object = Isolate::Current()->context()->global_object()-> + String* object_string = String::cast(CcTest::heap()->Object_string()); + Object* raw_object = CcTest::i_isolate()->context()->global_object()-> GetProperty(object_string)->ToObjectChecked(); JSFunction* object_function = JSFunction::cast(raw_object); Handle<JSFunction> constructor(object_function); @@ -805,16 +799,17 @@ TEST(JSObjectCopy) { Handle<String> first = factory->InternalizeUtf8String("first"); Handle<String> second = factory->InternalizeUtf8String("second"); - obj->SetProperty( - *first, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked(); - obj->SetProperty( - *second, Smi::FromInt(2), NONE, kNonStrictMode)->ToObjectChecked(); + Handle<Smi> one(Smi::FromInt(1), isolate); + Handle<Smi> two(Smi::FromInt(2), isolate); + + JSReceiver::SetProperty(obj, first, one, NONE, kNonStrictMode); + JSReceiver::SetProperty(obj, second, two, NONE, kNonStrictMode); obj->SetElement(0, *first, NONE, kNonStrictMode)->ToObjectChecked(); obj->SetElement(1, *second, NONE, kNonStrictMode)->ToObjectChecked(); // Make the clone. - Handle<JSObject> clone = Copy(obj); + Handle<JSObject> clone = JSObject::Copy(obj); CHECK(!clone.is_identical_to(obj)); CHECK_EQ(obj->GetElement(isolate, 0), clone->GetElement(isolate, 0)); @@ -824,10 +819,8 @@ TEST(JSObjectCopy) { CHECK_EQ(obj->GetProperty(*second), clone->GetProperty(*second)); // Flip the values. - clone->SetProperty( - *first, Smi::FromInt(2), NONE, kNonStrictMode)->ToObjectChecked(); - clone->SetProperty( - *second, Smi::FromInt(1), NONE, kNonStrictMode)->ToObjectChecked(); + JSReceiver::SetProperty(clone, first, two, NONE, kNonStrictMode); + JSReceiver::SetProperty(clone, second, one, NONE, kNonStrictMode); clone->SetElement(0, *second, NONE, kNonStrictMode)->ToObjectChecked(); clone->SetElement(1, *first, NONE, kNonStrictMode)->ToObjectChecked(); @@ -842,7 +835,7 @@ TEST(JSObjectCopy) { TEST(StringAllocation) { CcTest::InitializeVM(); - Isolate* isolate = Isolate::Current(); + Isolate* isolate = CcTest::i_isolate(); Factory* factory = isolate->factory(); const unsigned char chars[] = { 0xe5, 0xa4, 0xa7 }; @@ -897,7 +890,7 @@ static int ObjectsFoundInHeap(Heap* heap, Handle<Object> objs[], int size) { TEST(Iteration) { CcTest::InitializeVM(); - Isolate* isolate = Isolate::Current(); + Isolate* isolate = CcTest::i_isolate(); Factory* factory = isolate->factory(); v8::HandleScope scope(CcTest::isolate()); @@ -931,7 +924,7 @@ TEST(Iteration) { objs[next_objs_index++] = Handle<Map>(HeapObject::cast(*objs[0])->map()); CHECK_EQ(objs_count, next_objs_index); - CHECK_EQ(objs_count, ObjectsFoundInHeap(HEAP, objs, objs_count)); + CHECK_EQ(objs_count, ObjectsFoundInHeap(CcTest::heap(), objs, objs_count)); } @@ -959,11 +952,12 @@ static int LenFromSize(int size) { TEST(Regression39128) { // Test case for crbug.com/39128. CcTest::InitializeVM(); - Isolate* isolate = Isolate::Current(); + Isolate* isolate = CcTest::i_isolate(); Factory* factory = isolate->factory(); + Heap* heap = isolate->heap(); // Increase the chance of 'bump-the-pointer' allocation in old space. - HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); + heap->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); v8::HandleScope scope(CcTest::isolate()); @@ -973,7 +967,7 @@ TEST(Regression39128) { // Step 1: prepare a map for the object. We add 1 inobject property to it. Handle<JSFunction> object_ctor( - Isolate::Current()->native_context()->object_function()); + CcTest::i_isolate()->native_context()->object_function()); CHECK(object_ctor->has_initial_map()); Handle<Map> object_map(object_ctor->initial_map()); // Create a map with single inobject property. @@ -989,12 +983,12 @@ TEST(Regression39128) { int allocation_amount = Min(FixedArray::kMaxSize, Page::kMaxNonCodeHeapObjectSize + kPointerSize); int allocation_len = LenFromSize(allocation_amount); - NewSpace* new_space = HEAP->new_space(); + NewSpace* new_space = heap->new_space(); Address* top_addr = new_space->allocation_top_address(); Address* limit_addr = new_space->allocation_limit_address(); while ((*limit_addr - *top_addr) > allocation_amount) { - CHECK(!HEAP->always_allocate()); - Object* array = HEAP->AllocateFixedArray(allocation_len)->ToObjectChecked(); + CHECK(!heap->always_allocate()); + Object* array = heap->AllocateFixedArray(allocation_len)->ToObjectChecked(); CHECK(!array->IsFailure()); CHECK(new_space->Contains(array)); } @@ -1004,12 +998,12 @@ TEST(Regression39128) { int fixed_array_len = LenFromSize(to_fill); CHECK(fixed_array_len < FixedArray::kMaxLength); - CHECK(!HEAP->always_allocate()); - Object* array = HEAP->AllocateFixedArray(fixed_array_len)->ToObjectChecked(); + CHECK(!heap->always_allocate()); + Object* array = heap->AllocateFixedArray(fixed_array_len)->ToObjectChecked(); CHECK(!array->IsFailure()); CHECK(new_space->Contains(array)); - Object* object = HEAP->AllocateJSObjectFromMap(*my_map)->ToObjectChecked(); + Object* object = heap->AllocateJSObjectFromMap(*my_map)->ToObjectChecked(); CHECK(new_space->Contains(object)); JSObject* jsobject = JSObject::cast(object); CHECK_EQ(0, FixedArray::cast(jsobject->elements())->length()); @@ -1021,15 +1015,15 @@ TEST(Regression39128) { // Step 4: clone jsobject, but force always allocate first to create a clone // in old pointer space. - Address old_pointer_space_top = HEAP->old_pointer_space()->top(); + Address old_pointer_space_top = heap->old_pointer_space()->top(); AlwaysAllocateScope aa_scope; - Object* clone_obj = HEAP->CopyJSObject(jsobject)->ToObjectChecked(); + Object* clone_obj = heap->CopyJSObject(jsobject)->ToObjectChecked(); JSObject* clone = JSObject::cast(clone_obj); if (clone->address() != old_pointer_space_top) { // Alas, got allocated from free list, we cannot do checks. return; } - CHECK(HEAP->old_pointer_space()->Contains(clone->address())); + CHECK(heap->old_pointer_space()->Contains(clone->address())); } @@ -1037,8 +1031,9 @@ TEST(TestCodeFlushing) { // If we do not flush code this test is invalid. if (!FLAG_flush_code) return; i::FLAG_allow_natives_syntax = true; + i::FLAG_optimize_for_size = false; CcTest::InitializeVM(); - Isolate* isolate = Isolate::Current(); + Isolate* isolate = CcTest::i_isolate(); Factory* factory = isolate->factory(); v8::HandleScope scope(CcTest::isolate()); const char* source = "function foo() {" @@ -1055,21 +1050,86 @@ TEST(TestCodeFlushing) { } // Check function is compiled. - Object* func_value = Isolate::Current()->context()->global_object()-> + Object* func_value = CcTest::i_isolate()->context()->global_object()-> GetProperty(*foo_name)->ToObjectChecked(); CHECK(func_value->IsJSFunction()); Handle<JSFunction> function(JSFunction::cast(func_value)); CHECK(function->shared()->is_compiled()); // The code will survive at least two GCs. - HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); - HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); + CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); + CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); + CHECK(function->shared()->is_compiled()); + + // Simulate several GCs that use full marking. + const int kAgingThreshold = 6; + for (int i = 0; i < kAgingThreshold; i++) { + CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); + } + + // foo should no longer be in the compilation cache + CHECK(!function->shared()->is_compiled() || function->IsOptimized()); + CHECK(!function->is_compiled() || function->IsOptimized()); + // Call foo to get it recompiled. + CompileRun("foo()"); + CHECK(function->shared()->is_compiled()); + CHECK(function->is_compiled()); +} + + +TEST(TestCodeFlushingPreAged) { + // If we do not flush code this test is invalid. + if (!FLAG_flush_code) return; + i::FLAG_allow_natives_syntax = true; + i::FLAG_optimize_for_size = true; + CcTest::InitializeVM(); + Isolate* isolate = Isolate::Current(); + Factory* factory = isolate->factory(); + v8::HandleScope scope(CcTest::isolate()); + const char* source = "function foo() {" + " var x = 42;" + " var y = 42;" + " var z = x + y;" + "};" + "foo()"; + Handle<String> foo_name = factory->InternalizeUtf8String("foo"); + + // Compile foo, but don't run it. + { v8::HandleScope scope(CcTest::isolate()); + CompileRun(source); + } + + // Check function is compiled. + Object* func_value = Isolate::Current()->context()->global_object()-> + GetProperty(*foo_name)->ToObjectChecked(); + CHECK(func_value->IsJSFunction()); + Handle<JSFunction> function(JSFunction::cast(func_value)); + CHECK(function->shared()->is_compiled()); + + // The code has been run so will survive at least one GC. + CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); + CHECK(function->shared()->is_compiled()); + + // The code was only run once, so it should be pre-aged and collected on the + // next GC. + CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); + CHECK(!function->shared()->is_compiled() || function->IsOptimized()); + + // Execute the function again twice, and ensure it is reset to the young age. + { v8::HandleScope scope(CcTest::isolate()); + CompileRun("foo();" + "foo();"); + } + + // The code will survive at least two GC now that it is young again. + CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); + CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); CHECK(function->shared()->is_compiled()); // Simulate several GCs that use full marking. const int kAgingThreshold = 6; for (int i = 0; i < kAgingThreshold; i++) { - HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); + CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); } // foo should no longer be in the compilation cache @@ -1086,8 +1146,9 @@ TEST(TestCodeFlushingIncremental) { // If we do not flush code this test is invalid. if (!FLAG_flush_code || !FLAG_flush_code_incrementally) return; i::FLAG_allow_natives_syntax = true; + i::FLAG_optimize_for_size = false; CcTest::InitializeVM(); - Isolate* isolate = Isolate::Current(); + Isolate* isolate = CcTest::i_isolate(); Factory* factory = isolate->factory(); v8::HandleScope scope(CcTest::isolate()); const char* source = "function foo() {" @@ -1104,22 +1165,22 @@ TEST(TestCodeFlushingIncremental) { } // Check function is compiled. - Object* func_value = Isolate::Current()->context()->global_object()-> + Object* func_value = CcTest::i_isolate()->context()->global_object()-> GetProperty(*foo_name)->ToObjectChecked(); CHECK(func_value->IsJSFunction()); Handle<JSFunction> function(JSFunction::cast(func_value)); CHECK(function->shared()->is_compiled()); // The code will survive at least two GCs. - HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); - HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); + CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); + CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); CHECK(function->shared()->is_compiled()); // Simulate several GCs that use incremental marking. const int kAgingThreshold = 6; for (int i = 0; i < kAgingThreshold; i++) { SimulateIncrementalMarking(); - HEAP->CollectAllGarbage(Heap::kNoGCFlags); + CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); } CHECK(!function->shared()->is_compiled() || function->IsOptimized()); CHECK(!function->is_compiled() || function->IsOptimized()); @@ -1134,7 +1195,7 @@ TEST(TestCodeFlushingIncremental) { for (int i = 0; i < kAgingThreshold; i++) { SimulateIncrementalMarking(); if (!function->next_function_link()->IsUndefined()) break; - HEAP->CollectAllGarbage(Heap::kNoGCFlags); + CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); } // Force optimization while incremental marking is active and while @@ -1144,7 +1205,7 @@ TEST(TestCodeFlushingIncremental) { } // Simulate one final GC to make sure the candidate queue is sane. - HEAP->CollectAllGarbage(Heap::kNoGCFlags); + CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); CHECK(function->shared()->is_compiled() || !function->IsOptimized()); CHECK(function->is_compiled() || !function->IsOptimized()); } @@ -1154,8 +1215,9 @@ TEST(TestCodeFlushingIncrementalScavenge) { // If we do not flush code this test is invalid. if (!FLAG_flush_code || !FLAG_flush_code_incrementally) return; i::FLAG_allow_natives_syntax = true; + i::FLAG_optimize_for_size = false; CcTest::InitializeVM(); - Isolate* isolate = Isolate::Current(); + Isolate* isolate = CcTest::i_isolate(); Factory* factory = isolate->factory(); v8::HandleScope scope(CcTest::isolate()); const char* source = "var foo = function() {" @@ -1172,7 +1234,7 @@ TEST(TestCodeFlushingIncrementalScavenge) { Handle<String> bar_name = factory->InternalizeUtf8String("bar"); // Perfrom one initial GC to enable code flushing. - HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); + CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); // This compile will add the code to the compilation cache. { v8::HandleScope scope(CcTest::isolate()); @@ -1180,12 +1242,12 @@ TEST(TestCodeFlushingIncrementalScavenge) { } // Check functions are compiled. - Object* func_value = Isolate::Current()->context()->global_object()-> + Object* func_value = CcTest::i_isolate()->context()->global_object()-> GetProperty(*foo_name)->ToObjectChecked(); CHECK(func_value->IsJSFunction()); Handle<JSFunction> function(JSFunction::cast(func_value)); CHECK(function->shared()->is_compiled()); - Object* func_value2 = Isolate::Current()->context()->global_object()-> + Object* func_value2 = CcTest::i_isolate()->context()->global_object()-> GetProperty(*bar_name)->ToObjectChecked(); CHECK(func_value2->IsJSFunction()); Handle<JSFunction> function2(JSFunction::cast(func_value2)); @@ -1209,10 +1271,10 @@ TEST(TestCodeFlushingIncrementalScavenge) { // perform a scavenge while incremental marking is still running. SimulateIncrementalMarking(); *function2.location() = NULL; - HEAP->CollectGarbage(NEW_SPACE, "test scavenge while marking"); + CcTest::heap()->CollectGarbage(NEW_SPACE, "test scavenge while marking"); // Simulate one final GC to make sure the candidate queue is sane. - HEAP->CollectAllGarbage(Heap::kNoGCFlags); + CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); CHECK(!function->shared()->is_compiled() || function->IsOptimized()); CHECK(!function->is_compiled() || function->IsOptimized()); } @@ -1222,8 +1284,9 @@ TEST(TestCodeFlushingIncrementalAbort) { // If we do not flush code this test is invalid. if (!FLAG_flush_code || !FLAG_flush_code_incrementally) return; i::FLAG_allow_natives_syntax = true; + i::FLAG_optimize_for_size = false; CcTest::InitializeVM(); - Isolate* isolate = Isolate::Current(); + Isolate* isolate = CcTest::i_isolate(); Factory* factory = isolate->factory(); Heap* heap = isolate->heap(); v8::HandleScope scope(CcTest::isolate()); @@ -1241,7 +1304,7 @@ TEST(TestCodeFlushingIncrementalAbort) { } // Check function is compiled. - Object* func_value = Isolate::Current()->context()->global_object()-> + Object* func_value = CcTest::i_isolate()->context()->global_object()-> GetProperty(*foo_name)->ToObjectChecked(); CHECK(func_value->IsJSFunction()); Handle<JSFunction> function(JSFunction::cast(func_value)); @@ -1287,7 +1350,7 @@ TEST(TestCodeFlushingIncrementalAbort) { // Count the number of native contexts in the weak list of native contexts. int CountNativeContexts() { int count = 0; - Object* object = HEAP->native_contexts_list(); + Object* object = CcTest::heap()->native_contexts_list(); while (!object->IsUndefined()) { count++; object = Context::cast(object)->get(Context::NEXT_CONTEXT_LINK); @@ -1319,7 +1382,7 @@ TEST(TestInternalWeakLists) { static const int kNumTestContexts = 10; - Isolate* isolate = Isolate::Current(); + Isolate* isolate = CcTest::i_isolate(); Heap* heap = isolate->heap(); HandleScope scope(isolate); v8::Handle<v8::Context> ctx[kNumTestContexts]; @@ -1328,7 +1391,7 @@ TEST(TestInternalWeakLists) { // Create a number of global contests which gets linked together. for (int i = 0; i < kNumTestContexts; i++) { - ctx[i] = v8::Context::New(v8::Isolate::GetCurrent()); + ctx[i] = v8::Context::New(CcTest::isolate()); // Collect garbage that might have been created by one of the // installed extensions. @@ -1367,7 +1430,7 @@ TEST(TestInternalWeakLists) { // Scavenge treats these references as strong. for (int j = 0; j < 10; j++) { - HEAP->PerformScavenge(); + CcTest::heap()->PerformScavenge(); CHECK_EQ(opt ? 5 : 0, CountOptimizedUserFunctions(ctx[i])); } @@ -1379,41 +1442,41 @@ TEST(TestInternalWeakLists) { // Get rid of f3 and f5 in the same way. CompileRun("f3=null"); for (int j = 0; j < 10; j++) { - HEAP->PerformScavenge(); + CcTest::heap()->PerformScavenge(); CHECK_EQ(opt ? 4 : 0, CountOptimizedUserFunctions(ctx[i])); } - HEAP->CollectAllGarbage(Heap::kNoGCFlags); + CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); CHECK_EQ(opt ? 3 : 0, CountOptimizedUserFunctions(ctx[i])); CompileRun("f5=null"); for (int j = 0; j < 10; j++) { - HEAP->PerformScavenge(); + CcTest::heap()->PerformScavenge(); CHECK_EQ(opt ? 3 : 0, CountOptimizedUserFunctions(ctx[i])); } - HEAP->CollectAllGarbage(Heap::kNoGCFlags); + CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); CHECK_EQ(opt ? 2 : 0, CountOptimizedUserFunctions(ctx[i])); ctx[i]->Exit(); } // Force compilation cache cleanup. - HEAP->NotifyContextDisposed(); - HEAP->CollectAllGarbage(Heap::kNoGCFlags); + CcTest::heap()->NotifyContextDisposed(); + CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); // Dispose the native contexts one by one. for (int i = 0; i < kNumTestContexts; i++) { // TODO(dcarney): is there a better way to do this? i::Object** unsafe = reinterpret_cast<i::Object**>(*ctx[i]); - *unsafe = HEAP->undefined_value(); + *unsafe = CcTest::heap()->undefined_value(); ctx[i].Clear(); // Scavenge treats these references as strong. for (int j = 0; j < 10; j++) { - HEAP->PerformScavenge(); + CcTest::heap()->PerformScavenge(); CHECK_EQ(kNumTestContexts - i, CountNativeContexts()); } // Mark compact handles the weak references. - HEAP->CollectAllGarbage(Heap::kNoGCFlags); + CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); CHECK_EQ(kNumTestContexts - i - 1, CountNativeContexts()); } @@ -1462,7 +1525,7 @@ static int CountOptimizedUserFunctionsWithGC(v8::Handle<v8::Context> context, TEST(TestInternalWeakListsTraverseWithGC) { v8::V8::Initialize(); - Isolate* isolate = Isolate::Current(); + Isolate* isolate = CcTest::i_isolate(); static const int kNumTestContexts = 10; @@ -1474,7 +1537,7 @@ TEST(TestInternalWeakListsTraverseWithGC) { // Create an number of contexts and check the length of the weak list both // with and without GCs while iterating the list. for (int i = 0; i < kNumTestContexts; i++) { - ctx[i] = v8::Context::New(v8::Isolate::GetCurrent()); + ctx[i] = v8::Context::New(CcTest::isolate()); CHECK_EQ(i + 1, CountNativeContexts()); CHECK_EQ(i + 1, CountNativeContextsWithGC(isolate, i / 2 + 1)); } @@ -1516,13 +1579,13 @@ TEST(TestSizeOfObjects) { // Get initial heap size after several full GCs, which will stabilize // the heap size and return with sweeping finished completely. - HEAP->CollectAllGarbage(Heap::kNoGCFlags); - HEAP->CollectAllGarbage(Heap::kNoGCFlags); - HEAP->CollectAllGarbage(Heap::kNoGCFlags); - HEAP->CollectAllGarbage(Heap::kNoGCFlags); - HEAP->CollectAllGarbage(Heap::kNoGCFlags); - CHECK(HEAP->old_pointer_space()->IsLazySweepingComplete()); - int initial_size = static_cast<int>(HEAP->SizeOfObjects()); + CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); + CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); + CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); + CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); + CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); + CHECK(CcTest::heap()->old_pointer_space()->IsLazySweepingComplete()); + int initial_size = static_cast<int>(CcTest::heap()->SizeOfObjects()); { // Allocate objects on several different old-space pages so that @@ -1530,33 +1593,33 @@ TEST(TestSizeOfObjects) { AlwaysAllocateScope always_allocate; int filler_size = static_cast<int>(FixedArray::SizeFor(8192)); for (int i = 1; i <= 100; i++) { - HEAP->AllocateFixedArray(8192, TENURED)->ToObjectChecked(); + CcTest::heap()->AllocateFixedArray(8192, TENURED)->ToObjectChecked(); CHECK_EQ(initial_size + i * filler_size, - static_cast<int>(HEAP->SizeOfObjects())); + static_cast<int>(CcTest::heap()->SizeOfObjects())); } } // The heap size should go back to initial size after a full GC, even // though sweeping didn't finish yet. - HEAP->CollectAllGarbage(Heap::kNoGCFlags); + CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); // Normally sweeping would not be complete here, but no guarantees. - CHECK_EQ(initial_size, static_cast<int>(HEAP->SizeOfObjects())); + CHECK_EQ(initial_size, static_cast<int>(CcTest::heap()->SizeOfObjects())); // Advancing the sweeper step-wise should not change the heap size. - while (!HEAP->old_pointer_space()->IsLazySweepingComplete()) { - HEAP->old_pointer_space()->AdvanceSweeper(KB); - CHECK_EQ(initial_size, static_cast<int>(HEAP->SizeOfObjects())); + while (!CcTest::heap()->old_pointer_space()->IsLazySweepingComplete()) { + CcTest::heap()->old_pointer_space()->AdvanceSweeper(KB); + CHECK_EQ(initial_size, static_cast<int>(CcTest::heap()->SizeOfObjects())); } } TEST(TestSizeOfObjectsVsHeapIteratorPrecision) { CcTest::InitializeVM(); - HEAP->EnsureHeapIsIterable(); - intptr_t size_of_objects_1 = HEAP->SizeOfObjects(); - HeapIterator iterator(HEAP); + CcTest::heap()->EnsureHeapIsIterable(); + intptr_t size_of_objects_1 = CcTest::heap()->SizeOfObjects(); + HeapIterator iterator(CcTest::heap()); intptr_t size_of_objects_2 = 0; for (HeapObject* obj = iterator.next(); obj != NULL; @@ -1605,10 +1668,11 @@ static void FillUpNewSpace(NewSpace* new_space) { TEST(GrowAndShrinkNewSpace) { CcTest::InitializeVM(); - NewSpace* new_space = HEAP->new_space(); + Heap* heap = CcTest::heap(); + NewSpace* new_space = heap->new_space(); - if (HEAP->ReservedSemiSpaceSize() == HEAP->InitialSemiSpaceSize() || - HEAP->MaxSemiSpaceSize() == HEAP->InitialSemiSpaceSize()) { + if (heap->ReservedSemiSpaceSize() == heap->InitialSemiSpaceSize() || + heap->MaxSemiSpaceSize() == heap->InitialSemiSpaceSize()) { // The max size cannot exceed the reserved size, since semispaces must be // always within the reserved space. We can't test new space growing and // shrinking if the reserved size is the same as the minimum (initial) size. @@ -1634,7 +1698,7 @@ TEST(GrowAndShrinkNewSpace) { CHECK(old_capacity == new_capacity); // Let the scavenger empty the new space. - HEAP->CollectGarbage(NEW_SPACE); + heap->CollectGarbage(NEW_SPACE); CHECK_LE(new_space->Size(), old_capacity); // Explicitly shrinking should halve the space capacity. @@ -1655,9 +1719,9 @@ TEST(GrowAndShrinkNewSpace) { TEST(CollectingAllAvailableGarbageShrinksNewSpace) { CcTest::InitializeVM(); - - if (HEAP->ReservedSemiSpaceSize() == HEAP->InitialSemiSpaceSize() || - HEAP->MaxSemiSpaceSize() == HEAP->InitialSemiSpaceSize()) { + Heap* heap = CcTest::heap(); + if (heap->ReservedSemiSpaceSize() == heap->InitialSemiSpaceSize() || + heap->MaxSemiSpaceSize() == heap->InitialSemiSpaceSize()) { // The max size cannot exceed the reserved size, since semispaces must be // always within the reserved space. We can't test new space growing and // shrinking if the reserved size is the same as the minimum (initial) size. @@ -1665,14 +1729,14 @@ TEST(CollectingAllAvailableGarbageShrinksNewSpace) { } v8::HandleScope scope(CcTest::isolate()); - NewSpace* new_space = HEAP->new_space(); + NewSpace* new_space = heap->new_space(); intptr_t old_capacity, new_capacity; old_capacity = new_space->Capacity(); new_space->Grow(); new_capacity = new_space->Capacity(); CHECK(2 * old_capacity == new_capacity); FillUpNewSpace(new_space); - HEAP->CollectAllAvailableGarbage(); + heap->CollectAllAvailableGarbage(); new_capacity = new_space->Capacity(); CHECK(old_capacity == new_capacity); } @@ -1680,7 +1744,7 @@ TEST(CollectingAllAvailableGarbageShrinksNewSpace) { static int NumberOfGlobalObjects() { int count = 0; - HeapIterator iterator(HEAP); + HeapIterator iterator(CcTest::heap()); for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) { if (obj->IsGlobalObject()) count++; } @@ -1692,7 +1756,7 @@ static int NumberOfGlobalObjects() { // optimized code. TEST(LeakNativeContextViaMap) { i::FLAG_allow_natives_syntax = true; - v8::Isolate* isolate = v8::Isolate::GetCurrent(); + v8::Isolate* isolate = CcTest::isolate(); v8::HandleScope outer_scope(isolate); v8::Persistent<v8::Context> ctx1p; v8::Persistent<v8::Context> ctx2p; @@ -1703,7 +1767,7 @@ TEST(LeakNativeContextViaMap) { v8::Local<v8::Context>::New(isolate, ctx1p)->Enter(); } - HEAP->CollectAllAvailableGarbage(); + CcTest::heap()->CollectAllAvailableGarbage(); CHECK_EQ(4, NumberOfGlobalObjects()); { @@ -1726,10 +1790,10 @@ TEST(LeakNativeContextViaMap) { ctx1p.Dispose(); v8::V8::ContextDisposedNotification(); } - HEAP->CollectAllAvailableGarbage(); + CcTest::heap()->CollectAllAvailableGarbage(); CHECK_EQ(2, NumberOfGlobalObjects()); ctx2p.Dispose(); - HEAP->CollectAllAvailableGarbage(); + CcTest::heap()->CollectAllAvailableGarbage(); CHECK_EQ(0, NumberOfGlobalObjects()); } @@ -1738,7 +1802,7 @@ TEST(LeakNativeContextViaMap) { // optimized code. TEST(LeakNativeContextViaFunction) { i::FLAG_allow_natives_syntax = true; - v8::Isolate* isolate = v8::Isolate::GetCurrent(); + v8::Isolate* isolate = CcTest::isolate(); v8::HandleScope outer_scope(isolate); v8::Persistent<v8::Context> ctx1p; v8::Persistent<v8::Context> ctx2p; @@ -1749,7 +1813,7 @@ TEST(LeakNativeContextViaFunction) { v8::Local<v8::Context>::New(isolate, ctx1p)->Enter(); } - HEAP->CollectAllAvailableGarbage(); + CcTest::heap()->CollectAllAvailableGarbage(); CHECK_EQ(4, NumberOfGlobalObjects()); { @@ -1772,17 +1836,17 @@ TEST(LeakNativeContextViaFunction) { ctx1p.Dispose(); v8::V8::ContextDisposedNotification(); } - HEAP->CollectAllAvailableGarbage(); + CcTest::heap()->CollectAllAvailableGarbage(); CHECK_EQ(2, NumberOfGlobalObjects()); ctx2p.Dispose(); - HEAP->CollectAllAvailableGarbage(); + CcTest::heap()->CollectAllAvailableGarbage(); CHECK_EQ(0, NumberOfGlobalObjects()); } TEST(LeakNativeContextViaMapKeyed) { i::FLAG_allow_natives_syntax = true; - v8::Isolate* isolate = v8::Isolate::GetCurrent(); + v8::Isolate* isolate = CcTest::isolate(); v8::HandleScope outer_scope(isolate); v8::Persistent<v8::Context> ctx1p; v8::Persistent<v8::Context> ctx2p; @@ -1793,7 +1857,7 @@ TEST(LeakNativeContextViaMapKeyed) { v8::Local<v8::Context>::New(isolate, ctx1p)->Enter(); } - HEAP->CollectAllAvailableGarbage(); + CcTest::heap()->CollectAllAvailableGarbage(); CHECK_EQ(4, NumberOfGlobalObjects()); { @@ -1816,17 +1880,17 @@ TEST(LeakNativeContextViaMapKeyed) { ctx1p.Dispose(); v8::V8::ContextDisposedNotification(); } - HEAP->CollectAllAvailableGarbage(); + CcTest::heap()->CollectAllAvailableGarbage(); CHECK_EQ(2, NumberOfGlobalObjects()); ctx2p.Dispose(); - HEAP->CollectAllAvailableGarbage(); + CcTest::heap()->CollectAllAvailableGarbage(); CHECK_EQ(0, NumberOfGlobalObjects()); } TEST(LeakNativeContextViaMapProto) { i::FLAG_allow_natives_syntax = true; - v8::Isolate* isolate = v8::Isolate::GetCurrent(); + v8::Isolate* isolate = CcTest::isolate(); v8::HandleScope outer_scope(isolate); v8::Persistent<v8::Context> ctx1p; v8::Persistent<v8::Context> ctx2p; @@ -1837,7 +1901,7 @@ TEST(LeakNativeContextViaMapProto) { v8::Local<v8::Context>::New(isolate, ctx1p)->Enter(); } - HEAP->CollectAllAvailableGarbage(); + CcTest::heap()->CollectAllAvailableGarbage(); CHECK_EQ(4, NumberOfGlobalObjects()); { @@ -1864,10 +1928,10 @@ TEST(LeakNativeContextViaMapProto) { ctx1p.Dispose(); v8::V8::ContextDisposedNotification(); } - HEAP->CollectAllAvailableGarbage(); + CcTest::heap()->CollectAllAvailableGarbage(); CHECK_EQ(2, NumberOfGlobalObjects()); ctx2p.Dispose(); - HEAP->CollectAllAvailableGarbage(); + CcTest::heap()->CollectAllAvailableGarbage(); CHECK_EQ(0, NumberOfGlobalObjects()); } @@ -1879,12 +1943,12 @@ TEST(InstanceOfStubWriteBarrier) { #endif CcTest::InitializeVM(); - if (!i::Isolate::Current()->use_crankshaft()) return; + if (!CcTest::i_isolate()->use_crankshaft()) return; if (i::FLAG_force_marking_deque_overflows) return; - v8::HandleScope outer_scope(v8::Isolate::GetCurrent()); + v8::HandleScope outer_scope(CcTest::isolate()); { - v8::HandleScope scope(v8::Isolate::GetCurrent()); + v8::HandleScope scope(CcTest::isolate()); CompileRun( "function foo () { }" "function mkbar () { return new (new Function(\"\")) (); }" @@ -1895,14 +1959,14 @@ TEST(InstanceOfStubWriteBarrier) { "f(new foo()); g();"); } - IncrementalMarking* marking = HEAP->incremental_marking(); + IncrementalMarking* marking = CcTest::heap()->incremental_marking(); marking->Abort(); marking->Start(); Handle<JSFunction> f = v8::Utils::OpenHandle( *v8::Handle<v8::Function>::Cast( - v8::Context::GetCurrent()->Global()->Get(v8_str("f")))); + CcTest::global()->Get(v8_str("f")))); CHECK(f->IsOptimized()); @@ -1916,21 +1980,21 @@ TEST(InstanceOfStubWriteBarrier) { CHECK(marking->IsMarking()); { - v8::HandleScope scope(v8::Isolate::GetCurrent()); - v8::Handle<v8::Object> global = v8::Context::GetCurrent()->Global(); + v8::HandleScope scope(CcTest::isolate()); + v8::Handle<v8::Object> global = CcTest::global(); v8::Handle<v8::Function> g = v8::Handle<v8::Function>::Cast(global->Get(v8_str("g"))); g->Call(global, 0, NULL); } - HEAP->incremental_marking()->set_should_hurry(true); - HEAP->CollectGarbage(OLD_POINTER_SPACE); + CcTest::heap()->incremental_marking()->set_should_hurry(true); + CcTest::heap()->CollectGarbage(OLD_POINTER_SPACE); } TEST(PrototypeTransitionClearing) { CcTest::InitializeVM(); - Isolate* isolate = Isolate::Current(); + Isolate* isolate = CcTest::i_isolate(); Factory* factory = isolate->factory(); v8::HandleScope scope(CcTest::isolate()); @@ -1947,11 +2011,11 @@ TEST(PrototypeTransitionClearing) { Handle<JSObject> baseObject = v8::Utils::OpenHandle( *v8::Handle<v8::Object>::Cast( - v8::Context::GetCurrent()->Global()->Get(v8_str("base")))); + CcTest::global()->Get(v8_str("base")))); // Verify that only dead prototype transitions are cleared. CHECK_EQ(10, baseObject->map()->NumberOfProtoTransitions()); - HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); + CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask); const int transitions = 10 - 3; CHECK_EQ(transitions, baseObject->map()->NumberOfProtoTransitions()); @@ -1967,7 +2031,7 @@ TEST(PrototypeTransitionClearing) { // Make sure next prototype is placed on an old-space evacuation candidate. Handle<JSObject> prototype; - PagedSpace* space = HEAP->old_pointer_space(); + PagedSpace* space = CcTest::heap()->old_pointer_space(); { AlwaysAllocateScope always_allocate; SimulateFullSpace(space); @@ -1983,7 +2047,7 @@ TEST(PrototypeTransitionClearing) { CHECK(space->LastPage()->Contains(prototype->address())); JSObject::SetPrototype(baseObject, prototype, false); CHECK(Map::GetPrototypeTransition(map, prototype)->IsMap()); - HEAP->CollectAllGarbage(Heap::kNoGCFlags); + CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); CHECK(Map::GetPrototypeTransition(map, prototype)->IsMap()); } @@ -1996,11 +2060,11 @@ TEST(ResetSharedFunctionInfoCountersDuringIncrementalMarking) { #endif CcTest::InitializeVM(); - if (!i::Isolate::Current()->use_crankshaft()) return; - v8::HandleScope outer_scope(v8::Isolate::GetCurrent()); + if (!CcTest::i_isolate()->use_crankshaft()) return; + v8::HandleScope outer_scope(CcTest::isolate()); { - v8::HandleScope scope(v8::Isolate::GetCurrent()); + v8::HandleScope scope(CcTest::isolate()); CompileRun( "function f () {" " var s = 0;" @@ -2014,14 +2078,14 @@ TEST(ResetSharedFunctionInfoCountersDuringIncrementalMarking) { Handle<JSFunction> f = v8::Utils::OpenHandle( *v8::Handle<v8::Function>::Cast( - v8::Context::GetCurrent()->Global()->Get(v8_str("f")))); + CcTest::global()->Get(v8_str("f")))); CHECK(f->IsOptimized()); - IncrementalMarking* marking = HEAP->incremental_marking(); + IncrementalMarking* marking = CcTest::heap()->incremental_marking(); marking->Abort(); marking->Start(); - // The following two calls will increment HEAP->global_ic_age(). + // The following two calls will increment CcTest::heap()->global_ic_age(). const int kLongIdlePauseInMs = 1000; v8::V8::ContextDisposedNotification(); v8::V8::IdleNotification(kLongIdlePauseInMs); @@ -2035,11 +2099,11 @@ TEST(ResetSharedFunctionInfoCountersDuringIncrementalMarking) { // guard interrupt. But here we didn't ask for that, and there is no // JS code running to trigger the interrupt, so we explicitly finalize // here. - HEAP->CollectAllGarbage(Heap::kNoGCFlags, + CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags, "Test finalizing incremental mark-sweep"); } - CHECK_EQ(HEAP->global_ic_age(), f->shared()->ic_age()); + CHECK_EQ(CcTest::heap()->global_ic_age(), f->shared()->ic_age()); CHECK_EQ(0, f->shared()->opt_count()); CHECK_EQ(0, f->shared()->code()->profiler_ticks()); } @@ -2053,7 +2117,7 @@ TEST(ResetSharedFunctionInfoCountersDuringMarkSweep) { #endif CcTest::InitializeVM(); - if (!i::Isolate::Current()->use_crankshaft()) return; + if (!CcTest::i_isolate()->use_crankshaft()) return; v8::HandleScope outer_scope(CcTest::isolate()); { @@ -2071,18 +2135,18 @@ TEST(ResetSharedFunctionInfoCountersDuringMarkSweep) { Handle<JSFunction> f = v8::Utils::OpenHandle( *v8::Handle<v8::Function>::Cast( - v8::Context::GetCurrent()->Global()->Get(v8_str("f")))); + CcTest::global()->Get(v8_str("f")))); CHECK(f->IsOptimized()); - HEAP->incremental_marking()->Abort(); + CcTest::heap()->incremental_marking()->Abort(); - // The following two calls will increment HEAP->global_ic_age(). + // The following two calls will increment CcTest::heap()->global_ic_age(). // Since incremental marking is off, IdleNotification will do full GC. const int kLongIdlePauseInMs = 1000; v8::V8::ContextDisposedNotification(); v8::V8::IdleNotification(kLongIdlePauseInMs); - CHECK_EQ(HEAP->global_ic_age(), f->shared()->ic_age()); + CHECK_EQ(CcTest::heap()->global_ic_age(), f->shared()->ic_age()); CHECK_EQ(0, f->shared()->opt_count()); CHECK_EQ(0, f->shared()->code()->profiler_ticks()); } @@ -2092,11 +2156,11 @@ TEST(ResetSharedFunctionInfoCountersDuringMarkSweep) { TEST(OptimizedAllocationAlwaysInNewSpace) { i::FLAG_allow_natives_syntax = true; CcTest::InitializeVM(); - if (!i::Isolate::Current()->use_crankshaft() || i::FLAG_always_opt) return; + if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; v8::HandleScope scope(CcTest::isolate()); - SimulateFullSpace(HEAP->new_space()); + SimulateFullSpace(CcTest::heap()->new_space()); AlwaysAllocateScope always_allocate; v8::Local<v8::Value> res = CompileRun( "function c(x) {" @@ -2114,17 +2178,17 @@ TEST(OptimizedAllocationAlwaysInNewSpace) { Handle<JSObject> o = v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); - CHECK(HEAP->InNewSpace(*o)); + CHECK(CcTest::heap()->InNewSpace(*o)); } TEST(OptimizedPretenuringAllocationFolding) { i::FLAG_allow_natives_syntax = true; CcTest::InitializeVM(); - if (!i::Isolate::Current()->use_crankshaft() || i::FLAG_always_opt) return; + if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; v8::HandleScope scope(CcTest::isolate()); - HEAP->SetNewSpaceHighPromotionModeActive(true); + CcTest::heap()->SetNewSpaceHighPromotionModeActive(true); v8::Local<v8::Value> res = CompileRun( "function DataObject() {" @@ -2145,22 +2209,22 @@ TEST(OptimizedPretenuringAllocationFolding) { Handle<JSObject> o = v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); - CHECK(HEAP->InOldDataSpace(o->RawFastPropertyAt(0))); - CHECK(HEAP->InOldPointerSpace(o->RawFastPropertyAt(1))); - CHECK(HEAP->InOldDataSpace(o->RawFastPropertyAt(2))); - CHECK(HEAP->InOldPointerSpace(o->RawFastPropertyAt(3))); - CHECK(HEAP->InOldDataSpace(o->RawFastPropertyAt(4))); - CHECK(HEAP->InOldPointerSpace(o->RawFastPropertyAt(5))); + CHECK(CcTest::heap()->InOldDataSpace(o->RawFastPropertyAt(0))); + CHECK(CcTest::heap()->InOldPointerSpace(o->RawFastPropertyAt(1))); + CHECK(CcTest::heap()->InOldDataSpace(o->RawFastPropertyAt(2))); + CHECK(CcTest::heap()->InOldPointerSpace(o->RawFastPropertyAt(3))); + CHECK(CcTest::heap()->InOldDataSpace(o->RawFastPropertyAt(4))); + CHECK(CcTest::heap()->InOldPointerSpace(o->RawFastPropertyAt(5))); } TEST(OptimizedPretenuringAllocationFoldingBlocks) { i::FLAG_allow_natives_syntax = true; CcTest::InitializeVM(); - if (!i::Isolate::Current()->use_crankshaft() || i::FLAG_always_opt) return; + if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; v8::HandleScope scope(CcTest::isolate()); - HEAP->SetNewSpaceHighPromotionModeActive(true); + CcTest::heap()->SetNewSpaceHighPromotionModeActive(true); v8::Local<v8::Value> res = CompileRun( "function DataObject() {" @@ -2181,22 +2245,22 @@ TEST(OptimizedPretenuringAllocationFoldingBlocks) { Handle<JSObject> o = v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); - CHECK(HEAP->InOldPointerSpace(o->RawFastPropertyAt(0))); - CHECK(HEAP->InOldPointerSpace(o->RawFastPropertyAt(1))); - CHECK(HEAP->InOldDataSpace(o->RawFastPropertyAt(2))); - CHECK(HEAP->InOldDataSpace(o->RawFastPropertyAt(3))); - CHECK(HEAP->InOldPointerSpace(o->RawFastPropertyAt(4))); - CHECK(HEAP->InOldDataSpace(o->RawFastPropertyAt(5))); + CHECK(CcTest::heap()->InOldPointerSpace(o->RawFastPropertyAt(0))); + CHECK(CcTest::heap()->InOldPointerSpace(o->RawFastPropertyAt(1))); + CHECK(CcTest::heap()->InOldDataSpace(o->RawFastPropertyAt(2))); + CHECK(CcTest::heap()->InOldDataSpace(o->RawFastPropertyAt(3))); + CHECK(CcTest::heap()->InOldPointerSpace(o->RawFastPropertyAt(4))); + CHECK(CcTest::heap()->InOldDataSpace(o->RawFastPropertyAt(5))); } TEST(OptimizedPretenuringObjectArrayLiterals) { i::FLAG_allow_natives_syntax = true; CcTest::InitializeVM(); - if (!i::Isolate::Current()->use_crankshaft() || i::FLAG_always_opt) return; + if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; v8::HandleScope scope(CcTest::isolate()); - HEAP->SetNewSpaceHighPromotionModeActive(true); + CcTest::heap()->SetNewSpaceHighPromotionModeActive(true); v8::Local<v8::Value> res = CompileRun( "function f() {" @@ -2210,18 +2274,18 @@ TEST(OptimizedPretenuringObjectArrayLiterals) { Handle<JSObject> o = v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); - CHECK(HEAP->InOldPointerSpace(o->elements())); - CHECK(HEAP->InOldPointerSpace(*o)); + CHECK(CcTest::heap()->InOldPointerSpace(o->elements())); + CHECK(CcTest::heap()->InOldPointerSpace(*o)); } TEST(OptimizedPretenuringMixedInObjectProperties) { i::FLAG_allow_natives_syntax = true; CcTest::InitializeVM(); - if (!i::Isolate::Current()->use_crankshaft() || i::FLAG_always_opt) return; + if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; v8::HandleScope scope(CcTest::isolate()); - HEAP->SetNewSpaceHighPromotionModeActive(true); + CcTest::heap()->SetNewSpaceHighPromotionModeActive(true); v8::Local<v8::Value> res = CompileRun( "function f() {" @@ -2235,24 +2299,24 @@ TEST(OptimizedPretenuringMixedInObjectProperties) { Handle<JSObject> o = v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); - CHECK(HEAP->InOldPointerSpace(*o)); - CHECK(HEAP->InOldPointerSpace(o->RawFastPropertyAt(0))); - CHECK(HEAP->InOldDataSpace(o->RawFastPropertyAt(1))); + CHECK(CcTest::heap()->InOldPointerSpace(*o)); + CHECK(CcTest::heap()->InOldPointerSpace(o->RawFastPropertyAt(0))); + CHECK(CcTest::heap()->InOldDataSpace(o->RawFastPropertyAt(1))); JSObject* inner_object = reinterpret_cast<JSObject*>(o->RawFastPropertyAt(0)); - CHECK(HEAP->InOldPointerSpace(inner_object)); - CHECK(HEAP->InOldDataSpace(inner_object->RawFastPropertyAt(0))); - CHECK(HEAP->InOldPointerSpace(inner_object->RawFastPropertyAt(1))); + CHECK(CcTest::heap()->InOldPointerSpace(inner_object)); + CHECK(CcTest::heap()->InOldDataSpace(inner_object->RawFastPropertyAt(0))); + CHECK(CcTest::heap()->InOldPointerSpace(inner_object->RawFastPropertyAt(1))); } TEST(OptimizedPretenuringDoubleArrayProperties) { i::FLAG_allow_natives_syntax = true; CcTest::InitializeVM(); - if (!i::Isolate::Current()->use_crankshaft() || i::FLAG_always_opt) return; + if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; v8::HandleScope scope(CcTest::isolate()); - HEAP->SetNewSpaceHighPromotionModeActive(true); + CcTest::heap()->SetNewSpaceHighPromotionModeActive(true); v8::Local<v8::Value> res = CompileRun( "function f() {" @@ -2266,18 +2330,18 @@ TEST(OptimizedPretenuringDoubleArrayProperties) { Handle<JSObject> o = v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); - CHECK(HEAP->InOldPointerSpace(*o)); - CHECK(HEAP->InOldDataSpace(o->properties())); + CHECK(CcTest::heap()->InOldPointerSpace(*o)); + CHECK(CcTest::heap()->InOldDataSpace(o->properties())); } TEST(OptimizedPretenuringdoubleArrayLiterals) { i::FLAG_allow_natives_syntax = true; CcTest::InitializeVM(); - if (!i::Isolate::Current()->use_crankshaft() || i::FLAG_always_opt) return; + if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; v8::HandleScope scope(CcTest::isolate()); - HEAP->SetNewSpaceHighPromotionModeActive(true); + CcTest::heap()->SetNewSpaceHighPromotionModeActive(true); v8::Local<v8::Value> res = CompileRun( "function f() {" @@ -2291,18 +2355,18 @@ TEST(OptimizedPretenuringdoubleArrayLiterals) { Handle<JSObject> o = v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); - CHECK(HEAP->InOldDataSpace(o->elements())); - CHECK(HEAP->InOldPointerSpace(*o)); + CHECK(CcTest::heap()->InOldDataSpace(o->elements())); + CHECK(CcTest::heap()->InOldPointerSpace(*o)); } TEST(OptimizedPretenuringNestedMixedArrayLiterals) { i::FLAG_allow_natives_syntax = true; CcTest::InitializeVM(); - if (!i::Isolate::Current()->use_crankshaft() || i::FLAG_always_opt) return; + if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; v8::HandleScope scope(CcTest::isolate()); - HEAP->SetNewSpaceHighPromotionModeActive(true); + CcTest::heap()->SetNewSpaceHighPromotionModeActive(true); v8::Local<v8::Value> res = CompileRun( "function f() {" @@ -2322,21 +2386,21 @@ TEST(OptimizedPretenuringNestedMixedArrayLiterals) { Handle<JSObject> o = v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); - CHECK(HEAP->InOldPointerSpace(*o)); - CHECK(HEAP->InOldPointerSpace(*int_array_handle)); - CHECK(HEAP->InOldPointerSpace(int_array_handle->elements())); - CHECK(HEAP->InOldPointerSpace(*double_array_handle)); - CHECK(HEAP->InOldDataSpace(double_array_handle->elements())); + CHECK(CcTest::heap()->InOldPointerSpace(*o)); + CHECK(CcTest::heap()->InOldPointerSpace(*int_array_handle)); + CHECK(CcTest::heap()->InOldPointerSpace(int_array_handle->elements())); + CHECK(CcTest::heap()->InOldPointerSpace(*double_array_handle)); + CHECK(CcTest::heap()->InOldDataSpace(double_array_handle->elements())); } TEST(OptimizedPretenuringNestedObjectLiterals) { i::FLAG_allow_natives_syntax = true; CcTest::InitializeVM(); - if (!i::Isolate::Current()->use_crankshaft() || i::FLAG_always_opt) return; + if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; v8::HandleScope scope(CcTest::isolate()); - HEAP->SetNewSpaceHighPromotionModeActive(true); + CcTest::heap()->SetNewSpaceHighPromotionModeActive(true); v8::Local<v8::Value> res = CompileRun( "function f() {" @@ -2356,21 +2420,21 @@ TEST(OptimizedPretenuringNestedObjectLiterals) { Handle<JSObject> o = v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); - CHECK(HEAP->InOldPointerSpace(*o)); - CHECK(HEAP->InOldPointerSpace(*int_array_handle_1)); - CHECK(HEAP->InOldPointerSpace(int_array_handle_1->elements())); - CHECK(HEAP->InOldPointerSpace(*int_array_handle_2)); - CHECK(HEAP->InOldPointerSpace(int_array_handle_2->elements())); + CHECK(CcTest::heap()->InOldPointerSpace(*o)); + CHECK(CcTest::heap()->InOldPointerSpace(*int_array_handle_1)); + CHECK(CcTest::heap()->InOldPointerSpace(int_array_handle_1->elements())); + CHECK(CcTest::heap()->InOldPointerSpace(*int_array_handle_2)); + CHECK(CcTest::heap()->InOldPointerSpace(int_array_handle_2->elements())); } TEST(OptimizedPretenuringNestedDoubleLiterals) { i::FLAG_allow_natives_syntax = true; CcTest::InitializeVM(); - if (!i::Isolate::Current()->use_crankshaft() || i::FLAG_always_opt) return; + if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; v8::HandleScope scope(CcTest::isolate()); - HEAP->SetNewSpaceHighPromotionModeActive(true); + CcTest::heap()->SetNewSpaceHighPromotionModeActive(true); v8::Local<v8::Value> res = CompileRun( "function f() {" @@ -2392,11 +2456,11 @@ TEST(OptimizedPretenuringNestedDoubleLiterals) { Handle<JSObject> o = v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); - CHECK(HEAP->InOldPointerSpace(*o)); - CHECK(HEAP->InOldPointerSpace(*double_array_handle_1)); - CHECK(HEAP->InOldDataSpace(double_array_handle_1->elements())); - CHECK(HEAP->InOldPointerSpace(*double_array_handle_2)); - CHECK(HEAP->InOldDataSpace(double_array_handle_2->elements())); + CHECK(CcTest::heap()->InOldPointerSpace(*o)); + CHECK(CcTest::heap()->InOldPointerSpace(*double_array_handle_1)); + CHECK(CcTest::heap()->InOldDataSpace(double_array_handle_1->elements())); + CHECK(CcTest::heap()->InOldPointerSpace(*double_array_handle_2)); + CHECK(CcTest::heap()->InOldDataSpace(double_array_handle_2->elements())); } @@ -2404,7 +2468,7 @@ TEST(OptimizedPretenuringNestedDoubleLiterals) { TEST(OptimizedAllocationArrayLiterals) { i::FLAG_allow_natives_syntax = true; CcTest::InitializeVM(); - if (!i::Isolate::Current()->use_crankshaft() || i::FLAG_always_opt) return; + if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; v8::HandleScope scope(CcTest::isolate()); @@ -2423,7 +2487,7 @@ TEST(OptimizedAllocationArrayLiterals) { Handle<JSObject> o = v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); - CHECK(HEAP->InNewSpace(o->elements())); + CHECK(CcTest::heap()->InNewSpace(o->elements())); } @@ -2431,10 +2495,10 @@ TEST(OptimizedPretenuringCallNew) { i::FLAG_allow_natives_syntax = true; i::FLAG_pretenuring_call_new = true; CcTest::InitializeVM(); - if (!i::Isolate::Current()->use_crankshaft() || i::FLAG_always_opt) return; + if (!CcTest::i_isolate()->use_crankshaft() || i::FLAG_always_opt) return; if (i::FLAG_gc_global || i::FLAG_stress_compaction) return; v8::HandleScope scope(CcTest::isolate()); - HEAP->SetNewSpaceHighPromotionModeActive(true); + CcTest::heap()->SetNewSpaceHighPromotionModeActive(true); AlwaysAllocateScope always_allocate; v8::Local<v8::Value> res = CompileRun( @@ -2448,7 +2512,7 @@ TEST(OptimizedPretenuringCallNew) { Handle<JSObject> o = v8::Utils::OpenHandle(*v8::Handle<v8::Object>::Cast(res)); - CHECK(HEAP->InOldPointerSpace(*o)); + CHECK(CcTest::heap()->InOldPointerSpace(*o)); } @@ -2480,7 +2544,7 @@ TEST(Regress1465) { Handle<JSObject> root = v8::Utils::OpenHandle( *v8::Handle<v8::Object>::Cast( - v8::Context::GetCurrent()->Global()->Get(v8_str("root")))); + CcTest::global()->Get(v8_str("root")))); // Count number of live transitions before marking. int transitions_before = CountMapTransitions(root->map()); @@ -2488,7 +2552,7 @@ TEST(Regress1465) { CHECK_EQ(transitions_count, transitions_before); SimulateIncrementalMarking(); - HEAP->CollectAllGarbage(Heap::kNoGCFlags); + CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); // Count number of live transitions after marking. Note that one transition // is left, because 'o' still holds an instance of one transition target. @@ -2522,15 +2586,15 @@ TEST(Regress2143a) { "f(root);"); // This bug only triggers with aggressive IC clearing. - HEAP->AgeInlineCaches(); + CcTest::heap()->AgeInlineCaches(); // Explicitly request GC to perform final marking step and sweeping. - HEAP->CollectAllGarbage(Heap::kNoGCFlags); + CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); Handle<JSObject> root = v8::Utils::OpenHandle( *v8::Handle<v8::Object>::Cast( - v8::Context::GetCurrent()->Global()->Get(v8_str("root")))); + CcTest::global()->Get(v8_str("root")))); // The root object should be in a sane state. CHECK(root->IsJSObject()); @@ -2566,15 +2630,15 @@ TEST(Regress2143b) { "%DeoptimizeFunction(f);"); // This bug only triggers with aggressive IC clearing. - HEAP->AgeInlineCaches(); + CcTest::heap()->AgeInlineCaches(); // Explicitly request GC to perform final marking step and sweeping. - HEAP->CollectAllGarbage(Heap::kNoGCFlags); + CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); Handle<JSObject> root = v8::Utils::OpenHandle( *v8::Handle<v8::Object>::Cast( - v8::Context::GetCurrent()->Global()->Get(v8_str("root")))); + CcTest::global()->Get(v8_str("root")))); // The root object should be in a sane state. CHECK(root->IsJSObject()); @@ -2588,13 +2652,14 @@ TEST(ReleaseOverReservedPages) { i::FLAG_crankshaft = false; i::FLAG_always_opt = false; CcTest::InitializeVM(); - Isolate* isolate = Isolate::Current(); + Isolate* isolate = CcTest::i_isolate(); Factory* factory = isolate->factory(); + Heap* heap = isolate->heap(); v8::HandleScope scope(CcTest::isolate()); static const int number_of_test_pages = 20; // Prepare many pages with low live-bytes count. - PagedSpace* old_pointer_space = HEAP->old_pointer_space(); + PagedSpace* old_pointer_space = heap->old_pointer_space(); CHECK_EQ(1, old_pointer_space->CountTotalPages()); for (int i = 0; i < number_of_test_pages; i++) { AlwaysAllocateScope always_allocate; @@ -2605,14 +2670,14 @@ TEST(ReleaseOverReservedPages) { // Triggering one GC will cause a lot of garbage to be discovered but // even spread across all allocated pages. - HEAP->CollectAllGarbage(Heap::kNoGCFlags, "triggered for preparation"); + heap->CollectAllGarbage(Heap::kNoGCFlags, "triggered for preparation"); CHECK_GE(number_of_test_pages + 1, old_pointer_space->CountTotalPages()); // Triggering subsequent GCs should cause at least half of the pages // to be released to the OS after at most two cycles. - HEAP->CollectAllGarbage(Heap::kNoGCFlags, "triggered by test 1"); + heap->CollectAllGarbage(Heap::kNoGCFlags, "triggered by test 1"); CHECK_GE(number_of_test_pages + 1, old_pointer_space->CountTotalPages()); - HEAP->CollectAllGarbage(Heap::kNoGCFlags, "triggered by test 2"); + heap->CollectAllGarbage(Heap::kNoGCFlags, "triggered by test 2"); CHECK_GE(number_of_test_pages + 1, old_pointer_space->CountTotalPages() * 2); // Triggering a last-resort GC should cause all pages to be released to the @@ -2622,7 +2687,7 @@ TEST(ReleaseOverReservedPages) { // first page should be small in order to reduce memory used when the VM // boots, but if the 20 small arrays don't fit on the first page then that's // an indication that it is too small. - HEAP->CollectAllAvailableGarbage("triggered really hard"); + heap->CollectAllAvailableGarbage("triggered really hard"); CHECK_EQ(1, old_pointer_space->CountTotalPages()); } @@ -2630,10 +2695,10 @@ TEST(ReleaseOverReservedPages) { TEST(Regress2237) { i::FLAG_stress_compaction = false; CcTest::InitializeVM(); - Isolate* isolate = Isolate::Current(); + Isolate* isolate = CcTest::i_isolate(); Factory* factory = isolate->factory(); v8::HandleScope scope(CcTest::isolate()); - Handle<String> slice(HEAP->empty_string()); + Handle<String> slice(CcTest::heap()->empty_string()); { // Generate a parent that lives in new-space. @@ -2641,20 +2706,20 @@ TEST(Regress2237) { const char* c = "This text is long enough to trigger sliced strings."; Handle<String> s = factory->NewStringFromAscii(CStrVector(c)); CHECK(s->IsSeqOneByteString()); - CHECK(HEAP->InNewSpace(*s)); + CHECK(CcTest::heap()->InNewSpace(*s)); // Generate a sliced string that is based on the above parent and // lives in old-space. - SimulateFullSpace(HEAP->new_space()); + SimulateFullSpace(CcTest::heap()->new_space()); AlwaysAllocateScope always_allocate; Handle<String> t = factory->NewProperSubString(s, 5, 35); CHECK(t->IsSlicedString()); - CHECK(!HEAP->InNewSpace(*t)); + CHECK(!CcTest::heap()->InNewSpace(*t)); *slice.location() = *t.location(); } CHECK(SlicedString::cast(*slice)->parent()->IsSeqOneByteString()); - HEAP->CollectAllGarbage(Heap::kNoGCFlags); + CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); CHECK(SlicedString::cast(*slice)->parent()->IsSeqOneByteString()); } @@ -2669,7 +2734,7 @@ TEST(PrintSharedFunctionInfo) { Handle<JSFunction> g = v8::Utils::OpenHandle( *v8::Handle<v8::Function>::Cast( - v8::Context::GetCurrent()->Global()->Get(v8_str("g")))); + CcTest::global()->Get(v8_str("g")))); DisallowHeapAllocation no_allocation; g->shared()->PrintLn(); @@ -2683,7 +2748,7 @@ TEST(Regress2211) { v8::Handle<v8::String> value = v8_str("val string"); Smi* hash = Smi::FromInt(321); - Heap* heap = Isolate::Current()->heap(); + Heap* heap = CcTest::heap(); for (int i = 0; i < 2; i++) { // Store identity hash first and common hidden property second. @@ -2732,13 +2797,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); + CcTest::global()->Set(v8_str("fun1"), fun1); + CcTest::global()->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")))); + CcTest::global()->Get(v8_str("f")))); Handle<TypeFeedbackCells> cells(TypeFeedbackInfo::cast( f->shared()->code()->type_feedback_info())->type_feedback_cells()); @@ -2747,7 +2812,7 @@ TEST(IncrementalMarkingClearsTypeFeedbackCells) { CHECK(cells->GetCell(1)->value()->IsJSFunction()); SimulateIncrementalMarking(); - HEAP->CollectAllGarbage(Heap::kNoGCFlags); + CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); CHECK_EQ(2, cells->CellCount()); CHECK(cells->GetCell(0)->value()->IsTheHole()); @@ -2783,13 +2848,13 @@ TEST(IncrementalMarkingPreservesMonomorhpicIC) { Handle<JSFunction> f = v8::Utils::OpenHandle( *v8::Handle<v8::Function>::Cast( - v8::Context::GetCurrent()->Global()->Get(v8_str("f")))); + CcTest::global()->Get(v8_str("f")))); Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC); CHECK(ic_before->ic_state() == MONOMORPHIC); SimulateIncrementalMarking(); - HEAP->CollectAllGarbage(Heap::kNoGCFlags); + CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC); CHECK(ic_after->ic_state() == MONOMORPHIC); @@ -2810,12 +2875,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); + CcTest::global()->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")))); + CcTest::global()->Get(v8_str("f")))); Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC); CHECK(ic_before->ic_state() == MONOMORPHIC); @@ -2823,10 +2888,10 @@ TEST(IncrementalMarkingClearsMonomorhpicIC) { // Fire context dispose notification. v8::V8::ContextDisposedNotification(); SimulateIncrementalMarking(); - HEAP->CollectAllGarbage(Heap::kNoGCFlags); + CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC); - CHECK(ic_after->ic_state() == UNINITIALIZED); + CHECK(IC::IsCleared(ic_after)); } @@ -2850,13 +2915,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); + CcTest::global()->Set(v8_str("obj1"), obj1); + CcTest::global()->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")))); + CcTest::global()->Get(v8_str("f")))); Code* ic_before = FindFirstIC(f->shared()->code(), Code::LOAD_IC); CHECK(ic_before->ic_state() == POLYMORPHIC); @@ -2864,10 +2929,10 @@ TEST(IncrementalMarkingClearsPolymorhpicIC) { // Fire context dispose notification. v8::V8::ContextDisposedNotification(); SimulateIncrementalMarking(); - HEAP->CollectAllGarbage(Heap::kNoGCFlags); + CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags); Code* ic_after = FindFirstIC(f->shared()->code(), Code::LOAD_IC); - CHECK(ic_after->ic_state() == UNINITIALIZED); + CHECK(IC::IsCleared(ic_after)); } @@ -2900,21 +2965,20 @@ void ReleaseStackTraceDataTest(const char* source, const char* accessor) { // resource's callback is fired when the external string is GC'ed. FLAG_use_ic = false; // ICs retain objects. FLAG_concurrent_recompilation = false; - CcTest::InitializeVM(); v8::HandleScope scope(CcTest::isolate()); SourceResource* resource = new SourceResource(i::StrDup(source)); { v8::HandleScope scope(CcTest::isolate()); v8::Handle<v8::String> source_string = v8::String::NewExternal(resource); - HEAP->CollectAllAvailableGarbage(); + CcTest::heap()->CollectAllAvailableGarbage(); v8::Script::Compile(source_string)->Run(); CHECK(!resource->IsDisposed()); } - // HEAP->CollectAllAvailableGarbage(); + // CcTest::heap()->CollectAllAvailableGarbage(); CHECK(!resource->IsDisposed()); CompileRun(accessor); - HEAP->CollectAllAvailableGarbage(); + CcTest::heap()->CollectAllAvailableGarbage(); // External source has been released. CHECK(resource->IsDisposed()); @@ -2923,6 +2987,7 @@ void ReleaseStackTraceDataTest(const char* source, const char* accessor) { TEST(ReleaseStackTraceData) { + CcTest::InitializeVM(); static const char* source1 = "var error = null; " /* Normal Error */ "try { " " throw new Error(); " @@ -2968,7 +3033,7 @@ TEST(ReleaseStackTraceData) { TEST(Regression144230) { i::FLAG_stress_compaction = false; CcTest::InitializeVM(); - Isolate* isolate = Isolate::Current(); + Isolate* isolate = CcTest::i_isolate(); Heap* heap = isolate->heap(); HandleScope scope(isolate); @@ -3009,9 +3074,10 @@ TEST(Regression144230) { // visited later, causing the CallIC to be cleared. Handle<String> name = isolate->factory()->InternalizeUtf8String("call"); Handle<GlobalObject> global(isolate->context()->global_object()); + Handle<Smi> zero(Smi::FromInt(0), isolate); MaybeObject* maybe_call = global->GetProperty(*name); JSFunction* call = JSFunction::cast(maybe_call->ToObjectChecked()); - USE(global->SetProperty(*name, Smi::FromInt(0), NONE, kNonStrictMode)); + JSReceiver::SetProperty(global, name, zero, NONE, kNonStrictMode); isolate->compilation_cache()->Clear(); call->shared()->set_ic_age(heap->global_ic_age() + 1); Handle<Object> call_code(call->code(), isolate); @@ -3022,7 +3088,7 @@ TEST(Regression144230) { // Either heap verification caught the problem already or we go kaboom once // the CallIC is executed the next time. - USE(global->SetProperty(*name, *call_function, NONE, kNonStrictMode)); + JSReceiver::SetProperty(global, name, call_function, NONE, kNonStrictMode); CompileRun("call();"); } @@ -3031,7 +3097,7 @@ TEST(Regress159140) { i::FLAG_allow_natives_syntax = true; i::FLAG_flush_code_incrementally = true; CcTest::InitializeVM(); - Isolate* isolate = Isolate::Current(); + Isolate* isolate = CcTest::i_isolate(); Heap* heap = isolate->heap(); HandleScope scope(isolate); @@ -3060,14 +3126,14 @@ TEST(Regress159140) { Handle<JSFunction> f = v8::Utils::OpenHandle( *v8::Handle<v8::Function>::Cast( - v8::Context::GetCurrent()->Global()->Get(v8_str("f")))); + CcTest::global()->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")))); + CcTest::global()->Get(v8_str("g")))); CHECK(g->is_compiled()); const int kAgingThreshold = 6; for (int i = 0; i < kAgingThreshold; i++) { @@ -3093,7 +3159,7 @@ TEST(Regress165495) { i::FLAG_allow_natives_syntax = true; i::FLAG_flush_code_incrementally = true; CcTest::InitializeVM(); - Isolate* isolate = Isolate::Current(); + Isolate* isolate = CcTest::i_isolate(); Heap* heap = isolate->heap(); HandleScope scope(isolate); @@ -3115,7 +3181,7 @@ TEST(Regress165495) { Handle<JSFunction> f = v8::Utils::OpenHandle( *v8::Handle<v8::Function>::Cast( - v8::Context::GetCurrent()->Global()->Get(v8_str("f")))); + CcTest::global()->Get(v8_str("f")))); CHECK(f->is_compiled()); const int kAgingThreshold = 6; for (int i = 0; i < kAgingThreshold; i++) { @@ -3142,7 +3208,7 @@ TEST(Regress169209) { i::FLAG_flush_code_incrementally = true; CcTest::InitializeVM(); - Isolate* isolate = Isolate::Current(); + Isolate* isolate = CcTest::i_isolate(); Heap* heap = isolate->heap(); HandleScope scope(isolate); @@ -3163,7 +3229,7 @@ TEST(Regress169209) { Handle<JSFunction> f = v8::Utils::OpenHandle( *v8::Handle<v8::Function>::Cast( - v8::Context::GetCurrent()->Global()->Get(v8_str("f")))); + CcTest::global()->Get(v8_str("f")))); CHECK(f->is_compiled()); const int kAgingThreshold = 6; for (int i = 0; i < kAgingThreshold; i++) { @@ -3184,7 +3250,7 @@ TEST(Regress169209) { Handle<JSFunction> f = v8::Utils::OpenHandle( *v8::Handle<v8::Function>::Cast( - v8::Context::GetCurrent()->Global()->Get(v8_str("flushMe")))); + CcTest::global()->Get(v8_str("flushMe")))); CHECK(f->is_compiled()); const int kAgingThreshold = 6; for (int i = 0; i < kAgingThreshold; i++) { @@ -3228,7 +3294,7 @@ TEST(Regress169928) { i::FLAG_allow_natives_syntax = true; i::FLAG_crankshaft = false; CcTest::InitializeVM(); - Isolate* isolate = Isolate::Current(); + Isolate* isolate = CcTest::i_isolate(); Factory* factory = isolate->factory(); v8::HandleScope scope(CcTest::isolate()); @@ -3254,17 +3320,17 @@ 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)); + CcTest::global()->Set(array_name, v8::Int32::New(0)); // First make sure we flip spaces - HEAP->CollectGarbage(NEW_SPACE); + CcTest::heap()->CollectGarbage(NEW_SPACE); // Allocate the object. Handle<FixedArray> array_data = factory->NewFixedArray(2, NOT_TENURED); array_data->set(0, Smi::FromInt(1)); array_data->set(1, Smi::FromInt(2)); - AllocateAllButNBytes(HEAP->new_space(), + AllocateAllButNBytes(CcTest::heap()->new_space(), JSArray::kSize + AllocationMemento::kSize + kPointerSize); @@ -3277,18 +3343,18 @@ TEST(Regress169928) { // We need filler the size of AllocationMemento object, plus an extra // fill pointer value. - MaybeObject* maybe_object = HEAP->AllocateRaw( + MaybeObject* maybe_object = CcTest::heap()->AllocateRaw( AllocationMemento::kSize + kPointerSize, NEW_SPACE, OLD_POINTER_SPACE); Object* obj = NULL; CHECK(maybe_object->ToObject(&obj)); Address addr_obj = reinterpret_cast<Address>( reinterpret_cast<byte*>(obj - kHeapObjectTag)); - HEAP->CreateFillerObjectAt(addr_obj, + CcTest::heap()->CreateFillerObjectAt(addr_obj, AllocationMemento::kSize + kPointerSize); // 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); + CcTest::global()->Set(array_name, array_obj); // This should crash with a protection violation if we are running a build // with the bug. @@ -3303,7 +3369,7 @@ TEST(Regress168801) { i::FLAG_allow_natives_syntax = true; i::FLAG_flush_code_incrementally = true; CcTest::InitializeVM(); - Isolate* isolate = Isolate::Current(); + Isolate* isolate = CcTest::i_isolate(); Heap* heap = isolate->heap(); HandleScope scope(isolate); @@ -3326,7 +3392,7 @@ TEST(Regress168801) { Handle<JSFunction> f = v8::Utils::OpenHandle( *v8::Handle<v8::Function>::Cast( - v8::Context::GetCurrent()->Global()->Get(v8_str("f")))); + CcTest::global()->Get(v8_str("f")))); CHECK(f->is_compiled()); const int kAgingThreshold = 6; for (int i = 0; i < kAgingThreshold; i++) { @@ -3359,7 +3425,7 @@ TEST(Regress173458) { i::FLAG_allow_natives_syntax = true; i::FLAG_flush_code_incrementally = true; CcTest::InitializeVM(); - Isolate* isolate = Isolate::Current(); + Isolate* isolate = CcTest::i_isolate(); Heap* heap = isolate->heap(); HandleScope scope(isolate); @@ -3382,7 +3448,7 @@ TEST(Regress173458) { Handle<JSFunction> f = v8::Utils::OpenHandle( *v8::Handle<v8::Function>::Cast( - v8::Context::GetCurrent()->Global()->Get(v8_str("f")))); + CcTest::global()->Get(v8_str("f")))); CHECK(f->is_compiled()); const int kAgingThreshold = 6; for (int i = 0; i < kAgingThreshold; i++) { @@ -3416,7 +3482,7 @@ class DummyVisitor : public ObjectVisitor { TEST(DeferredHandles) { CcTest::InitializeVM(); - Isolate* isolate = Isolate::Current(); + Isolate* isolate = CcTest::i_isolate(); Heap* heap = isolate->heap(); v8::HandleScope scope(reinterpret_cast<v8::Isolate*>(isolate)); v8::ImplementationUtilities::HandleScopeData* data = @@ -3444,7 +3510,7 @@ TEST(IncrementalMarkingStepMakesBigProgressWithLargeObjects) { " for (var i = 0; i < n; i += 100) a[i] = i;" "};" "f(10 * 1024 * 1024);"); - IncrementalMarking* marking = HEAP->incremental_marking(); + IncrementalMarking* marking = CcTest::heap()->incremental_marking(); if (marking->IsStopped()) marking->Start(); // This big step should be sufficient to mark the whole array. marking->Step(100 * MB, IncrementalMarking::NO_GC_VIA_STACK_GUARD); |