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