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

Unified Diff: src/heap/spaces.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/spaces.h ('k') | src/heap/spaces-inl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/spaces.cc
diff --git a/src/heap/spaces.cc b/src/heap/spaces.cc
index bbb3402c0c29b8fa80242673f8a84a0528d26e06..3ca518685e67f3183a82cfdde4e2a524f8a836a6 100644
--- a/src/heap/spaces.cc
+++ b/src/heap/spaces.cc
@@ -29,19 +29,26 @@ HeapObjectIterator::HeapObjectIterator(PagedSpace* space)
cur_end_(nullptr),
space_(space),
page_range_(space->anchor()->next_page(), space->anchor()),
- current_page_(page_range_.begin()) {}
+ next_page_(page_range_.begin()) {}
+
+HeapObjectIterator::HeapObjectIterator(NewSpace* space)
+ : cur_addr_(nullptr),
+ cur_end_(nullptr),
+ space_(space),
+ page_range_(space->bottom(), space->top()),
+ next_page_(page_range_.begin()) {}
HeapObjectIterator::HeapObjectIterator(Page* page)
: cur_addr_(nullptr),
cur_end_(nullptr),
- space_(reinterpret_cast<PagedSpace*>(page->owner())),
+ space_(reinterpret_cast<SpaceWithInlineAllocationArea*>(page->owner())),
page_range_(page),
- current_page_(page_range_.begin()) {
+ next_page_(page_range_.begin()) {
#ifdef DEBUG
Space* owner = page->owner();
- DCHECK(owner == page->heap()->old_space() ||
- owner == page->heap()->map_space() ||
- owner == page->heap()->code_space());
+ Heap* heap = page->heap();
+ DCHECK(owner == heap->old_space() || owner == heap->map_space() ||
+ owner == heap->code_space() || owner == heap->new_space());
#endif // DEBUG
}
@@ -49,8 +56,8 @@ HeapObjectIterator::HeapObjectIterator(Page* page)
// objects. This happens at the end of the page.
bool HeapObjectIterator::AdvanceToNextPage() {
DCHECK_EQ(cur_addr_, cur_end_);
- if (current_page_ == page_range_.end()) return false;
- Page* cur_page = *(current_page_++);
+ if (next_page_ == page_range_.end()) return false;
+ Page* cur_page = *(next_page_++);
space_->heap()
->mark_compact_collector()
->sweeper()
@@ -1180,7 +1187,9 @@ void Space::AllocationStep(Address soon_object, int size) {
PagedSpace::PagedSpace(Heap* heap, AllocationSpace space,
Executability executable)
- : Space(heap, space, executable), anchor_(this), free_list_(this) {
+ : SpaceWithInlineAllocationArea(heap, space, executable),
+ anchor_(this),
+ free_list_(this) {
area_size_ = MemoryAllocator::PageAreaSize(space);
accounting_stats_.Clear();
@@ -2095,7 +2104,7 @@ void SemiSpace::set_age_mark(Address mark) {
DCHECK_EQ(Page::FromAllocationAreaAddress(mark)->owner(), this);
age_mark_ = mark;
// Mark all pages up to the one containing mark.
- for (Page* p : NewSpacePageRange(space_start(), mark)) {
+ for (Page* p : PageRange(space_start(), mark)) {
p->SetFlag(MemoryChunk::NEW_SPACE_BELOW_AGE_MARK);
}
}
« no previous file with comments | « src/heap/spaces.h ('k') | src/heap/spaces-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698