Simplify test-mark-compact/NoPromotion test.

R=svenpanne@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@17398 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent a85c825b
...@@ -73,33 +73,23 @@ TEST(MarkingDeque) { ...@@ -73,33 +73,23 @@ TEST(MarkingDeque) {
TEST(Promotion) { TEST(Promotion) {
// This test requires compaction. If compaction is turned off, we
// skip the entire test.
if (FLAG_never_compact) return;
CcTest::InitializeVM(); CcTest::InitializeVM();
// Ensure that we get a compacting collection so that objects are promoted
// from new space.
FLAG_gc_global = true;
FLAG_always_compact = true;
Heap* heap = CcTest::heap(); Heap* heap = CcTest::heap();
heap->ConfigureHeap(2*256*KB, 8*MB, 8*MB); heap->ConfigureHeap(2*256*KB, 1*MB, 1*MB);
v8::HandleScope sc(CcTest::isolate()); v8::HandleScope sc(CcTest::isolate());
// Allocate a fixed array in the new space. // Allocate a fixed array in the new space.
int array_size = int array_length =
(Page::kMaxNonCodeHeapObjectSize - FixedArray::kHeaderSize) / (Page::kMaxNonCodeHeapObjectSize - FixedArray::kHeaderSize) /
(kPointerSize * 4); (4 * kPointerSize);
Object* obj = heap->AllocateFixedArray(array_size)->ToObjectChecked(); Object* obj = heap->AllocateFixedArray(array_length)->ToObjectChecked();
Handle<FixedArray> array(FixedArray::cast(obj)); Handle<FixedArray> array(FixedArray::cast(obj));
// Array should be in the new space. // 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. // Call mark compact GC, so array becomes an old object.
heap->CollectGarbage(OLD_POINTER_SPACE); heap->CollectGarbage(OLD_POINTER_SPACE);
// Array now sits in the old space // Array now sits in the old space
...@@ -108,42 +98,27 @@ TEST(Promotion) { ...@@ -108,42 +98,27 @@ TEST(Promotion) {
TEST(NoPromotion) { TEST(NoPromotion) {
// Test the situation that some objects in new space are promoted to
// the old space
CcTest::InitializeVM(); CcTest::InitializeVM();
Heap* heap = CcTest::heap();
CcTest::heap()->ConfigureHeap(2*256*KB, 8*MB, 8*MB); heap->ConfigureHeap(2*256*KB, 1*MB, 1*MB);
v8::HandleScope sc(CcTest::isolate()); v8::HandleScope sc(CcTest::isolate());
// Do a mark compact GC to shrink the heap. // Allocate a big fixed array in the new space.
CcTest::heap()->CollectGarbage(OLD_POINTER_SPACE); int array_length =
(Page::kMaxNonCodeHeapObjectSize - FixedArray::kHeaderSize) /
// Allocate a big Fixed array in the new space. (2 * kPointerSize);
int length = (Page::kMaxNonCodeHeapObjectSize - Object* obj = heap->AllocateFixedArray(array_length)->ToObjectChecked();
FixedArray::kHeaderSize) / (2 * kPointerSize);
Object* obj = CcTest::heap()->AllocateFixedArray(length)->
ToObjectChecked();
Handle<FixedArray> array(FixedArray::cast(obj)); Handle<FixedArray> array(FixedArray::cast(obj));
// Array still stays in the new space. // Array should be in the new space.
CHECK(CcTest::heap()->InSpace(*array, NEW_SPACE)); CHECK(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 = CcTest::heap()->AllocateFixedArray(100, TENURED);
if (!maybe_obj->ToObject(&obj)) break;
}
host->set(0, obj); // Simulate a full old space to make promotion fail.
host = FixedArray::cast(obj); SimulateFullSpace(heap->old_pointer_space());
}
// Call mark compact GC, and it should pass. // Call mark compact GC, and it should pass.
CcTest::heap()->CollectGarbage(OLD_POINTER_SPACE); heap->CollectGarbage(OLD_POINTER_SPACE);
} }
......
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