| Index: test/cctest/test-heap.cc
|
| diff --git a/test/cctest/test-heap.cc b/test/cctest/test-heap.cc
|
| index 42b5789d4d02f17f520af87c6a27c148e2b59dbc..258a2b9cc28574102dc932458d88a2423a2b09c2 100644
|
| --- a/test/cctest/test-heap.cc
|
| +++ b/test/cctest/test-heap.cc
|
| @@ -1187,6 +1187,37 @@ TEST(TestInternalWeakListsTraverseWithGC) {
|
| }
|
|
|
|
|
| +TEST(TestSizeOfObjects) {
|
| + v8::V8::Initialize();
|
| +
|
| + // 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);
|
| + CHECK(HEAP->old_pointer_space()->IsSweepingComplete());
|
| + intptr_t initial_size = HEAP->SizeOfObjects();
|
| +
|
| + {
|
| + // Allocate objects on several different old-space pages so that
|
| + // lazy sweeping kicks in for subsequent GC runs.
|
| + AlwaysAllocateScope always_allocate;
|
| + intptr_t filler_size = FixedArray::SizeFor(8192);
|
| + for (int i = 1; i <= 100; i++) {
|
| + HEAP->AllocateFixedArray(8192, TENURED)->ToObjectChecked();
|
| + CHECK_EQ(initial_size + i * filler_size, HEAP->SizeOfObjects());
|
| + }
|
| + }
|
| +
|
| + // The heap size should go back to initial size after a full GC, even
|
| + // though sweeping didn't finish yet (with a delta of about 512 words).
|
| + HEAP->CollectAllGarbage(Heap::kNoGCFlags);
|
| + CHECK(!HEAP->old_pointer_space()->IsSweepingComplete());
|
| + CHECK_EQ(initial_size, HEAP->SizeOfObjects());
|
| +}
|
| +
|
| +
|
| TEST(TestSizeOfObjectsVsHeapIteratorPrecision) {
|
| InitializeVM();
|
| HEAP->EnsureHeapIsIterable();
|
|
|