[heap] Fix TPH heap object iterator

This CL ensures that the TPH object iterator is reset correctly before iteration.

Bug: v8:11641
Change-Id: I041890f8a1999f5d0d75af017744a5618550f28c
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2849818
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Commit-Queue: Ulan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#74219}
This commit is contained in:
Wenyu Zhao 2021-04-27 12:07:46 +10:00 committed by Commit Bot
parent 37ff3a420f
commit c1b0fed9e7

View File

@ -6154,13 +6154,14 @@ HeapObjectIterator::HeapObjectIterator(
break;
}
object_iterator_ = space_iterator_->Next()->GetObjectIterator(heap_);
if (V8_ENABLE_THIRD_PARTY_HEAP_BOOL) heap_->tp_heap_->ResetIterator();
}
HeapObjectIterator::~HeapObjectIterator() {
#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) {
if (!V8_ENABLE_THIRD_PARTY_HEAP_BOOL && filtering_ != kNoFiltering) {
DCHECK_NULL(object_iterator_);
}
#endif
@ -6177,6 +6178,7 @@ HeapObject HeapObjectIterator::Next() {
}
HeapObject HeapObjectIterator::NextObject() {
if (V8_ENABLE_THIRD_PARTY_HEAP_BOOL) return heap_->tp_heap_->NextObject();
// No iterator means we are done.
if (object_iterator_.get() == nullptr) return HeapObject();