Commit c57236e2 authored by dcarney@chromium.org's avatar dcarney@chromium.org

remove HEAP from tests

R=svenpanne@chromium.org
BUG=

Review URL: https://codereview.chromium.org/24169005

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@16819 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 8754a251
......@@ -78,9 +78,6 @@ typedef v8::internal::EnumSet<CcTestExtensionIds> CcTestExtensionFlags;
EXTENSION_LIST(DEFINE_EXTENSION_FLAG)
#undef DEFINE_EXTENSION_FLAG
// Temporary macros for accessing current isolate and its subobjects.
// They provide better readability, especially when used a lot in the code.
#define HEAP (v8::internal::Isolate::Current()->heap())
class CcTest {
public:
......@@ -108,6 +105,10 @@ class CcTest {
return reinterpret_cast<i::Isolate*>(isolate());
}
static i::Heap* heap() {
return i_isolate()->heap();
}
// Helper function to initialize the VM.
static void InitializeVM(CcTestExtensionFlags extensions = NO_EXTENSIONS);
......
......@@ -317,7 +317,7 @@ static void CheckAccessorArgsCorrect(
CHECK(info.GetIsolate() == CcTest::isolate());
CHECK(info.This() == info.Holder());
CHECK(info.Data()->Equals(v8::String::New("data")));
HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags);
CHECK(info.GetIsolate() == CcTest::isolate());
CHECK(info.This() == info.Holder());
CHECK(info.Data()->Equals(v8::String::New("data")));
......
......@@ -37,7 +37,7 @@ using namespace v8::internal;
static MaybeObject* AllocateAfterFailures() {
static int attempts = 0;
if (++attempts < 3) return Failure::RetryAfterGC();
Heap* heap = CcTest::i_isolate()->heap();
Heap* heap = CcTest::heap();
// New space.
SimulateFullSpace(heap->new_space());
......
This diff is collapsed.
......@@ -61,7 +61,7 @@ TEST(MIPS0) {
CodeDesc desc;
assm.GetCode(&desc);
Object* code = HEAP->CreateCode(
Object* code = CcTest::heap()->CreateCode(
desc,
Code::ComputeFlags(Code::STUB),
Handle<Code>())->ToObjectChecked();
......@@ -100,7 +100,7 @@ TEST(MIPS1) {
CodeDesc desc;
assm.GetCode(&desc);
Object* code = HEAP->CreateCode(
Object* code = CcTest::heap()->CreateCode(
desc,
Code::ComputeFlags(Code::STUB),
Handle<Code>())->ToObjectChecked();
......@@ -241,7 +241,7 @@ TEST(MIPS2) {
CodeDesc desc;
assm.GetCode(&desc);
Object* code = HEAP->CreateCode(
Object* code = CcTest::heap()->CreateCode(
desc,
Code::ComputeFlags(Code::STUB),
Handle<Code>())->ToObjectChecked();
......@@ -314,7 +314,7 @@ TEST(MIPS3) {
CodeDesc desc;
assm.GetCode(&desc);
Object* code = HEAP->CreateCode(
Object* code = CcTest::heap()->CreateCode(
desc,
Code::ComputeFlags(Code::STUB),
Handle<Code>())->ToObjectChecked();
......@@ -382,7 +382,7 @@ TEST(MIPS4) {
CodeDesc desc;
assm.GetCode(&desc);
Object* code = HEAP->CreateCode(
Object* code = CcTest::heap()->CreateCode(
desc,
Code::ComputeFlags(Code::STUB),
Handle<Code>())->ToObjectChecked();
......@@ -448,7 +448,7 @@ TEST(MIPS5) {
CodeDesc desc;
assm.GetCode(&desc);
Object* code = HEAP->CreateCode(
Object* code = CcTest::heap()->CreateCode(
desc,
Code::ComputeFlags(Code::STUB),
Handle<Code>())->ToObjectChecked();
......@@ -521,7 +521,7 @@ TEST(MIPS6) {
CodeDesc desc;
assm.GetCode(&desc);
Object* code = HEAP->CreateCode(
Object* code = CcTest::heap()->CreateCode(
desc,
Code::ComputeFlags(Code::STUB),
Handle<Code>())->ToObjectChecked();
......@@ -598,7 +598,7 @@ TEST(MIPS7) {
CodeDesc desc;
assm.GetCode(&desc);
Object* code = HEAP->CreateCode(
Object* code = CcTest::heap()->CreateCode(
desc,
Code::ComputeFlags(Code::STUB),
Handle<Code>())->ToObjectChecked();
......@@ -697,7 +697,7 @@ TEST(MIPS8) {
CodeDesc desc;
assm.GetCode(&desc);
Object* code = HEAP->CreateCode(
Object* code = CcTest::heap()->CreateCode(
desc,
Code::ComputeFlags(Code::STUB),
Handle<Code>())->ToObjectChecked();
......@@ -745,7 +745,7 @@ TEST(MIPS9) {
CodeDesc desc;
assm.GetCode(&desc);
Object* code = HEAP->CreateCode(
Object* code = CcTest::heap()->CreateCode(
desc,
Code::ComputeFlags(Code::STUB),
Handle<Code>())->ToObjectChecked();
......@@ -805,7 +805,7 @@ TEST(MIPS10) {
CodeDesc desc;
assm.GetCode(&desc);
Object* code = HEAP->CreateCode(
Object* code = CcTest::heap()->CreateCode(
desc,
Code::ComputeFlags(Code::STUB),
Handle<Code>())->ToObjectChecked();
......@@ -938,7 +938,7 @@ TEST(MIPS11) {
CodeDesc desc;
assm.GetCode(&desc);
Object* code = HEAP->CreateCode(
Object* code = CcTest::heap()->CreateCode(
desc,
Code::ComputeFlags(Code::STUB),
Handle<Code>())->ToObjectChecked();
......@@ -1043,7 +1043,7 @@ TEST(MIPS12) {
CodeDesc desc;
assm.GetCode(&desc);
Object* code = HEAP->CreateCode(
Object* code = CcTest::heap()->CreateCode(
desc,
Code::ComputeFlags(Code::STUB),
Handle<Code>())->ToObjectChecked();
......@@ -1100,7 +1100,7 @@ TEST(MIPS13) {
CodeDesc desc;
assm.GetCode(&desc);
Object* code = HEAP->CreateCode(
Object* code = CcTest::heap()->CreateCode(
desc,
Code::ComputeFlags(Code::STUB),
Handle<Code>())->ToObjectChecked();
......@@ -1221,7 +1221,7 @@ TEST(MIPS14) {
CodeDesc desc;
assm.GetCode(&desc);
Object* code = HEAP->CreateCode(
Object* code = CcTest::heap()->CreateCode(
desc,
Code::ComputeFlags(Code::STUB),
Handle<Code>())->ToObjectChecked();
......
......@@ -317,7 +317,7 @@ TEST(Regression236) {
v8::HandleScope scope(CcTest::isolate());
Handle<Script> script = factory->NewScript(factory->empty_string());
script->set_source(HEAP->undefined_value());
script->set_source(CcTest::heap()->undefined_value());
CHECK_EQ(-1, GetScriptLineNumber(script, 0));
CHECK_EQ(-1, GetScriptLineNumber(script, 100));
CHECK_EQ(-1, GetScriptLineNumber(script, -1));
......
......@@ -953,7 +953,7 @@ TEST(FunctionCallSample) {
v8::HandleScope scope(env->GetIsolate());
// Collect garbage that might have be generated while installing extensions.
HEAP->CollectAllGarbage(Heap::kNoGCFlags);
CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
v8::Script::Compile(v8::String::New(call_function_test_source))->Run();
v8::Local<v8::Function> function = v8::Local<v8::Function>::Cast(
......
......@@ -443,11 +443,11 @@ void CheckDebuggerUnloaded(bool check_functions) {
CHECK_EQ(NULL, CcTest::i_isolate()->debug()->debug_info_list_);
// Collect garbage to ensure weak handles are cleared.
HEAP->CollectAllGarbage(Heap::kNoGCFlags);
HEAP->CollectAllGarbage(Heap::kMakeHeapIterableMask);
CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
CcTest::heap()->CollectAllGarbage(Heap::kMakeHeapIterableMask);
// Iterate the head and check that there are no debugger related objects left.
HeapIterator iterator(HEAP);
HeapIterator iterator(CcTest::heap());
for (HeapObject* obj = iterator.next(); obj != NULL; obj = iterator.next()) {
CHECK(!obj->IsDebugInfo());
CHECK(!obj->IsBreakPointInfo());
......@@ -961,10 +961,10 @@ static void DebugEventBreakPointCollectGarbage(
break_point_hit_count++;
if (break_point_hit_count % 2 == 0) {
// Scavenge.
HEAP->CollectGarbage(v8::internal::NEW_SPACE);
CcTest::heap()->CollectGarbage(v8::internal::NEW_SPACE);
} else {
// Mark sweep compact.
HEAP->CollectAllGarbage(Heap::kNoGCFlags);
CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
}
}
}
......@@ -985,7 +985,7 @@ static void DebugEventBreak(
// Run the garbage collector to enforce heap verification if option
// --verify-heap is set.
HEAP->CollectGarbage(v8::internal::NEW_SPACE);
CcTest::heap()->CollectGarbage(v8::internal::NEW_SPACE);
// Set the break flag again to come back here as soon as possible.
v8::Debug::DebugBreak(CcTest::isolate());
......@@ -1450,12 +1450,12 @@ static void CallAndGC(v8::Local<v8::Object> recv,
CHECK_EQ(1 + i * 3, break_point_hit_count);
// Scavenge and call function.
HEAP->CollectGarbage(v8::internal::NEW_SPACE);
CcTest::heap()->CollectGarbage(v8::internal::NEW_SPACE);
f->Call(recv, 0, NULL);
CHECK_EQ(2 + i * 3, break_point_hit_count);
// Mark sweep (and perhaps compact) and call function.
HEAP->CollectAllGarbage(Heap::kNoGCFlags);
CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
f->Call(recv, 0, NULL);
CHECK_EQ(3 + i * 3, break_point_hit_count);
}
......@@ -2259,7 +2259,7 @@ TEST(ScriptBreakPointLineTopLevel) {
}
f = v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("f")));
HEAP->CollectAllGarbage(Heap::kNoGCFlags);
CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
SetScriptBreakPointByNameFromJS("test.html", 3, -1);
......@@ -6547,7 +6547,7 @@ TEST(ScriptCollectedEvent) {
// Do garbage collection to ensure that only the script in this test will be
// collected afterwards.
HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
script_collected_count = 0;
v8::Debug::SetDebugEventListener2(DebugEventScriptCollectedEvent);
......@@ -6558,7 +6558,7 @@ TEST(ScriptCollectedEvent) {
// Do garbage collection to collect the script above which is no longer
// referenced.
HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
CHECK_EQ(2, script_collected_count);
......@@ -6609,7 +6609,7 @@ TEST(ScriptCollectedEventContext) {
// Do garbage collection to ensure that only the script in this test will be
// collected afterwards.
HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
v8::Debug::SetMessageHandler2(ScriptCollectedMessageHandler);
v8::Script::Compile(v8::String::New("eval('a=1')"))->Run();
......@@ -6626,7 +6626,7 @@ TEST(ScriptCollectedEventContext) {
// Do garbage collection to collect the script above which is no longer
// referenced.
HEAP->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
CcTest::heap()->CollectAllGarbage(Heap::kAbortIncrementalMarkingMask);
CHECK_EQ(2, script_collected_message_count);
......
......@@ -143,7 +143,7 @@ void DeclarationContext::Check(const char* source,
InitializeIfNeeded();
// A retry after a GC may pollute the counts, so perform gc now
// to avoid that.
HEAP->CollectGarbage(v8::internal::NEW_SPACE);
CcTest::heap()->CollectGarbage(v8::internal::NEW_SPACE);
HandleScope scope(CcTest::isolate());
TryCatch catcher;
catcher.SetVerbose(true);
......@@ -169,7 +169,8 @@ void DeclarationContext::Check(const char* source,
CHECK_EQ(value, catcher.Exception());
}
}
HEAP->CollectAllAvailableGarbage(); // Clean slate for the next test.
// Clean slate for the next test.
CcTest::heap()->CollectAllAvailableGarbage();
}
......
......@@ -104,7 +104,7 @@ class AllowNativesSyntaxNoInliningNoConcurrent {
// Abort any ongoing incremental marking to make sure that all weak global
// handle callbacks are processed.
static void NonIncrementalGC() {
HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask);
CcTest::heap()->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask);
}
......
......@@ -50,13 +50,13 @@ TEST(ObjectHashTable) {
table = PutIntoObjectHashTable(table, a, b);
CHECK_EQ(table->NumberOfElements(), 1);
CHECK_EQ(table->Lookup(*a), *b);
CHECK_EQ(table->Lookup(*b), HEAP->the_hole_value());
CHECK_EQ(table->Lookup(*b), CcTest::heap()->the_hole_value());
// Keys still have to be valid after objects were moved.
HEAP->CollectGarbage(NEW_SPACE);
CcTest::heap()->CollectGarbage(NEW_SPACE);
CHECK_EQ(table->NumberOfElements(), 1);
CHECK_EQ(table->Lookup(*a), *b);
CHECK_EQ(table->Lookup(*b), HEAP->the_hole_value());
CHECK_EQ(table->Lookup(*b), CcTest::heap()->the_hole_value());
// Keys that are overwritten should not change number of elements.
table = PutIntoObjectHashTable(table, a, factory->NewJSArray(13));
......@@ -67,7 +67,7 @@ TEST(ObjectHashTable) {
table = PutIntoObjectHashTable(table, a, factory->the_hole_value());
CHECK_EQ(table->NumberOfElements(), 0);
CHECK_EQ(table->NumberOfDeletedElements(), 1);
CHECK_EQ(table->Lookup(*a), HEAP->the_hole_value());
CHECK_EQ(table->Lookup(*a), CcTest::heap()->the_hole_value());
// Keys should map back to their respective values and also should get
// an identity hash code generated.
......@@ -87,7 +87,7 @@ TEST(ObjectHashTable) {
Handle<JSReceiver> key = factory->NewJSArray(7);
CHECK(key->GetIdentityHash(ALLOW_CREATION)->ToObjectChecked()->IsSmi());
CHECK_EQ(table->FindEntry(*key), ObjectHashTable::kNotFound);
CHECK_EQ(table->Lookup(*key), HEAP->the_hole_value());
CHECK_EQ(table->Lookup(*key), CcTest::heap()->the_hole_value());
CHECK(key->GetIdentityHash(OMIT_CREATION)->ToObjectChecked()->IsSmi());
}
......@@ -95,8 +95,9 @@ TEST(ObjectHashTable) {
// should not get an identity hash code generated.
for (int i = 0; i < 100; i++) {
Handle<JSReceiver> key = factory->NewJSArray(7);
CHECK_EQ(table->Lookup(*key), HEAP->the_hole_value());
CHECK_EQ(key->GetIdentityHash(OMIT_CREATION), HEAP->undefined_value());
CHECK_EQ(table->Lookup(*key), CcTest::heap()->the_hole_value());
CHECK_EQ(key->GetIdentityHash(OMIT_CREATION),
CcTest::heap()->undefined_value());
}
}
......@@ -170,8 +171,8 @@ TEST(ObjectHashSetCausesGC) {
// Simulate a full heap so that generating an identity hash code
// in subsequent calls will request GC.
SimulateFullSpace(HEAP->new_space());
SimulateFullSpace(HEAP->old_pointer_space());
SimulateFullSpace(CcTest::heap()->new_space());
SimulateFullSpace(CcTest::heap()->old_pointer_space());
// Calling Contains() should not cause GC ever.
CHECK(!table->Contains(*key));
......@@ -203,8 +204,8 @@ TEST(ObjectHashTableCausesGC) {
// Simulate a full heap so that generating an identity hash code
// in subsequent calls will request GC.
SimulateFullSpace(HEAP->new_space());
SimulateFullSpace(HEAP->old_pointer_space());
SimulateFullSpace(CcTest::heap()->new_space());
SimulateFullSpace(CcTest::heap()->old_pointer_space());
// Calling Lookup() should not cause GC ever.
CHECK(table->Lookup(*key)->IsTheHole());
......
......@@ -401,7 +401,7 @@ TEST(DisasmX64) {
CodeDesc desc;
assm.GetCode(&desc);
Object* code = HEAP->CreateCode(
Object* code = CcTest::heap()->CreateCode(
desc,
Code::ComputeFlags(Code::STUB),
Handle<Code>())->ToObjectChecked();
......
......@@ -82,7 +82,7 @@ static void CheckFunctionName(v8::Handle<v8::Script> script,
isolate->debug()->PrepareForBreakPoints();
Object* shared_func_info_ptr =
isolate->debug()->FindSharedFunctionInfoInScript(i_script, func_pos);
CHECK(shared_func_info_ptr != HEAP->undefined_value());
CHECK(shared_func_info_ptr != CcTest::heap()->undefined_value());
Handle<SharedFunctionInfo> shared_func_info(
SharedFunctionInfo::cast(shared_func_info_ptr));
......
......@@ -87,18 +87,18 @@ class TestObjectVisitor : public ObjectVisitor {
TEST(IterateObjectGroupsOldApi) {
CcTest::InitializeVM();
GlobalHandles* global_handles = CcTest::i_isolate()->global_handles();
Heap* heap = CcTest::heap();
v8::HandleScope handle_scope(CcTest::isolate());
Handle<Object> g1s1 =
global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked());
global_handles->Create(heap->AllocateFixedArray(1)->ToObjectChecked());
Handle<Object> g1s2 =
global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked());
global_handles->Create(heap->AllocateFixedArray(1)->ToObjectChecked());
Handle<Object> g2s1 =
global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked());
global_handles->Create(heap->AllocateFixedArray(1)->ToObjectChecked());
Handle<Object> g2s2 =
global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked());
global_handles->Create(heap->AllocateFixedArray(1)->ToObjectChecked());
TestRetainedObjectInfo info1;
TestRetainedObjectInfo info2;
......@@ -182,18 +182,19 @@ TEST(IterateObjectGroupsOldApi) {
TEST(IterateObjectGroups) {
CcTest::InitializeVM();
GlobalHandles* global_handles = CcTest::i_isolate()->global_handles();
Heap* heap = CcTest::heap();
v8::HandleScope handle_scope(CcTest::isolate());
Handle<Object> g1s1 =
global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked());
global_handles->Create(heap->AllocateFixedArray(1)->ToObjectChecked());
Handle<Object> g1s2 =
global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked());
global_handles->Create(heap->AllocateFixedArray(1)->ToObjectChecked());
Handle<Object> g2s1 =
global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked());
global_handles->Create(heap->AllocateFixedArray(1)->ToObjectChecked());
Handle<Object> g2s2 =
global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked());
global_handles->Create(heap->AllocateFixedArray(1)->ToObjectChecked());
TestRetainedObjectInfo info1;
TestRetainedObjectInfo info2;
......@@ -276,23 +277,24 @@ TEST(IterateObjectGroups) {
TEST(ImplicitReferences) {
CcTest::InitializeVM();
GlobalHandles* global_handles = CcTest::i_isolate()->global_handles();
Heap* heap = CcTest::heap();
v8::HandleScope handle_scope(CcTest::isolate());
Handle<Object> g1s1 =
global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked());
global_handles->Create(heap->AllocateFixedArray(1)->ToObjectChecked());
Handle<Object> g1c1 =
global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked());
global_handles->Create(heap->AllocateFixedArray(1)->ToObjectChecked());
Handle<Object> g1c2 =
global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked());
global_handles->Create(heap->AllocateFixedArray(1)->ToObjectChecked());
Handle<Object> g2s1 =
global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked());
global_handles->Create(heap->AllocateFixedArray(1)->ToObjectChecked());
Handle<Object> g2s2 =
global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked());
global_handles->Create(heap->AllocateFixedArray(1)->ToObjectChecked());
Handle<Object> g2c1 =
global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked());
global_handles->Create(heap->AllocateFixedArray(1)->ToObjectChecked());
global_handles->SetObjectGroupId(g1s1.location(), UniqueId(1));
global_handles->SetObjectGroupId(g2s1.location(), UniqueId(2));
......
......@@ -505,7 +505,7 @@ TEST(HeapSnapshotAddressReuse) {
CompileRun(
"for (var i = 0; i < 10000; ++i)\n"
" a[i] = new A();\n");
HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags);
const v8::HeapSnapshot* snapshot2 =
heap_profiler->TakeHeapSnapshot(v8_str("snapshot2"));
......@@ -549,7 +549,7 @@ TEST(HeapEntryIdsAndArrayShift) {
"for (var i = 0; i < 1; ++i)\n"
" a.shift();\n");
HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags);
const v8::HeapSnapshot* snapshot2 =
heap_profiler->TakeHeapSnapshot(v8_str("s2"));
......@@ -594,7 +594,7 @@ TEST(HeapEntryIdsAndGC) {
heap_profiler->TakeHeapSnapshot(s1_str);
CHECK(ValidateSnapshot(snapshot1));
HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags);
const v8::HeapSnapshot* snapshot2 =
heap_profiler->TakeHeapSnapshot(s2_str);
......@@ -901,7 +901,7 @@ TEST(HeapSnapshotObjectsStats) {
// We have to call GC 6 times. In other case the garbage will be
// the reason of flakiness.
for (int i = 0; i < 6; ++i) {
HEAP->CollectAllGarbage(i::Heap::kNoGCFlags);
CcTest::heap()->CollectAllGarbage(i::Heap::kNoGCFlags);
}
v8::SnapshotObjectId initial_id;
......
This diff is collapsed.
......@@ -439,7 +439,7 @@ TEST(EquivalenceOfLoggingAndTraversal) {
" (function a(j) { return function b() { return j; } })(100);\n"
"})(this);");
logger->StopProfiler();
HEAP->CollectAllGarbage(i::Heap::kMakeHeapIterableMask);
CcTest::heap()->CollectAllGarbage(i::Heap::kMakeHeapIterableMask);
logger->StringEvent("test-logging-done", "");
// Iterate heap to find compiled functions, will write to log.
......
......@@ -81,7 +81,8 @@ TEST(Promotion) {
// from new space.
FLAG_gc_global = true;
FLAG_always_compact = true;
HEAP->ConfigureHeap(2*256*KB, 8*MB, 8*MB);
Heap* heap = CcTest::heap();
heap->ConfigureHeap(2*256*KB, 8*MB, 8*MB);
CcTest::InitializeVM();
......@@ -91,23 +92,23 @@ TEST(Promotion) {
int array_size =
(Page::kMaxNonCodeHeapObjectSize - FixedArray::kHeaderSize) /
(kPointerSize * 4);
Object* obj = HEAP->AllocateFixedArray(array_size)->ToObjectChecked();
Object* obj = heap->AllocateFixedArray(array_size)->ToObjectChecked();
Handle<FixedArray> array(FixedArray::cast(obj));
// Array should be in the new space.
CHECK(HEAP->InSpace(*array, NEW_SPACE));
CHECK(heap->InSpace(*array, NEW_SPACE));
// Call the m-c collector, so array becomes an old object.
HEAP->CollectGarbage(OLD_POINTER_SPACE);
heap->CollectGarbage(OLD_POINTER_SPACE);
// Array now sits in the old space
CHECK(HEAP->InSpace(*array, OLD_POINTER_SPACE));
CHECK(heap->InSpace(*array, OLD_POINTER_SPACE));
}
TEST(NoPromotion) {
HEAP->ConfigureHeap(2*256*KB, 8*MB, 8*MB);
CcTest::heap()->ConfigureHeap(2*256*KB, 8*MB, 8*MB);
// Test the situation that some objects in new space are promoted to
// the old space
......@@ -116,24 +117,24 @@ TEST(NoPromotion) {
v8::HandleScope sc(CcTest::isolate());
// Do a mark compact GC to shrink the heap.
HEAP->CollectGarbage(OLD_POINTER_SPACE);
CcTest::heap()->CollectGarbage(OLD_POINTER_SPACE);
// Allocate a big Fixed array in the new space.
int length = (Page::kMaxNonCodeHeapObjectSize -
FixedArray::kHeaderSize) / (2 * kPointerSize);
Object* obj = CcTest::i_isolate()->heap()->AllocateFixedArray(length)->
Object* obj = CcTest::heap()->AllocateFixedArray(length)->
ToObjectChecked();
Handle<FixedArray> array(FixedArray::cast(obj));
// Array still stays in the new space.
CHECK(HEAP->InSpace(*array, NEW_SPACE));
CHECK(CcTest::heap()->InSpace(*array, NEW_SPACE));
// Allocate objects in the old space until out of memory.
FixedArray* host = *array;
while (true) {
Object* obj;
{ MaybeObject* maybe_obj = HEAP->AllocateFixedArray(100, TENURED);
{ MaybeObject* maybe_obj = CcTest::heap()->AllocateFixedArray(100, TENURED);
if (!maybe_obj->ToObject(&obj)) break;
}
......@@ -142,7 +143,7 @@ TEST(NoPromotion) {
}
// Call mark compact GC, and it should pass.
HEAP->CollectGarbage(OLD_POINTER_SPACE);
CcTest::heap()->CollectGarbage(OLD_POINTER_SPACE);
}
......@@ -255,15 +256,15 @@ TEST(MapCompact) {
Handle<Map> map = CreateMap();
map->set_prototype(*root);
root = factory->NewJSObjectFromMap(map);
} while (HEAP->map_space()->MapPointersEncodable());
} while (CcTest::heap()->map_space()->MapPointersEncodable());
}
// Now, as we don't have any handles to just allocated maps, we should
// be able to trigger map compaction.
// To give an additional chance to fail, try to force compaction which
// should be impossible right now.
HEAP->CollectAllGarbage(Heap::kForceCompactionMask);
CcTest::heap()->CollectAllGarbage(Heap::kForceCompactionMask);
// And now map pointers should be encodable again.
CHECK(HEAP->map_space()->MapPointersEncodable());
CHECK(CcTest::heap()->map_space()->MapPointersEncodable());
}
#endif
......@@ -282,16 +283,16 @@ TEST(ObjectGroups) {
FLAG_incremental_marking = false;
CcTest::InitializeVM();
GlobalHandles* global_handles = CcTest::i_isolate()->global_handles();
Heap* heap = CcTest::heap();
NumberOfWeakCalls = 0;
v8::HandleScope handle_scope(CcTest::isolate());
Handle<Object> g1s1 =
global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked());
global_handles->Create(heap->AllocateFixedArray(1)->ToObjectChecked());
Handle<Object> g1s2 =
global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked());
global_handles->Create(heap->AllocateFixedArray(1)->ToObjectChecked());
Handle<Object> g1c1 =
global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked());
global_handles->Create(heap->AllocateFixedArray(1)->ToObjectChecked());
global_handles->MakeWeak(g1s1.location(),
reinterpret_cast<void*>(1234),
&WeakPointerCallback);
......@@ -303,11 +304,11 @@ TEST(ObjectGroups) {
&WeakPointerCallback);
Handle<Object> g2s1 =
global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked());
global_handles->Create(heap->AllocateFixedArray(1)->ToObjectChecked());
Handle<Object> g2s2 =
global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked());
global_handles->Create(heap->AllocateFixedArray(1)->ToObjectChecked());
Handle<Object> g2c1 =
global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked());
global_handles->Create(heap->AllocateFixedArray(1)->ToObjectChecked());
global_handles->MakeWeak(g2s1.location(),
reinterpret_cast<void*>(1234),
&WeakPointerCallback);
......@@ -337,7 +338,7 @@ TEST(ObjectGroups) {
Handle<HeapObject>::cast(g2s1).location(), g2_children, 1);
}
// Do a full GC
HEAP->CollectGarbage(OLD_POINTER_SPACE);
heap->CollectGarbage(OLD_POINTER_SPACE);
// All object should be alive.
CHECK_EQ(0, NumberOfWeakCalls);
......@@ -365,7 +366,7 @@ TEST(ObjectGroups) {
Handle<HeapObject>::cast(g2s1).location(), g2_children, 1);
}
HEAP->CollectGarbage(OLD_POINTER_SPACE);
heap->CollectGarbage(OLD_POINTER_SPACE);
// All objects should be gone. 5 global handles in total.
CHECK_EQ(5, NumberOfWeakCalls);
......@@ -378,7 +379,7 @@ TEST(ObjectGroups) {
reinterpret_cast<void*>(1234),
&WeakPointerCallback);
HEAP->CollectGarbage(OLD_POINTER_SPACE);
heap->CollectGarbage(OLD_POINTER_SPACE);
CHECK_EQ(7, NumberOfWeakCalls);
}
......@@ -413,8 +414,8 @@ TEST(EmptyObjectGroups) {
v8::HandleScope handle_scope(CcTest::isolate());
Handle<Object> object =
global_handles->Create(HEAP->AllocateFixedArray(1)->ToObjectChecked());
Handle<Object> object = global_handles->Create(
CcTest::heap()->AllocateFixedArray(1)->ToObjectChecked());
TestRetainedObjectInfo info;
global_handles->AddObjectGroup(NULL, 0, &info);
......
......@@ -444,7 +444,7 @@ TEST(ObservationWeakMap) {
CHECK_EQ(1, NumberOfElements(callbackInfoMap));
CHECK_EQ(1, NumberOfElements(objectInfoMap));
CHECK_EQ(1, NumberOfElements(notifierObjectInfoMap));
HEAP->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask);
i_isolate->heap()->CollectAllGarbage(i::Heap::kAbortIncrementalMarkingMask);
CHECK_EQ(0, NumberOfElements(callbackInfoMap));
CHECK_EQ(0, NumberOfElements(objectInfoMap));
CHECK_EQ(0, NumberOfElements(notifierObjectInfoMap));
......
......@@ -399,7 +399,7 @@ class TestSetup {
TEST(RecordTickSample) {
TestSetup test_setup;
CpuProfilesCollection profiles(CcTest::i_isolate()->heap());
CpuProfilesCollection profiles(CcTest::heap());
profiles.StartProfiling("", 1, false);
ProfileGenerator generator(&profiles);
CodeEntry* entry1 = profiles.NewCodeEntry(i::Logger::FUNCTION_TAG, "aaa");
......@@ -465,7 +465,7 @@ static void CheckNodeIds(ProfileNode* node, int* expectedId) {
TEST(SampleIds) {
TestSetup test_setup;
CpuProfilesCollection profiles(CcTest::i_isolate()->heap());
CpuProfilesCollection profiles(CcTest::heap());
profiles.StartProfiling("", 1, true);
ProfileGenerator generator(&profiles);
CodeEntry* entry1 = profiles.NewCodeEntry(i::Logger::FUNCTION_TAG, "aaa");
......@@ -513,7 +513,7 @@ TEST(SampleIds) {
TEST(NoSamples) {
TestSetup test_setup;
CpuProfilesCollection profiles(CcTest::i_isolate()->heap());
CpuProfilesCollection profiles(CcTest::heap());
profiles.StartProfiling("", 1, false);
ProfileGenerator generator(&profiles);
CodeEntry* entry1 = profiles.NewCodeEntry(i::Logger::FUNCTION_TAG, "aaa");
......@@ -652,7 +652,7 @@ TEST(RecordStackTraceAtStartProfiling) {
TEST(Issue51919) {
CpuProfilesCollection collection(CcTest::i_isolate()->heap());
CpuProfilesCollection collection(CcTest::heap());
i::EmbeddedVector<char*,
CpuProfilesCollection::kMaxSimultaneousProfiles> titles;
for (int i = 0; i < CpuProfilesCollection::kMaxSimultaneousProfiles; ++i) {
......
......@@ -294,11 +294,11 @@ static void SanityCheck() {
Isolate* isolate = CcTest::i_isolate();
v8::HandleScope scope(CcTest::isolate());
#ifdef VERIFY_HEAP
HEAP->Verify();
CcTest::heap()->Verify();
#endif
CHECK(isolate->global_object()->IsJSObject());
CHECK(isolate->native_context()->IsContext());
CHECK(HEAP->string_table()->IsStringTable());
CHECK(CcTest::heap()->string_table()->IsStringTable());
CHECK(!isolate->factory()->InternalizeOneByteString(
STATIC_ASCII_VECTOR("Empty"))->IsFailure());
}
......
......@@ -72,7 +72,7 @@ TEST(Page) {
Page* p = Page::FromAddress(page_start);
// Initialized Page has heap pointer, normally set by memory_allocator.
p->heap_ = HEAP;
p->heap_ = CcTest::heap();
CHECK(p->address() == page_start);
CHECK(p->is_valid());
......@@ -323,8 +323,8 @@ TEST(NewSpace) {
NewSpace new_space(heap);
CHECK(new_space.SetUp(HEAP->ReservedSemiSpaceSize(),
HEAP->ReservedSemiSpaceSize()));
CHECK(new_space.SetUp(CcTest::heap()->ReservedSemiSpaceSize(),
CcTest::heap()->ReservedSemiSpaceSize()));
CHECK(new_space.HasBeenSetUp());
while (new_space.Available() >= Page::kMaxNonCodeHeapObjectSize) {
......@@ -372,7 +372,7 @@ TEST(OldSpace) {
TEST(LargeObjectSpace) {
v8::V8::Initialize();
LargeObjectSpace* lo = HEAP->lo_space();
LargeObjectSpace* lo = CcTest::heap()->lo_space();
CHECK(lo != NULL);
int lo_size = Page::kPageSize;
......
......@@ -290,7 +290,7 @@ ConsStringGenerationData::ConsStringGenerationData(bool long_blocks,
rng_.init();
InitializeBuildingBlocks(
building_blocks_, kNumberOfBuildingBlocks, long_blocks, &rng_, zone);
empty_string_ = CcTest::i_isolate()->heap()->empty_string();
empty_string_ = CcTest::heap()->empty_string();
Reset();
}
......
......@@ -37,8 +37,8 @@ TEST(Create) {
#endif
}
HEAP->PerformScavenge();
HEAP->CollectAllGarbage(Heap::kNoGCFlags);
CcTest::heap()->PerformScavenge();
CcTest::heap()->CollectAllGarbage(Heap::kNoGCFlags);
// All symbols should be distinct.
for (int i = 0; i < kNumSymbols; ++i) {
......
......@@ -117,7 +117,7 @@ class ThreadB : public v8::internal::Thread {
v8::Context::Scope context_scope(context);
// Clear the caches by forcing major GC.
HEAP->CollectAllGarbage(v8::internal::Heap::kNoGCFlags);
CcTest::heap()->CollectAllGarbage(v8::internal::Heap::kNoGCFlags);
turn = SECOND_TIME_FILL_CACHE;
break;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment