Commit 8c6fedd6 authored by ulan's avatar ulan Committed by Commit bot

[heap] Add the free remainder of a black page to the free list.

BUG=chromium:615489

Review-Url: https://codereview.chromium.org/2020743002
Cr-Commit-Position: refs/heads/master@{#36587}
parent 65678bc6
......@@ -215,6 +215,8 @@ class IncrementalMarking {
bool black_allocation() { return black_allocation_; }
void StartBlackAllocationForTesting() { StartBlackAllocation(); }
private:
class Observer : public AllocationObserver {
public:
......
......@@ -3813,6 +3813,7 @@ void MarkCompactCollector::Sweeper::AddSweepingPageSafe(AllocationSpace space,
}
void MarkCompactCollector::StartSweepSpace(PagedSpace* space) {
Address space_top = space->top();
space->ClearStats();
PageIterator it(space);
......@@ -3836,7 +3837,15 @@ void MarkCompactCollector::StartSweepSpace(PagedSpace* space) {
Bitmap::Clear(p);
p->concurrent_sweeping_state().SetValue(Page::kSweepingDone);
p->ClearFlag(Page::BLACK_PAGE);
// TODO(hpayer): Free unused memory of last black page.
// Area above the high watermark is free.
Address free_start = p->HighWaterMark();
// Check if the space top was in this page, which means that the
// high watermark is not up-to-date.
if (free_start < space_top && space_top <= p->area_end()) {
free_start = space_top;
}
int size = static_cast<int>(p->area_end() - free_start);
space->Free(free_start, size);
continue;
}
......
......@@ -651,6 +651,8 @@ class MemoryChunk {
// Approximate amount of physical memory committed for this chunk.
size_t CommittedPhysicalMemory() { return high_water_mark_.Value(); }
Address HighWaterMark() { return address() + high_water_mark_.Value(); }
int progress_bar() {
DCHECK(IsFlagSet(HAS_PROGRESS_BAR));
return progress_bar_;
......
......@@ -6684,5 +6684,43 @@ TEST(Regress609761) {
CHECK_EQ(size_after, size_before + array->Size());
}
TEST(Regress615489) {
FLAG_black_allocation = true;
CcTest::InitializeVM();
v8::HandleScope scope(CcTest::isolate());
Heap* heap = CcTest::heap();
Isolate* isolate = heap->isolate();
heap->CollectAllGarbage();
i::MarkCompactCollector* collector = heap->mark_compact_collector();
i::IncrementalMarking* marking = heap->incremental_marking();
if (collector->sweeping_in_progress()) {
collector->EnsureSweepingCompleted();
}
CHECK(marking->IsMarking() || marking->IsStopped());
if (marking->IsStopped()) {
heap->StartIncrementalMarking();
}
CHECK(marking->IsMarking());
marking->StartBlackAllocationForTesting();
{
AlwaysAllocateScope always_allocate(CcTest::i_isolate());
v8::HandleScope inner(CcTest::isolate());
isolate->factory()->NewFixedArray(500, TENURED)->Size();
}
while (!marking->IsComplete()) {
marking->Step(i::MB, i::IncrementalMarking::NO_GC_VIA_STACK_GUARD);
if (marking->IsReadyToOverApproximateWeakClosure()) {
marking->FinalizeIncrementally();
}
}
CHECK(marking->IsComplete());
intptr_t size_before = heap->SizeOfObjects();
CcTest::heap()->CollectAllGarbage();
intptr_t size_after = heap->SizeOfObjects();
// Live size does not increase after garbage collection.
CHECK_LE(size_after, size_before);
}
} // namespace internal
} // namespace v8
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