Chromium Code Reviews| Index: src/mark-compact.cc |
| diff --git a/src/mark-compact.cc b/src/mark-compact.cc |
| index 516787de1c4b9c2dd9e9767a3fc39aac30938024..37719db458ba6177e9b7e8ca3cd9a5f3a5667576 100644 |
| --- a/src/mark-compact.cc |
| +++ b/src/mark-compact.cc |
| @@ -2494,12 +2494,12 @@ void MarkCompactCollector::EvacuateNewSpace() { |
| void MarkCompactCollector::EvacuateLiveObjectsFromPage(Page* p) { |
| AlwaysAllocateScope always_allocate; |
| - |
| - ASSERT(p->IsEvacuationCandidate() && !p->WasSwept()); |
| - |
| PagedSpace* space = static_cast<PagedSpace*>(p->owner()); |
| - |
| + ASSERT(p->IsEvacuationCandidate() && |
| + !p->WasSweptPrecisely() && |
|
Erik Corry
2011/08/25 09:19:48
I think it makes sense to have a
bool WasSwept()
Michael Starzinger
2011/08/25 09:33:03
Done.
|
| + !p->WasSweptConservatively()); |
| MarkBit::CellType* cells = p->markbits()->cells(); |
| + p->MarkSweptPrecisely(); |
| int last_cell_index = |
| Bitmap::IndexToCell( |
| @@ -2536,6 +2536,9 @@ void MarkCompactCollector::EvacuateLiveObjectsFromPage(Page* p) { |
| space->identity()); |
| ASSERT(object->map_word().IsForwardingAddress()); |
| } |
| + |
| + // Clear marking bits for current cell. |
| + cells[cell_index] = 0; |
| } |
| } |
| @@ -2613,10 +2616,11 @@ enum SweepingMode { |
| // Slots in live objects pointing into evacuation candidates are updated |
| // if requested. |
| static void SweepPrecisely(PagedSpace* space, Page* p, SweepingMode mode) { |
| - ASSERT(!p->IsEvacuationCandidate() && !p->WasSwept()); |
| - ASSERT(!p->IsFlagSet(MemoryChunk::WAS_SWEPT_CONSERVATIVELY)); |
| + ASSERT(!p->IsEvacuationCandidate() && |
| + !p->WasSweptPrecisely() && |
| + !p->WasSweptConservatively()); |
| MarkBit::CellType* cells = p->markbits()->cells(); |
| - p->MarkSwept(); |
| + p->MarkSweptPrecisely(); |
| int last_cell_index = |
| Bitmap::IndexToCell( |
| @@ -2711,6 +2715,10 @@ void MarkCompactCollector::EvacuateNewSpaceAndCandidates() { |
| SlotsBuffer::SizeOfChain(p->slots_buffer())); |
| } |
| } else { |
| + if (FLAG_gc_verbose) { |
| + PrintF("Sweeping 0x%" V8PRIxPTR " during evacuation.\n", |
| + reinterpret_cast<intptr_t>(p)); |
| + } |
| PagedSpace* space = static_cast<PagedSpace*>(p->owner()); |
| p->ClearFlag(MemoryChunk::RESCAN_ON_EVACUATION); |
| SweepPrecisely(space, p, SWEEP_AND_UPDATE_SLOTS); |
| @@ -2761,8 +2769,6 @@ void MarkCompactCollector::EvacuateNewSpaceAndCandidates() { |
| p->set_scan_on_scavenge(false); |
| slots_buffer_allocator_.DeallocateChain(p->slots_buffer_address()); |
| p->ClearEvacuationCandidate(); |
| - p->MarkSwept(); |
| - p->ClearFlag(MemoryChunk::WAS_SWEPT_CONSERVATIVELY); |
| } |
| evacuation_candidates_.Rewind(0); |
| compacting_ = false; |
| @@ -3093,9 +3099,11 @@ static inline Address StartOfLiveObject(Address block_address, uint32_t cell) { |
| // memory that can be ignored when scanning. Dead objects other than free |
| // spaces will not contain the free space map. |
| intptr_t MarkCompactCollector::SweepConservatively(PagedSpace* space, Page* p) { |
| - ASSERT(!p->IsEvacuationCandidate() && !p->WasSwept()); |
| + ASSERT(!p->IsEvacuationCandidate() && |
| + !p->WasSweptPrecisely() && |
| + !p->WasSweptConservatively()); |
| MarkBit::CellType* cells = p->markbits()->cells(); |
| - p->SetFlag(MemoryChunk::WAS_SWEPT_CONSERVATIVELY); |
| + p->MarkSweptConservatively(); |
| int last_cell_index = |
| Bitmap::IndexToCell( |
| @@ -3189,10 +3197,15 @@ void MarkCompactCollector::SweepSpace(PagedSpace* space, |
| intptr_t freed_bytes = 0; |
| intptr_t newspace_size = space->heap()->new_space()->Size(); |
| + bool lazy_sweeping_active = false; |
| while (it.has_next()) { |
| Page* p = it.next(); |
| + // Clear sweeping flags indicating that marking bits are still intact. |
| + p->ClearSweptPrecisely(); |
| + p->ClearSweptConservatively(); |
| + |
| if (p->IsEvacuationCandidate()) { |
| ASSERT(evacuation_candidates_.length() > 0); |
| continue; |
| @@ -3203,17 +3216,30 @@ void MarkCompactCollector::SweepSpace(PagedSpace* space, |
| continue; |
| } |
| + if (lazy_sweeping_active) { |
| + if (FLAG_gc_verbose) { |
| + PrintF("Sweeping 0x%" V8PRIxPTR " lazily postponed.\n", |
| + reinterpret_cast<intptr_t>(p)); |
| + } |
| + continue; |
| + } |
| + |
| + if (FLAG_gc_verbose) { |
| + PrintF("Sweeping 0x%" V8PRIxPTR " with sweeper %d.\n", |
| + reinterpret_cast<intptr_t>(p), |
| + sweeper); |
| + } |
| + |
| switch (sweeper) { |
| case CONSERVATIVE: { |
| SweepConservatively(space, p); |
| break; |
| } |
| case LAZY_CONSERVATIVE: { |
| - Page* next_page = p->next_page(); |
| freed_bytes += SweepConservatively(space, p); |
| if (freed_bytes >= newspace_size && p != space->LastPage()) { |
| - space->SetPagesToSweep(next_page, space->LastPage()); |
| - return; |
| + space->SetPagesToSweep(p->next_page(), space->LastPage()); |
| + lazy_sweeping_active = true; |
| } |
| break; |
| } |