Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(382)

Unified Diff: src/heap/mark-compact.cc

Issue 2185613002: [heap] Reland "Remove black pages and use black areas instead." (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: move check to left trimming Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/heap/mark-compact.h ('k') | src/heap/mark-compact-inl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/mark-compact.cc
diff --git a/src/heap/mark-compact.cc b/src/heap/mark-compact.cc
index 40b2484445d370f30a9dc60ba065343295f349b3..cf9ba155fed2b78558466f57d6a66638133abf23 100644
--- a/src/heap/mark-compact.cc
+++ b/src/heap/mark-compact.cc
@@ -104,30 +104,30 @@ static void VerifyMarking(Heap* heap, Address bottom, Address top) {
VerifyMarkingVisitor visitor(heap);
HeapObject* object;
Address next_object_must_be_here_or_later = bottom;
-
- for (Address current = bottom; current < top; current += kPointerSize) {
+ for (Address current = bottom; current < top;) {
object = HeapObject::FromAddress(current);
if (MarkCompactCollector::IsMarked(object)) {
CHECK(Marking::IsBlack(ObjectMarking::MarkBitFrom(object)));
CHECK(current >= next_object_must_be_here_or_later);
object->Iterate(&visitor);
next_object_must_be_here_or_later = current + object->Size();
- // The next word for sure belongs to the current object, jump over it.
+ // The object is either part of a black area of black allocation or a
+ // regular black object
+ Page* page = Page::FromAddress(current);
+ CHECK(
+ page->markbits()->AllBitsSetInRange(
+ page->AddressToMarkbitIndex(current),
+ page->AddressToMarkbitIndex(next_object_must_be_here_or_later)) ||
+ page->markbits()->AllBitsClearInRange(
+ page->AddressToMarkbitIndex(current + kPointerSize * 2),
+ page->AddressToMarkbitIndex(next_object_must_be_here_or_later)));
+ current = next_object_must_be_here_or_later;
+ } else {
current += kPointerSize;
}
}
}
-static void VerifyMarkingBlackPage(Heap* heap, Page* page) {
- CHECK(page->IsFlagSet(Page::BLACK_PAGE));
- VerifyMarkingVisitor visitor(heap);
- HeapObjectIterator it(page);
- for (HeapObject* object = it.Next(); object != NULL; object = it.Next()) {
- CHECK(Marking::IsBlack(ObjectMarking::MarkBitFrom(object)));
- object->Iterate(&visitor);
- }
-}
-
static void VerifyMarking(NewSpace* space) {
Address end = space->top();
// The bottom position is at the start of its page. Allows us to use
@@ -146,11 +146,7 @@ static void VerifyMarking(NewSpace* space) {
static void VerifyMarking(PagedSpace* space) {
for (Page* p : *space) {
- if (p->IsFlagSet(Page::BLACK_PAGE)) {
- VerifyMarkingBlackPage(space->heap(), p);
- } else {
- VerifyMarking(space->heap(), p->area_start(), p->area_end());
- }
+ VerifyMarking(space->heap(), p->area_start(), p->area_end());
}
}
@@ -409,9 +405,6 @@ void MarkCompactCollector::VerifyOmittedMapChecks() {
static void ClearMarkbitsInPagedSpace(PagedSpace* space) {
for (Page* p : *space) {
p->ClearLiveness();
- if (p->IsFlagSet(Page::BLACK_PAGE)) {
- p->ClearFlag(Page::BLACK_PAGE);
- }
}
}
@@ -435,9 +428,6 @@ void MarkCompactCollector::ClearMarkbits() {
MemoryChunk* chunk = MemoryChunk::FromAddress(obj->address());
chunk->ResetProgressBar();
chunk->ResetLiveBytes();
- if (chunk->IsFlagSet(Page::BLACK_PAGE)) {
- chunk->ClearFlag(Page::BLACK_PAGE);
- }
}
}
@@ -659,7 +649,6 @@ void MarkCompactCollector::CollectEvacuationCandidates(PagedSpace* space) {
for (Page* p : *space) {
if (p->NeverEvacuate()) continue;
- if (p->IsFlagSet(Page::BLACK_PAGE)) continue;
// Invariant: Evacuation candidates are just created when marking is
// started. This means that sweeping has finished. Furthermore, at the end
// of a GC all evacuation candidates are cleared and their slot buffers are
@@ -1913,9 +1902,7 @@ class MarkCompactCollector::EvacuateRecordOnlyVisitor final
void MarkCompactCollector::DiscoverGreyObjectsInSpace(PagedSpace* space) {
for (Page* p : *space) {
- if (!p->IsFlagSet(Page::BLACK_PAGE)) {
- DiscoverGreyObjectsOnPage(p);
- }
+ DiscoverGreyObjectsOnPage(p);
if (marking_deque()->IsFull()) return;
}
}
@@ -2932,9 +2919,8 @@ bool MarkCompactCollector::IsSlotInBlackObject(MemoryChunk* p, Address slot) {
DCHECK(owner != heap_->lo_space() && owner != nullptr);
USE(owner);
- // If we are on a black page, we cannot find the actual object start
- // easiliy. We just return true but do not set the out_object.
- if (p->IsFlagSet(Page::BLACK_PAGE)) {
+ // We may be part of a black area.
+ if (Marking::IsBlackOrGrey(ObjectMarking::MarkBitFrom(slot))) {
return true;
}
@@ -3031,27 +3017,16 @@ HeapObject* MarkCompactCollector::FindBlackObjectBySlotSlow(Address slot) {
return nullptr;
}
- if (p->IsFlagSet(Page::BLACK_PAGE)) {
- HeapObjectIterator it(p);
- HeapObject* object = nullptr;
- while ((object = it.Next()) != nullptr) {
- int size = object->Size();
- if (object->address() > slot) return nullptr;
- if (object->address() <= slot && slot < (object->address() + size)) {
- return object;
- }
- }
- } else {
- LiveObjectIterator<kBlackObjects> it(p);
- HeapObject* object = nullptr;
- while ((object = it.Next()) != nullptr) {
- int size = object->Size();
- if (object->address() > slot) return nullptr;
- if (object->address() <= slot && slot < (object->address() + size)) {
- return object;
- }
+ LiveObjectIterator<kBlackObjects> it(p);
+ HeapObject* object = nullptr;
+ while ((object = it.Next()) != nullptr) {
+ int size = object->Size();
+ if (object->address() > slot) return nullptr;
+ if (object->address() <= slot && slot < (object->address() + size)) {
+ return object;
}
}
+
return nullptr;
}
@@ -3388,7 +3363,6 @@ int MarkCompactCollector::Sweeper::RawSweep(
DCHECK(free_list_mode == IGNORE_FREE_LIST || space->identity() == OLD_SPACE ||
space->identity() == CODE_SPACE || space->identity() == MAP_SPACE);
DCHECK(!p->IsEvacuationCandidate() && !p->SweepingDone());
- DCHECK(!p->IsFlagSet(Page::BLACK_PAGE));
// Before we sweep objects on the page, we free dead array buffers which
// requires valid mark bits.
@@ -3941,7 +3915,6 @@ void MarkCompactCollector::Sweeper::AddSweepingPageSafe(AllocationSpace space,
}
void MarkCompactCollector::StartSweepSpace(PagedSpace* space) {
- Address space_top = space->top();
space->ClearStats();
int will_be_swept = 0;
@@ -3958,24 +3931,6 @@ void MarkCompactCollector::StartSweepSpace(PagedSpace* space) {
continue;
}
- // We can not sweep black pages, since all mark bits are set for these
- // pages.
- if (p->IsFlagSet(Page::BLACK_PAGE)) {
- p->ClearLiveness();
- p->concurrent_sweeping_state().SetValue(Page::kSweepingDone);
- p->ClearFlag(Page::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;
- }
-
if (p->IsFlagSet(Page::NEVER_ALLOCATE_ON_PAGE)) {
// We need to sweep the page to get it into an iterable state again. Note
// that this adds unusable memory into the free list that is later on
« no previous file with comments | « src/heap/mark-compact.h ('k') | src/heap/mark-compact-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698