Commit 5d3f801a authored by mlippautz's avatar mlippautz Committed by Commit bot

[heap] Get rid of dead code in HeapIterator.

BUG=

Review URL: https://codereview.chromium.org/1319953003

Cr-Commit-Position: refs/heads/master@{#30418}
parent b6f0ee50
...@@ -6111,31 +6111,15 @@ class UnreachableObjectsFilter : public HeapObjectsFilter { ...@@ -6111,31 +6111,15 @@ class UnreachableObjectsFilter : public HeapObjectsFilter {
}; };
HeapIterator::HeapIterator(Heap* heap)
: make_heap_iterable_helper_(heap),
no_heap_allocation_(),
heap_(heap),
filtering_(HeapIterator::kNoFiltering),
filter_(NULL) {
Init();
}
HeapIterator::HeapIterator(Heap* heap, HeapIterator::HeapIterator(Heap* heap,
HeapIterator::HeapObjectsFiltering filtering) HeapIterator::HeapObjectsFiltering filtering)
: make_heap_iterable_helper_(heap), : make_heap_iterable_helper_(heap),
no_heap_allocation_(), no_heap_allocation_(),
heap_(heap), heap_(heap),
filtering_(filtering), filtering_(filtering),
filter_(NULL) { filter_(nullptr),
Init(); space_iterator_(nullptr),
} object_iterator_(nullptr) {
HeapIterator::~HeapIterator() { Shutdown(); }
void HeapIterator::Init() {
// Start the iteration. // Start the iteration.
space_iterator_ = new SpaceIterator(heap_); space_iterator_ = new SpaceIterator(heap_);
switch (filtering_) { switch (filtering_) {
...@@ -6149,35 +6133,33 @@ void HeapIterator::Init() { ...@@ -6149,35 +6133,33 @@ void HeapIterator::Init() {
} }
void HeapIterator::Shutdown() { HeapIterator::~HeapIterator() {
#ifdef DEBUG #ifdef DEBUG
// Assert that in filtering mode we have iterated through all // Assert that in filtering mode we have iterated through all
// objects. Otherwise, heap will be left in an inconsistent state. // objects. Otherwise, heap will be left in an inconsistent state.
if (filtering_ != kNoFiltering) { if (filtering_ != kNoFiltering) {
DCHECK(object_iterator_ == NULL); DCHECK(object_iterator_ == nullptr);
} }
#endif #endif
// Make sure the last iterator is deallocated. // Make sure the last iterator is deallocated.
delete object_iterator_;
delete space_iterator_; delete space_iterator_;
space_iterator_ = NULL;
object_iterator_ = NULL;
delete filter_; delete filter_;
filter_ = NULL;
} }
HeapObject* HeapIterator::next() { HeapObject* HeapIterator::next() {
if (filter_ == NULL) return NextObject(); if (filter_ == nullptr) return NextObject();
HeapObject* obj = NextObject(); HeapObject* obj = NextObject();
while (obj != NULL && filter_->SkipObject(obj)) obj = NextObject(); while ((obj != nullptr) && (filter_->SkipObject(obj))) obj = NextObject();
return obj; return obj;
} }
HeapObject* HeapIterator::NextObject() { HeapObject* HeapIterator::NextObject() {
// No iterator means we are done. // No iterator means we are done.
if (object_iterator_ == NULL) return NULL; if (object_iterator_ == nullptr) return nullptr;
if (HeapObject* obj = object_iterator_->next_object()) { if (HeapObject* obj = object_iterator_->next_object()) {
// If the current iterator has more objects we are fine. // If the current iterator has more objects we are fine.
...@@ -6192,15 +6174,8 @@ HeapObject* HeapIterator::NextObject() { ...@@ -6192,15 +6174,8 @@ HeapObject* HeapIterator::NextObject() {
} }
} }
// Done with the last space. // Done with the last space.
object_iterator_ = NULL; object_iterator_ = nullptr;
return NULL; return nullptr;
}
void HeapIterator::reset() {
// Restart the iterator.
Shutdown();
Init();
} }
......
...@@ -2588,26 +2588,26 @@ class HeapIterator BASE_EMBEDDED { ...@@ -2588,26 +2588,26 @@ class HeapIterator BASE_EMBEDDED {
public: public:
enum HeapObjectsFiltering { kNoFiltering, kFilterUnreachable }; enum HeapObjectsFiltering { kNoFiltering, kFilterUnreachable };
explicit HeapIterator(Heap* heap); explicit HeapIterator(Heap* heap,
HeapIterator(Heap* heap, HeapObjectsFiltering filtering); HeapObjectsFiltering filtering = kNoFiltering);
~HeapIterator(); ~HeapIterator();
HeapObject* next(); HeapObject* next();
void reset();
private: private:
struct MakeHeapIterableHelper { struct MakeHeapIterableHelper {
explicit MakeHeapIterableHelper(Heap* heap) { heap->MakeHeapIterable(); } explicit MakeHeapIterableHelper(Heap* heap) { heap->MakeHeapIterable(); }
}; };
// Perform the initialization.
void Init();
// Perform all necessary shutdown (destruction) work.
void Shutdown();
HeapObject* NextObject(); HeapObject* NextObject();
// The following two fields need to be declared in this order. Initialization
// order guarantees that we first make the heap iterable (which may involve
// allocations) and only then lock it down by not allowing further
// allocations.
MakeHeapIterableHelper make_heap_iterable_helper_; MakeHeapIterableHelper make_heap_iterable_helper_;
DisallowHeapAllocation no_heap_allocation_; DisallowHeapAllocation no_heap_allocation_;
Heap* heap_; Heap* heap_;
HeapObjectsFiltering filtering_; HeapObjectsFiltering filtering_;
HeapObjectsFilter* filter_; HeapObjectsFilter* filter_;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment