Commit d27d2938 authored by mlippautz's avatar mlippautz Committed by Commit bot

[heap] Fix SizeOfObjects tests

Use CollectAllAvailableGarbage for initial GC.

R=hpayer@chromium.org
BUG=

Review-Url: https://codereview.chromium.org/2236403002
Cr-Commit-Position: refs/heads/master@{#38584}
parent c6e0c8e2
...@@ -1968,11 +1968,7 @@ TEST(TestSizeOfRegExpCode) { ...@@ -1968,11 +1968,7 @@ TEST(TestSizeOfRegExpCode) {
// Get initial heap size after several full GCs, which will stabilize // Get initial heap size after several full GCs, which will stabilize
// the heap size and return with sweeping finished completely. // the heap size and return with sweeping finished completely.
CcTest::heap()->CollectAllGarbage(); CcTest::heap()->CollectAllAvailableGarbage("initial cleanup");
CcTest::heap()->CollectAllGarbage();
CcTest::heap()->CollectAllGarbage();
CcTest::heap()->CollectAllGarbage();
CcTest::heap()->CollectAllGarbage();
MarkCompactCollector* collector = CcTest::heap()->mark_compact_collector(); MarkCompactCollector* collector = CcTest::heap()->mark_compact_collector();
if (collector->sweeping_in_progress()) { if (collector->sweeping_in_progress()) {
collector->EnsureSweepingCompleted(); collector->EnsureSweepingCompleted();
...@@ -2005,19 +2001,16 @@ TEST(TestSizeOfRegExpCode) { ...@@ -2005,19 +2001,16 @@ TEST(TestSizeOfRegExpCode) {
HEAP_TEST(TestSizeOfObjects) { HEAP_TEST(TestSizeOfObjects) {
v8::V8::Initialize(); v8::V8::Initialize();
Heap* heap = CcTest::heap();
MarkCompactCollector* collector = heap->mark_compact_collector();
// Get initial heap size after several full GCs, which will stabilize // Get initial heap size after several full GCs, which will stabilize
// the heap size and return with sweeping finished completely. // the heap size and return with sweeping finished completely.
CcTest::heap()->CollectAllGarbage(); heap->CollectAllAvailableGarbage("initial cleanup");
CcTest::heap()->CollectAllGarbage();
CcTest::heap()->CollectAllGarbage();
CcTest::heap()->CollectAllGarbage();
CcTest::heap()->CollectAllGarbage();
MarkCompactCollector* collector = CcTest::heap()->mark_compact_collector();
if (collector->sweeping_in_progress()) { if (collector->sweeping_in_progress()) {
collector->EnsureSweepingCompleted(); collector->EnsureSweepingCompleted();
} }
int initial_size = static_cast<int>(CcTest::heap()->SizeOfObjects()); int initial_size = static_cast<int>(heap->SizeOfObjects());
{ {
// Allocate objects on several different old-space pages so that // Allocate objects on several different old-space pages so that
...@@ -2026,25 +2019,22 @@ HEAP_TEST(TestSizeOfObjects) { ...@@ -2026,25 +2019,22 @@ HEAP_TEST(TestSizeOfObjects) {
AlwaysAllocateScope always_allocate(CcTest::i_isolate()); AlwaysAllocateScope always_allocate(CcTest::i_isolate());
int filler_size = static_cast<int>(FixedArray::SizeFor(8192)); int filler_size = static_cast<int>(FixedArray::SizeFor(8192));
for (int i = 1; i <= 100; i++) { for (int i = 1; i <= 100; i++) {
CcTest::heap()->AllocateFixedArray(8192, TENURED).ToObjectChecked(); heap->AllocateFixedArray(8192, TENURED).ToObjectChecked();
CHECK_EQ(initial_size + i * filler_size, CHECK_EQ(initial_size + i * filler_size,
static_cast<int>(CcTest::heap()->SizeOfObjects())); static_cast<int>(heap->SizeOfObjects()));
} }
} }
// The heap size should go back to initial size after a full GC, even // The heap size should go back to initial size after a full GC, even
// though sweeping didn't finish yet. // though sweeping didn't finish yet.
CcTest::heap()->CollectAllGarbage(); heap->CollectAllGarbage();
// Normally sweeping would not be complete here, but no guarantees. // 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()));
// Waiting for sweeper threads should not change heap size. // Waiting for sweeper threads should not change heap size.
if (collector->sweeping_in_progress()) { if (collector->sweeping_in_progress()) {
collector->EnsureSweepingCompleted(); collector->EnsureSweepingCompleted();
} }
CHECK_EQ(initial_size, static_cast<int>(CcTest::heap()->SizeOfObjects())); CHECK_EQ(initial_size, static_cast<int>(heap->SizeOfObjects()));
} }
......
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