Commit 4bdcbb7e authored by Dan Elphick's avatar Dan Elphick Committed by Commit Bot

[heap] Add Heap member to VerifyPointersVisitor

Removes uses of HeapObject::GetIsolate()/GetHeap() from
VerifyPointersVisitor by adding it to the visitor at construction time.

Bug: v8:7786
Change-Id: I28388f2eadbaf9947eafe0c62492c9a4781be250
Reviewed-on: https://chromium-review.googlesource.com/1071575Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Commit-Queue: Dan Elphick <delphick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53325}
parent 9a03c0f3
...@@ -3660,19 +3660,22 @@ bool Heap::RootIsImmortalImmovable(int root_index) { ...@@ -3660,19 +3660,22 @@ bool Heap::RootIsImmortalImmovable(int root_index) {
#ifdef VERIFY_HEAP #ifdef VERIFY_HEAP
class VerifyReadOnlyPointersVisitor : public VerifyPointersVisitor { class VerifyReadOnlyPointersVisitor : public VerifyPointersVisitor {
public:
explicit VerifyReadOnlyPointersVisitor(Heap* heap)
: VerifyPointersVisitor(heap) {}
protected: protected:
void VerifyPointers(HeapObject* host, MaybeObject** start, void VerifyPointers(HeapObject* host, MaybeObject** start,
MaybeObject** end) override { MaybeObject** end) override {
Heap* heap = host->GetIsolate()->heap();
if (host != nullptr) { if (host != nullptr) {
CHECK(heap->InReadOnlySpace(host->map())); CHECK(heap_->InReadOnlySpace(host->map()));
} }
VerifyPointersVisitor::VerifyPointers(host, start, end); VerifyPointersVisitor::VerifyPointers(host, start, end);
for (MaybeObject** current = start; current < end; current++) { for (MaybeObject** current = start; current < end; current++) {
HeapObject* object; HeapObject* object;
if ((*current)->ToStrongOrWeakHeapObject(&object)) { if ((*current)->ToStrongOrWeakHeapObject(&object)) {
CHECK(heap->InReadOnlySpace(object)); CHECK(heap_->InReadOnlySpace(object));
} }
} }
} }
...@@ -3685,7 +3688,7 @@ void Heap::Verify() { ...@@ -3685,7 +3688,7 @@ void Heap::Verify() {
// We have to wait here for the sweeper threads to have an iterable heap. // We have to wait here for the sweeper threads to have an iterable heap.
mark_compact_collector()->EnsureSweepingCompleted(); mark_compact_collector()->EnsureSweepingCompleted();
VerifyPointersVisitor visitor; VerifyPointersVisitor visitor(this);
IterateRoots(&visitor, VISIT_ONLY_STRONG); IterateRoots(&visitor, VISIT_ONLY_STRONG);
VerifySmisVisitor smis_visitor; VerifySmisVisitor smis_visitor;
...@@ -3696,12 +3699,12 @@ void Heap::Verify() { ...@@ -3696,12 +3699,12 @@ void Heap::Verify() {
old_space_->Verify(&visitor); old_space_->Verify(&visitor);
map_space_->Verify(&visitor); map_space_->Verify(&visitor);
VerifyPointersVisitor no_dirty_regions_visitor; VerifyPointersVisitor no_dirty_regions_visitor(this);
code_space_->Verify(&no_dirty_regions_visitor); code_space_->Verify(&no_dirty_regions_visitor);
lo_space_->Verify(); lo_space_->Verify();
VerifyReadOnlyPointersVisitor read_only_visitor; VerifyReadOnlyPointersVisitor read_only_visitor(this);
read_only_space_->Verify(&read_only_visitor); read_only_space_->Verify(&read_only_visitor);
} }
...@@ -5682,7 +5685,7 @@ void VerifyPointersVisitor::VerifyPointers(HeapObject* host, ...@@ -5682,7 +5685,7 @@ void VerifyPointersVisitor::VerifyPointers(HeapObject* host,
for (MaybeObject** current = start; current < end; current++) { for (MaybeObject** current = start; current < end; current++) {
HeapObject* object; HeapObject* object;
if ((*current)->ToStrongOrWeakHeapObject(&object)) { if ((*current)->ToStrongOrWeakHeapObject(&object)) {
CHECK(object->GetIsolate()->heap()->Contains(object)); CHECK(heap_->Contains(object));
CHECK(object->map()->IsMap()); CHECK(object->map()->IsMap());
} else { } else {
CHECK((*current)->IsSmi() || (*current)->IsClearedWeakHeapObject()); CHECK((*current)->IsSmi() || (*current)->IsClearedWeakHeapObject());
......
...@@ -2624,6 +2624,7 @@ class CodePageMemoryModificationScope { ...@@ -2624,6 +2624,7 @@ class CodePageMemoryModificationScope {
// objects in a heap space but above the allocation pointer. // objects in a heap space but above the allocation pointer.
class VerifyPointersVisitor : public ObjectVisitor, public RootVisitor { class VerifyPointersVisitor : public ObjectVisitor, public RootVisitor {
public: public:
explicit VerifyPointersVisitor(Heap* heap) : heap_(heap) {}
void VisitPointers(HeapObject* host, Object** start, Object** end) override; void VisitPointers(HeapObject* host, Object** start, Object** end) override;
void VisitPointers(HeapObject* host, MaybeObject** start, void VisitPointers(HeapObject* host, MaybeObject** start,
MaybeObject** end) override; MaybeObject** end) override;
...@@ -2633,6 +2634,8 @@ class VerifyPointersVisitor : public ObjectVisitor, public RootVisitor { ...@@ -2633,6 +2634,8 @@ class VerifyPointersVisitor : public ObjectVisitor, public RootVisitor {
protected: protected:
virtual void VerifyPointers(HeapObject* host, MaybeObject** start, virtual void VerifyPointers(HeapObject* host, MaybeObject** start,
MaybeObject** end); MaybeObject** end);
Heap* heap_;
}; };
......
...@@ -2363,7 +2363,7 @@ void NewSpace::Verify() { ...@@ -2363,7 +2363,7 @@ void NewSpace::Verify() {
object->ObjectVerify(); object->ObjectVerify();
// All the interior pointers should be contained in the heap. // All the interior pointers should be contained in the heap.
VerifyPointersVisitor visitor; VerifyPointersVisitor visitor(heap());
int size = object->Size(); int size = object->Size();
object->IterateBody(map, size, &visitor); object->IterateBody(map, size, &visitor);
...@@ -3481,7 +3481,7 @@ void LargeObjectSpace::Verify() { ...@@ -3481,7 +3481,7 @@ void LargeObjectSpace::Verify() {
// Byte arrays and strings don't have interior pointers. // Byte arrays and strings don't have interior pointers.
if (object->IsAbstractCode()) { if (object->IsAbstractCode()) {
VerifyPointersVisitor code_visitor; VerifyPointersVisitor code_visitor(heap());
object->IterateBody(map, object->Size(), &code_visitor); object->IterateBody(map, object->Size(), &code_visitor);
} else if (object->IsFixedArray()) { } else if (object->IsFixedArray()) {
FixedArray* array = FixedArray::cast(object); FixedArray* array = FixedArray::cast(object);
......
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