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

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

Issue 2516303006: [heap] Refactor heap object iteration (Closed)
Patch Set: Add comment Created 4 years, 1 month 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/heap.cc ('k') | src/heap/spaces.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 8b1c7085c0b2fdf8190b3193b69a6059bd54e223..bad3495bbe4befe1c583ff680b66bc8a845ff213 100644
--- a/src/heap/mark-compact.cc
+++ b/src/heap/mark-compact.cc
@@ -133,7 +133,7 @@ static void VerifyMarking(NewSpace* space) {
// page->area_start() as start of range on all pages.
CHECK_EQ(space->bottom(), Page::FromAddress(space->bottom())->area_start());
- NewSpacePageRange range(space->bottom(), end);
+ PageRange range(space->bottom(), end);
for (auto it = range.begin(); it != range.end();) {
Page* page = *(it++);
Address limit = it != range.end() ? page->area_end() : end;
@@ -185,29 +185,21 @@ class VerifyEvacuationVisitor : public ObjectVisitor {
static void VerifyEvacuation(Page* page) {
VerifyEvacuationVisitor visitor;
HeapObjectIterator iterator(page);
- for (HeapObject* heap_object = iterator.Next(); heap_object != NULL;
+ for (HeapObject* heap_object = iterator.Next(); heap_object != nullptr;
heap_object = iterator.Next()) {
- // We skip free space objects.
- if (!heap_object->IsFiller()) {
- heap_object->Iterate(&visitor);
- }
+ CHECK(!heap_object->IsFiller());
+ heap_object->Iterate(&visitor);
}
}
static void VerifyEvacuation(NewSpace* space) {
VerifyEvacuationVisitor visitor;
- NewSpacePageRange range(space->bottom(), space->top());
- for (auto it = range.begin(); it != range.end();) {
- Page* page = *(it++);
- Address current = page->area_start();
- Address limit = it != range.end() ? page->area_end() : space->top();
- CHECK(limit == space->top() || !page->Contains(space->top()));
- while (current < limit) {
- HeapObject* object = HeapObject::FromAddress(current);
- object->Iterate(&visitor);
- current += object->Size();
- }
+ HeapObjectIterator iterator(space);
+ for (HeapObject* heap_object = iterator.Next(); heap_object != nullptr;
+ heap_object = iterator.Next()) {
+ CHECK(!heap_object->IsFiller());
+ heap_object->Iterate(&visitor);
}
}
@@ -332,7 +324,7 @@ void MarkCompactCollector::VerifyMarkbitsAreClean(PagedSpace* space) {
void MarkCompactCollector::VerifyMarkbitsAreClean(NewSpace* space) {
- for (Page* p : NewSpacePageRange(space->bottom(), space->top())) {
+ for (Page* p : PageRange(space->bottom(), space->top())) {
CHECK(p->markbits()->IsClean());
CHECK_EQ(0, p->LiveBytes());
}
@@ -1964,7 +1956,7 @@ void MarkCompactCollector::DiscoverGreyObjectsInSpace(PagedSpace* space) {
void MarkCompactCollector::DiscoverGreyObjectsInNewSpace() {
NewSpace* space = heap()->new_space();
- for (Page* page : NewSpacePageRange(space->bottom(), space->top())) {
+ for (Page* page : PageRange(space->bottom(), space->top())) {
DiscoverGreyObjectsOnPage(page);
if (marking_deque()->IsFull()) return;
}
@@ -3031,7 +3023,7 @@ static String* UpdateReferenceInExternalStringTableEntry(Heap* heap,
void MarkCompactCollector::EvacuateNewSpacePrologue() {
NewSpace* new_space = heap()->new_space();
// Append the list of new space pages to be processed.
- for (Page* p : NewSpacePageRange(new_space->bottom(), new_space->top())) {
+ for (Page* p : PageRange(new_space->bottom(), new_space->top())) {
newspace_evacuation_candidates_.Add(p);
}
new_space->Flip();
@@ -3817,7 +3809,7 @@ void UpdateToSpacePointersInParallel(Heap* heap, base::Semaphore* semaphore) {
heap, heap->isolate()->cancelable_task_manager(), semaphore);
Address space_start = heap->new_space()->bottom();
Address space_end = heap->new_space()->top();
- for (Page* page : NewSpacePageRange(space_start, space_end)) {
+ for (Page* page : PageRange(space_start, space_end)) {
Address start =
page->Contains(space_start) ? space_start : page->area_start();
Address end = page->Contains(space_end) ? space_end : page->area_end();
« no previous file with comments | « src/heap/heap.cc ('k') | src/heap/spaces.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698