[roheap] Make all HeapIterators have matching APIs

This makes the API more consistent.

Originally I planned to use this to template iterators inside mkgrokdump, but
I decided against it.

Bug: v8:9183
Change-Id: Iefa372370a7cc7c637dc86c0bfb837a91a2bc6e3
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1622116
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: Dan Elphick <delphick@chromium.org>
Commit-Queue: Maciej Goszczycki <goszczycki@google.com>
Cr-Commit-Position: refs/heads/master@{#61705}
This commit is contained in:
Maciej Goszczycki 2019-05-21 16:45:58 +01:00 committed by Commit Bot
parent 295575234a
commit 19b8981303
12 changed files with 31 additions and 31 deletions

View File

@ -7,8 +7,8 @@
namespace v8 {
namespace internal {
HeapObject CombinedHeapIterator::next() {
HeapObject object = ro_heap_iterator_.next();
HeapObject CombinedHeapIterator::Next() {
HeapObject object = ro_heap_iterator_.Next();
if (!object.is_null()) {
return object;
}

View File

@ -23,7 +23,7 @@ class V8_EXPORT_PRIVATE CombinedHeapIterator final {
HeapIterator::HeapObjectsFiltering::kNoFiltering)
: heap_iterator_(heap, filtering),
ro_heap_iterator_(heap->read_only_heap()) {}
HeapObject next();
HeapObject Next();
private:
HeapIterator heap_iterator_;

View File

@ -514,8 +514,8 @@ void MarkCompactCollector::CollectGarbage() {
#ifdef VERIFY_HEAP
void MarkCompactCollector::VerifyMarkbitsAreDirty(ReadOnlySpace* space) {
ReadOnlyHeapIterator iterator(space);
for (HeapObject object = iterator.next(); !object.is_null();
object = iterator.next()) {
for (HeapObject object = iterator.Next(); !object.is_null();
object = iterator.Next()) {
CHECK(non_atomic_marking_state()->IsBlack(object));
}
}

View File

@ -1081,8 +1081,8 @@ namespace {
void IterateHeap(Heap* heap, ObjectStatsVisitor* visitor) {
CombinedHeapIterator iterator(heap);
for (HeapObject obj = iterator.next(); !obj.is_null();
obj = iterator.next()) {
for (HeapObject obj = iterator.Next(); !obj.is_null();
obj = iterator.Next()) {
visitor->Visit(obj, obj->Size());
}
}

View File

@ -142,7 +142,7 @@ ReadOnlyHeapIterator::ReadOnlyHeapIterator(ReadOnlySpace* ro_space)
current_page_(ro_space->first_page()),
current_addr_(current_page_->area_start()) {}
HeapObject ReadOnlyHeapIterator::next() {
HeapObject ReadOnlyHeapIterator::Next() {
if (current_page_ == nullptr) {
return HeapObject();
}

View File

@ -89,7 +89,7 @@ class V8_EXPORT_PRIVATE ReadOnlyHeapIterator {
explicit ReadOnlyHeapIterator(ReadOnlyHeap* ro_heap);
explicit ReadOnlyHeapIterator(ReadOnlySpace* ro_space);
HeapObject next();
HeapObject Next();
private:
ReadOnlySpace* const ro_space_;

View File

@ -3423,7 +3423,7 @@ void ReadOnlySpace::ClearStringPaddingIfNeeded() {
if (is_string_padding_cleared_) return;
ReadOnlyHeapIterator iterator(this);
for (HeapObject o = iterator.next(); !o.is_null(); o = iterator.next()) {
for (HeapObject o = iterator.Next(); !o.is_null(); o = iterator.Next()) {
if (o->IsSeqOneByteString()) {
SeqOneByteString::cast(o)->clear_padding();
} else if (o->IsSeqTwoByteString()) {

View File

@ -175,8 +175,8 @@ Handle<HeapObject> HeapProfiler::FindHeapObjectById(SnapshotObjectId id) {
HeapObject object;
CombinedHeapIterator iterator(heap(), HeapIterator::kFilterUnreachable);
// Make sure that object with the given id is still reachable.
for (HeapObject obj = iterator.next(); !obj.is_null();
obj = iterator.next()) {
for (HeapObject obj = iterator.Next(); !obj.is_null();
obj = iterator.Next()) {
if (ids_->FindEntry(obj->address()) == id) {
DCHECK(object.is_null());
object = obj;
@ -206,8 +206,8 @@ void HeapProfiler::QueryObjects(Handle<Context> context,
// collect all garbage first.
heap()->CollectAllAvailableGarbage(GarbageCollectionReason::kHeapProfiler);
CombinedHeapIterator heap_iterator(heap());
for (HeapObject heap_obj = heap_iterator.next(); !heap_obj.is_null();
heap_obj = heap_iterator.next()) {
for (HeapObject heap_obj = heap_iterator.Next(); !heap_obj.is_null();
heap_obj = heap_iterator.Next()) {
if (!heap_obj->IsJSObject() || heap_obj->IsExternal(isolate())) continue;
v8::Local<v8::Object> v8_obj(
Utils::ToLocal(handle(JSObject::cast(heap_obj), isolate())));

View File

@ -396,8 +396,8 @@ void HeapObjectsMap::UpdateHeapObjectsMap() {
heap_->PreciseCollectAllGarbage(Heap::kNoGCFlags,
GarbageCollectionReason::kHeapProfiler);
CombinedHeapIterator iterator(heap_);
for (HeapObject obj = iterator.next(); !obj.is_null();
obj = iterator.next()) {
for (HeapObject obj = iterator.Next(); !obj.is_null();
obj = iterator.Next()) {
FindOrAddEntry(obj->address(), obj->Size());
if (FLAG_heap_profiler_trace_objects) {
PrintF("Update object : %p %6d. Next address is %p\n",
@ -648,7 +648,7 @@ const char* V8HeapExplorer::GetSystemEntryName(HeapObject object) {
int V8HeapExplorer::EstimateObjectsCount() {
CombinedHeapIterator it(heap_, HeapIterator::kFilterUnreachable);
int objects_count = 0;
while (!it.next().is_null()) ++objects_count;
while (!it.Next().is_null()) ++objects_count;
return objects_count;
}
@ -1459,8 +1459,8 @@ bool V8HeapExplorer::IterateAndExtractReferences(
CombinedHeapIterator iterator(heap_, HeapIterator::kFilterUnreachable);
// Heap iteration with filtering must be finished in any case.
for (HeapObject obj = iterator.next(); !obj.is_null();
obj = iterator.next(), progress_->ProgressStep()) {
for (HeapObject obj = iterator.Next(); !obj.is_null();
obj = iterator.Next(), progress_->ProgressStep()) {
if (interrupted) continue;
size_t max_pointer = obj->Size() / kTaggedSize;

View File

@ -68,8 +68,8 @@ void ReadOnlySerializer::FinalizeSerialization() {
// Check that every object on read-only heap is reachable (and was
// serialized).
ReadOnlyHeapIterator iterator(isolate()->heap()->read_only_heap());
for (HeapObject object = iterator.next(); !object.is_null();
object = iterator.next()) {
for (HeapObject object = iterator.Next(); !object.is_null();
object = iterator.Next()) {
CHECK(serialized_objects_.count(object));
}
#endif

View File

@ -28,19 +28,19 @@ TEST(HeapIteratorNullPastEnd) {
TEST(ReadOnlyHeapIteratorNullPastEnd) {
ReadOnlyHeapIterator iterator(CcTest::heap()->read_only_heap());
while (!iterator.next().is_null()) {
while (!iterator.Next().is_null()) {
}
for (int i = 0; i < 20; i++) {
CHECK(iterator.next().is_null());
CHECK(iterator.Next().is_null());
}
}
TEST(CombinedHeapIteratorNullPastEnd) {
CombinedHeapIterator iterator(CcTest::heap());
while (!iterator.next().is_null()) {
while (!iterator.Next().is_null()) {
}
for (int i = 0; i < 20; i++) {
CHECK(iterator.next().is_null());
CHECK(iterator.Next().is_null());
}
}
@ -57,8 +57,8 @@ TEST(ReadOnlyHeapIterator) {
const Object sample_object = CreateWritableObject();
ReadOnlyHeapIterator iterator(CcTest::read_only_heap());
for (HeapObject obj = iterator.next(); !obj.is_null();
obj = iterator.next()) {
for (HeapObject obj = iterator.Next(); !obj.is_null();
obj = iterator.Next()) {
CHECK(ReadOnlyHeap::Contains(obj));
CHECK(!CcTest::heap()->Contains(obj));
CHECK_NE(sample_object, obj);
@ -88,8 +88,8 @@ TEST(CombinedHeapIterator) {
CombinedHeapIterator iterator(CcTest::heap());
bool seen_sample_object = false;
for (HeapObject obj = iterator.next(); !obj.is_null();
obj = iterator.next()) {
for (HeapObject obj = iterator.Next(); !obj.is_null();
obj = iterator.Next()) {
CHECK(IsValidHeapObject(CcTest::heap(), obj));
if (sample_object == obj) seen_sample_object = true;
}

View File

@ -128,8 +128,8 @@ static int DumpHeapConstants(const char* argv0) {
i::PrintF("\n# List of known V8 objects.\n");
i::PrintF("KNOWN_OBJECTS = {\n");
i::ReadOnlyHeapIterator ro_iterator(heap->read_only_heap());
for (i::HeapObject object = ro_iterator.next(); !object.is_null();
object = ro_iterator.next()) {
for (i::HeapObject object = ro_iterator.Next(); !object.is_null();
object = ro_iterator.Next()) {
// Skip read-only heap maps, they will be reported elsewhere.
if (object->IsMap()) continue;
DumpKnownObject(heap, i::Heap::GetSpaceName(i::RO_SPACE), object);