Commit 8ee03b11 authored by Ulan Degenbaev's avatar Ulan Degenbaev Committed by Commit Bot

[heap] Use LiveObjectRange in MarkingVerifier

This removes custom object iteration in MarkingVerifier.

Change-Id: I2e597dab6014ff4443faa60cd3d4be20a2dc1b56
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2438067Reviewed-by: 's avatarDominik Inführ <dinfuehr@chromium.org>
Commit-Queue: Ulan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70250}
parent b187504e
......@@ -135,8 +135,8 @@ void MainMarkingVisitor<MarkingState>::MarkDescriptorArrayFromWriteBarrier(
}
template <LiveObjectIterationMode mode>
LiveObjectRange<mode>::iterator::iterator(MemoryChunk* chunk, Bitmap* bitmap,
Address start)
LiveObjectRange<mode>::iterator::iterator(const MemoryChunk* chunk,
Bitmap* bitmap, Address start)
: chunk_(chunk),
one_word_filler_map_(
ReadOnlyRoots(chunk->heap()).one_pointer_filler_map()),
......
......@@ -118,30 +118,28 @@ void MarkingVerifier::VerifyRoots() {
void MarkingVerifier::VerifyMarkingOnPage(const Page* page, Address start,
Address end) {
HeapObject object;
Address next_object_must_be_here_or_later = start;
for (Address current = start; current < end;) {
object = HeapObject::FromAddress(current);
// One word fillers at the end of a black area can be grey.
if (IsBlackOrGrey(object) &&
object.map() != ReadOnlyRoots(heap_).one_pointer_filler_map()) {
CHECK(IsMarked(object));
CHECK(current >= next_object_must_be_here_or_later);
object.Iterate(this);
next_object_must_be_here_or_later = current + object.Size();
// The object is either part of a black area of black allocation or a
// regular black object
CHECK(
bitmap(page)->AllBitsSetInRange(
for (auto object_and_size :
LiveObjectRange<kAllLiveObjects>(page, bitmap(page))) {
HeapObject object = object_and_size.first;
size_t size = object_and_size.second;
Address current = object.address();
if (current < start) continue;
if (current >= end) break;
CHECK(IsMarked(object));
CHECK(current >= next_object_must_be_here_or_later);
object.Iterate(this);
next_object_must_be_here_or_later = current + size;
// The object is either part of a black area of black allocation or a
// regular black object
CHECK(bitmap(page)->AllBitsSetInRange(
page->AddressToMarkbitIndex(current),
page->AddressToMarkbitIndex(next_object_must_be_here_or_later)) ||
bitmap(page)->AllBitsClearInRange(
page->AddressToMarkbitIndex(current + kTaggedSize * 2),
page->AddressToMarkbitIndex(next_object_must_be_here_or_later)));
current = next_object_must_be_here_or_later;
} else {
current += kTaggedSize;
}
current = next_object_must_be_here_or_later;
}
}
......
......@@ -32,7 +32,8 @@ class YoungGenerationMarkingVisitor;
class MarkBitCellIterator {
public:
MarkBitCellIterator(MemoryChunk* chunk, Bitmap* bitmap) : chunk_(chunk) {
MarkBitCellIterator(const MemoryChunk* chunk, Bitmap* bitmap)
: chunk_(chunk) {
last_cell_index_ =
Bitmap::IndexToCell(chunk_->AddressToMarkbitIndex(chunk_->area_end()));
cell_base_ = chunk_->address();
......@@ -83,7 +84,7 @@ class MarkBitCellIterator {
}
private:
MemoryChunk* chunk_;
const MemoryChunk* chunk_;
MarkBit::CellType* cells_;
unsigned int last_cell_index_;
unsigned int cell_index_;
......@@ -102,7 +103,7 @@ class LiveObjectRange {
using reference = const value_type&;
using iterator_category = std::forward_iterator_tag;
inline iterator(MemoryChunk* chunk, Bitmap* bitmap, Address start);
inline iterator(const MemoryChunk* chunk, Bitmap* bitmap, Address start);
inline iterator& operator++();
inline iterator operator++(int);
......@@ -120,7 +121,7 @@ class LiveObjectRange {
private:
inline void AdvanceToNextValidObject();
MemoryChunk* const chunk_;
const MemoryChunk* const chunk_;
Map const one_word_filler_map_;
Map const two_word_filler_map_;
Map const free_space_map_;
......@@ -131,7 +132,7 @@ class LiveObjectRange {
int current_size_;
};
LiveObjectRange(MemoryChunk* chunk, Bitmap* bitmap)
LiveObjectRange(const MemoryChunk* chunk, Bitmap* bitmap)
: chunk_(chunk),
bitmap_(bitmap),
start_(chunk_->area_start()),
......@@ -143,7 +144,7 @@ class LiveObjectRange {
inline iterator end();
private:
MemoryChunk* const chunk_;
const MemoryChunk* const chunk_;
Bitmap* bitmap_;
Address start_;
Address end_;
......
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