From eabb514278eef838aa8007558067194bd281b7fe Mon Sep 17 00:00:00 2001 From: mstarzinger Date: Fri, 7 Aug 2015 06:46:29 -0700 Subject: [PATCH] [heap] Remove unused support for heap iterator size function. R=hpayer@chromium.org Review URL: https://codereview.chromium.org/1281903002 Cr-Commit-Position: refs/heads/master@{#30071} --- src/globals.h | 5 ----- src/heap/heap.cc | 22 ++++++--------------- src/heap/heap.h | 2 -- src/heap/mark-compact.cc | 2 +- src/heap/spaces-inl.h | 2 +- src/heap/spaces.cc | 51 +++++++++++------------------------------------- src/heap/spaces.h | 21 +++++--------------- src/heap/store-buffer.cc | 4 ++-- 8 files changed, 26 insertions(+), 83 deletions(-) diff --git a/src/globals.h b/src/globals.h index 486794d..41c33fa 100644 --- a/src/globals.h +++ b/src/globals.h @@ -572,11 +572,6 @@ struct CodeDesc { }; -// Callback function used for iterating objects in heap spaces, -// for example, scanning heap objects. -typedef int (*HeapObjectCallback)(HeapObject* obj); - - // Callback function used for checking constraints when copying/relocating // objects. Returns true if an object can be copied/relocated from its // old_addr to a new_addr. diff --git a/src/heap/heap.cc b/src/heap/heap.cc index 5a3db5e..e74ad5b 100644 --- a/src/heap/heap.cc +++ b/src/heap/heap.cc @@ -6115,17 +6115,7 @@ OldSpace* OldSpaces::next() { SpaceIterator::SpaceIterator(Heap* heap) - : heap_(heap), - current_space_(FIRST_SPACE), - iterator_(NULL), - size_func_(NULL) {} - - -SpaceIterator::SpaceIterator(Heap* heap, HeapObjectCallback size_func) - : heap_(heap), - current_space_(FIRST_SPACE), - iterator_(NULL), - size_func_(size_func) {} + : heap_(heap), current_space_(FIRST_SPACE), iterator_(NULL) {} SpaceIterator::~SpaceIterator() { @@ -6162,19 +6152,19 @@ ObjectIterator* SpaceIterator::CreateIterator() { switch (current_space_) { case NEW_SPACE: - iterator_ = new SemiSpaceIterator(heap_->new_space(), size_func_); + iterator_ = new SemiSpaceIterator(heap_->new_space()); break; case OLD_SPACE: - iterator_ = new HeapObjectIterator(heap_->old_space(), size_func_); + iterator_ = new HeapObjectIterator(heap_->old_space()); break; case CODE_SPACE: - iterator_ = new HeapObjectIterator(heap_->code_space(), size_func_); + iterator_ = new HeapObjectIterator(heap_->code_space()); break; case MAP_SPACE: - iterator_ = new HeapObjectIterator(heap_->map_space(), size_func_); + iterator_ = new HeapObjectIterator(heap_->map_space()); break; case LO_SPACE: - iterator_ = new LargeObjectIterator(heap_->lo_space(), size_func_); + iterator_ = new LargeObjectIterator(heap_->lo_space()); break; } diff --git a/src/heap/heap.h b/src/heap/heap.h index c4b588f..561d24c 100644 --- a/src/heap/heap.h +++ b/src/heap/heap.h @@ -2505,7 +2505,6 @@ class PagedSpaces BASE_EMBEDDED { class SpaceIterator : public Malloced { public: explicit SpaceIterator(Heap* heap); - SpaceIterator(Heap* heap, HeapObjectCallback size_func); virtual ~SpaceIterator(); bool has_next(); @@ -2517,7 +2516,6 @@ class SpaceIterator : public Malloced { Heap* heap_; int current_space_; // from enum AllocationSpace. ObjectIterator* iterator_; // object iterator for the current space. - HeapObjectCallback size_func_; }; diff --git a/src/heap/mark-compact.cc b/src/heap/mark-compact.cc index 0ac9b3b..f9eeaad 100644 --- a/src/heap/mark-compact.cc +++ b/src/heap/mark-compact.cc @@ -169,7 +169,7 @@ class VerifyEvacuationVisitor : public ObjectVisitor { static void VerifyEvacuation(Page* page) { VerifyEvacuationVisitor visitor; - HeapObjectIterator iterator(page, NULL); + HeapObjectIterator iterator(page); for (HeapObject* heap_object = iterator.Next(); heap_object != NULL; heap_object = iterator.Next()) { // We skip free space objects. diff --git a/src/heap/spaces-inl.h b/src/heap/spaces-inl.h index 6222e6b..02a115a 100644 --- a/src/heap/spaces-inl.h +++ b/src/heap/spaces-inl.h @@ -88,7 +88,7 @@ HeapObject* HeapObjectIterator::FromCurrentPage() { continue; } HeapObject* obj = HeapObject::FromAddress(cur_addr_); - int obj_size = (size_func_ == NULL) ? obj->Size() : size_func_(obj); + int obj_size = obj->Size(); cur_addr_ += obj_size; DCHECK(cur_addr_ <= cur_end_); // TODO(hpayer): Remove the debugging code. diff --git a/src/heap/spaces.cc b/src/heap/spaces.cc index a1f0997..a0df653 100644 --- a/src/heap/spaces.cc +++ b/src/heap/spaces.cc @@ -24,40 +24,27 @@ HeapObjectIterator::HeapObjectIterator(PagedSpace* space) { // just an anchor for the double linked page list. Initialize as if we have // reached the end of the anchor page, then the first iteration will move on // to the first page. - Initialize(space, NULL, NULL, kAllPagesInSpace, NULL); + Initialize(space, NULL, NULL, kAllPagesInSpace); } -HeapObjectIterator::HeapObjectIterator(PagedSpace* space, - HeapObjectCallback size_func) { - // You can't actually iterate over the anchor page. It is not a real page, - // just an anchor for the double linked page list. Initialize the current - // address and end as NULL, then the first iteration will move on - // to the first page. - Initialize(space, NULL, NULL, kAllPagesInSpace, size_func); -} - - -HeapObjectIterator::HeapObjectIterator(Page* page, - HeapObjectCallback size_func) { +HeapObjectIterator::HeapObjectIterator(Page* page) { Space* owner = page->owner(); DCHECK(owner == page->heap()->old_space() || owner == page->heap()->map_space() || owner == page->heap()->code_space()); Initialize(reinterpret_cast(owner), page->area_start(), - page->area_end(), kOnePageOnly, size_func); + page->area_end(), kOnePageOnly); DCHECK(page->WasSwept() || page->SweepingCompleted()); } void HeapObjectIterator::Initialize(PagedSpace* space, Address cur, Address end, - HeapObjectIterator::PageMode mode, - HeapObjectCallback size_f) { + HeapObjectIterator::PageMode mode) { space_ = space; cur_addr_ = cur; cur_end_ = end; page_mode_ = mode; - size_func_ = size_f; } @@ -1009,7 +996,7 @@ Object* PagedSpace::FindObject(Address addr) { if (!Contains(addr)) return Smi::FromInt(0); // Signaling not found. Page* p = Page::FromAddress(addr); - HeapObjectIterator it(p, NULL); + HeapObjectIterator it(p); for (HeapObject* obj = it.Next(); obj != NULL; obj = it.Next()) { Address cur = obj->address(); Address next = cur + obj->Size(); @@ -1186,7 +1173,7 @@ void PagedSpace::Verify(ObjectVisitor* visitor) { allocation_pointer_found_in_space = true; } CHECK(page->WasSwept()); - HeapObjectIterator it(page, NULL); + HeapObjectIterator it(page); Address end_of_previous_object = page->area_start(); Address top = page->area_end(); int black_size = 0; @@ -1860,32 +1847,24 @@ void SemiSpace::AssertValidRange(Address start, Address end) { // ----------------------------------------------------------------------------- // SemiSpaceIterator implementation. SemiSpaceIterator::SemiSpaceIterator(NewSpace* space) { - Initialize(space->bottom(), space->top(), NULL); -} - - -SemiSpaceIterator::SemiSpaceIterator(NewSpace* space, - HeapObjectCallback size_func) { - Initialize(space->bottom(), space->top(), size_func); + Initialize(space->bottom(), space->top()); } SemiSpaceIterator::SemiSpaceIterator(NewSpace* space, Address start) { - Initialize(start, space->top(), NULL); + Initialize(start, space->top()); } SemiSpaceIterator::SemiSpaceIterator(Address from, Address to) { - Initialize(from, to, NULL); + Initialize(from, to); } -void SemiSpaceIterator::Initialize(Address start, Address end, - HeapObjectCallback size_func) { +void SemiSpaceIterator::Initialize(Address start, Address end) { SemiSpace::AssertValidRange(start, end); current_ = start; limit_ = end; - size_func_ = size_func; } @@ -2821,14 +2800,6 @@ void MapSpace::VerifyObject(HeapObject* object) { CHECK(object->IsMap()); } LargeObjectIterator::LargeObjectIterator(LargeObjectSpace* space) { current_ = space->first_page_; - size_func_ = NULL; -} - - -LargeObjectIterator::LargeObjectIterator(LargeObjectSpace* space, - HeapObjectCallback size_func) { - current_ = space->first_page_; - size_func_ = size_func; } @@ -3140,7 +3111,7 @@ void Page::Print() { PrintF("Page@%p in %s\n", this->address(), AllocationSpaceName(this->owner()->identity())); printf(" --------------------------------------\n"); - HeapObjectIterator objects(this, nullptr); + HeapObjectIterator objects(this); unsigned mark_size = 0; for (HeapObject* object = objects.Next(); object != NULL; object = objects.Next()) { diff --git a/src/heap/spaces.h b/src/heap/spaces.h index e9b23e5..f225bbc 100644 --- a/src/heap/spaces.h +++ b/src/heap/spaces.h @@ -1240,11 +1240,8 @@ class ObjectIterator : public Malloced { class HeapObjectIterator : public ObjectIterator { public: // Creates a new object iterator in a given space. - // If the size function is not given, the iterator calls the default - // Object::Size(). explicit HeapObjectIterator(PagedSpace* space); - HeapObjectIterator(PagedSpace* space, HeapObjectCallback size_func); - HeapObjectIterator(Page* page, HeapObjectCallback size_func); + explicit HeapObjectIterator(Page* page); // Advance to the next object, skipping free spaces and other fillers and // skipping the special garbage section of which there is one per space. @@ -1264,7 +1261,6 @@ class HeapObjectIterator : public ObjectIterator { Address cur_addr_; // Current iteration point. Address cur_end_; // End iteration point. - HeapObjectCallback size_func_; // Size function or NULL. PagedSpace* space_; PageMode page_mode_; @@ -1277,7 +1273,7 @@ class HeapObjectIterator : public ObjectIterator { // Initializes fields. inline void Initialize(PagedSpace* owner, Address start, Address end, - PageMode mode, HeapObjectCallback size_func); + PageMode mode); }; @@ -2279,13 +2275,10 @@ class SemiSpace : public Space { class SemiSpaceIterator : public ObjectIterator { public: // Create an iterator over the objects in the given space. If no start - // address is given, the iterator starts from the bottom of the space. If - // no size function is given, the iterator calls Object::Size(). + // address is given, the iterator starts from the bottom of the space. // Iterate over all of allocated to-space. explicit SemiSpaceIterator(NewSpace* space); - // Iterate over all of allocated to-space, with a custome size function. - SemiSpaceIterator(NewSpace* space, HeapObjectCallback size_func); // Iterate over part of allocated to-space, from start to the end // of allocation. SemiSpaceIterator(NewSpace* space, Address start); @@ -2303,7 +2296,7 @@ class SemiSpaceIterator : public ObjectIterator { } HeapObject* object = HeapObject::FromAddress(current_); - int size = (size_func_ == NULL) ? object->Size() : size_func_(object); + int size = object->Size(); current_ += size; return object; @@ -2313,14 +2306,12 @@ class SemiSpaceIterator : public ObjectIterator { virtual HeapObject* next_object() { return Next(); } private: - void Initialize(Address start, Address end, HeapObjectCallback size_func); + void Initialize(Address start, Address end); // The current iteration point. Address current_; // The end of iteration. Address limit_; - // The callback function. - HeapObjectCallback size_func_; }; @@ -2818,7 +2809,6 @@ class LargeObjectSpace : public Space { class LargeObjectIterator : public ObjectIterator { public: explicit LargeObjectIterator(LargeObjectSpace* space); - LargeObjectIterator(LargeObjectSpace* space, HeapObjectCallback size_func); HeapObject* Next(); @@ -2827,7 +2817,6 @@ class LargeObjectIterator : public ObjectIterator { private: LargePage* current_; - HeapObjectCallback size_func_; }; diff --git a/src/heap/store-buffer.cc b/src/heap/store-buffer.cc index a196844..e6430d5 100644 --- a/src/heap/store-buffer.cc +++ b/src/heap/store-buffer.cc @@ -455,7 +455,7 @@ void StoreBuffer::IteratePointersToNewSpace(ObjectSlotCallback slot_callback) { PagedSpace* owner = reinterpret_cast(page->owner()); if (owner == heap_->map_space()) { DCHECK(page->WasSwept()); - HeapObjectIterator iterator(page, NULL); + HeapObjectIterator iterator(page); for (HeapObject* heap_object = iterator.Next(); heap_object != NULL; heap_object = iterator.Next()) { // We skip free space objects. @@ -470,7 +470,7 @@ void StoreBuffer::IteratePointersToNewSpace(ObjectSlotCallback slot_callback) { } else { heap_->mark_compact_collector()->SweepOrWaitUntilSweepingCompleted( page); - HeapObjectIterator iterator(page, NULL); + HeapObjectIterator iterator(page); for (HeapObject* heap_object = iterator.Next(); heap_object != NULL; heap_object = iterator.Next()) { // We iterate over objects that contain new space pointers only. -- 2.7.4