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 {
};
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::HeapObjectsFiltering filtering)
: make_heap_iterable_helper_(heap),
no_heap_allocation_(),
heap_(heap),
filtering_(filtering),
filter_(NULL) {
Init();
}
HeapIterator::~HeapIterator() { Shutdown(); }
void HeapIterator::Init() {
filter_(nullptr),
space_iterator_(nullptr),
object_iterator_(nullptr) {
// Start the iteration.
space_iterator_ = new SpaceIterator(heap_);
switch (filtering_) {
......@@ -6149,35 +6133,33 @@ void HeapIterator::Init() {
}
void HeapIterator::Shutdown() {
HeapIterator::~HeapIterator() {
#ifdef DEBUG
// Assert that in filtering mode we have iterated through all
// objects. Otherwise, heap will be left in an inconsistent state.
if (filtering_ != kNoFiltering) {
DCHECK(object_iterator_ == NULL);
DCHECK(object_iterator_ == nullptr);
}
#endif
// Make sure the last iterator is deallocated.
delete object_iterator_;
delete space_iterator_;
space_iterator_ = NULL;
object_iterator_ = NULL;
delete filter_;
filter_ = NULL;
}
HeapObject* HeapIterator::next() {
if (filter_ == NULL) return NextObject();
if (filter_ == nullptr) return NextObject();
HeapObject* obj = NextObject();
while (obj != NULL && filter_->SkipObject(obj)) obj = NextObject();
while ((obj != nullptr) && (filter_->SkipObject(obj))) obj = NextObject();
return obj;
}
HeapObject* HeapIterator::NextObject() {
// 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 the current iterator has more objects we are fine.
......@@ -6192,15 +6174,8 @@ HeapObject* HeapIterator::NextObject() {
}
}
// Done with the last space.
object_iterator_ = NULL;
return NULL;
}
void HeapIterator::reset() {
// Restart the iterator.
Shutdown();
Init();
object_iterator_ = nullptr;
return nullptr;
}
......
......@@ -2588,26 +2588,26 @@ class HeapIterator BASE_EMBEDDED {
public:
enum HeapObjectsFiltering { kNoFiltering, kFilterUnreachable };
explicit HeapIterator(Heap* heap);
HeapIterator(Heap* heap, HeapObjectsFiltering filtering);
explicit HeapIterator(Heap* heap,
HeapObjectsFiltering filtering = kNoFiltering);
~HeapIterator();
HeapObject* next();
void reset();
private:
struct MakeHeapIterableHelper {
explicit MakeHeapIterableHelper(Heap* heap) { heap->MakeHeapIterable(); }
};
// Perform the initialization.
void Init();
// Perform all necessary shutdown (destruction) work.
void Shutdown();
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_;
DisallowHeapAllocation no_heap_allocation_;
Heap* heap_;
HeapObjectsFiltering filtering_;
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