From 1dacb786141e4b9aa8b5e4c4e3b0f0b2ca8fc51c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Inf=C3=BChr?= Date: Mon, 11 Jun 2018 17:19:16 +0200 Subject: [PATCH] RecordSlot's target argument should be HeapObject MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: chromium:844008 Change-Id: If248ca90213c5cb3dfb0e3936a9ac824ed3c3119 Reviewed-on: https://chromium-review.googlesource.com/1095276 Reviewed-by: Ulan Degenbaev Commit-Queue: Dominik Inführ Cr-Commit-Position: refs/heads/master@{#53646} --- src/heap/concurrent-marking.cc | 10 ++++++---- src/heap/incremental-marking.cc | 3 ++- src/heap/mark-compact-inl.h | 6 +++--- src/heap/mark-compact.cc | 9 ++++----- src/heap/mark-compact.h | 5 +++-- src/heap/objects-visiting.cc | 9 ++++++--- 6 files changed, 24 insertions(+), 18 deletions(-) diff --git a/src/heap/concurrent-marking.cc b/src/heap/concurrent-marking.cc index 355acaace2..e2ee8cb35f 100644 --- a/src/heap/concurrent-marking.cc +++ b/src/heap/concurrent-marking.cc @@ -157,8 +157,9 @@ class ConcurrentMarkingVisitor final Object* object = snapshot.value(i); DCHECK(!HasWeakHeapObjectTag(object)); if (!object->IsHeapObject()) continue; - MarkObject(HeapObject::cast(object)); - MarkCompactCollector::RecordSlot(host, slot, object); + HeapObject* heap_object = HeapObject::cast(object); + MarkObject(heap_object); + MarkCompactCollector::RecordSlot(host, slot, heap_object); } } @@ -368,7 +369,7 @@ class ConcurrentMarkingVisitor final Object** value_slot = table->RawFieldOfElementAt(EphemeronHashTable::EntryToValueIndex(i)); - MarkCompactCollector::RecordSlot(table, key_slot, *key_slot); + MarkCompactCollector::RecordSlot(table, key_slot, key); if (marking_state_.IsBlackOrGrey(key)) { VisitPointer(table, value_slot); @@ -376,7 +377,8 @@ class ConcurrentMarkingVisitor final Object* value = *value_slot; if (value->IsHeapObject()) { - MarkCompactCollector::RecordSlot(table, value_slot, value); + MarkCompactCollector::RecordSlot(table, value_slot, + HeapObject::cast(value)); } } } diff --git a/src/heap/incremental-marking.cc b/src/heap/incremental-marking.cc index 521e49438a..f3c1c07a10 100644 --- a/src/heap/incremental-marking.cc +++ b/src/heap/incremental-marking.cc @@ -98,7 +98,8 @@ void IncrementalMarking::RecordWriteSlow(HeapObject* obj, Object* value) { if (BaseRecordWrite(obj, value) && slot != nullptr) { // Object is not going to be rescanned we need to record the slot. - heap_->mark_compact_collector()->RecordSlot(obj, slot, value); + heap_->mark_compact_collector()->RecordSlot(obj, slot, + HeapObject::cast(value)); } } diff --git a/src/heap/mark-compact-inl.h b/src/heap/mark-compact-inl.h index eb5834552b..57c5f6b6f2 100644 --- a/src/heap/mark-compact-inl.h +++ b/src/heap/mark-compact-inl.h @@ -145,7 +145,7 @@ int MarkingVisitorRecordSlot(weak_cell, slot, *slot); + collector_->RecordSlot(weak_cell, slot, HeapObject::cast(*slot)); } else { // If we do not know about liveness of values of weak cells, we have to // process them when we know the liveness of the whole transitive @@ -383,13 +383,13 @@ void MarkCompactCollector::MarkExternallyReferencedObject(HeapObject* obj) { } void MarkCompactCollector::RecordSlot(HeapObject* object, Object** slot, - Object* target) { + HeapObject* target) { RecordSlot(object, reinterpret_cast(slot), target); } void MarkCompactCollector::RecordSlot(HeapObject* object, HeapObjectReference** slot, - Object* target) { + HeapObject* target) { Page* target_page = Page::FromAddress(reinterpret_cast
(target)); Page* source_page = Page::FromAddress(reinterpret_cast
(object)); if (target_page->IsEvacuationCandidate() && diff --git a/src/heap/mark-compact.cc b/src/heap/mark-compact.cc index abf985714a..4555c0bbf5 100644 --- a/src/heap/mark-compact.cc +++ b/src/heap/mark-compact.cc @@ -959,7 +959,7 @@ class InternalizedStringTableCleaner : public ObjectVisitor { } else { // StringTable contains only old space strings. DCHECK(!heap_->InNewSpace(o)); - MarkCompactCollector::RecordSlot(table_, p, o); + MarkCompactCollector::RecordSlot(table_, p, heap_object); } } } @@ -1912,9 +1912,9 @@ void MarkCompactCollector::ClearWeakCells() { // Resurrect the cell. non_atomic_marking_state()->WhiteToBlack(value); Object** slot = HeapObject::RawField(value, Cell::kValueOffset); - RecordSlot(value, slot, *slot); + RecordSlot(value, slot, HeapObject::cast(*slot)); slot = HeapObject::RawField(weak_cell, WeakCell::kValueOffset); - RecordSlot(weak_cell, slot, *slot); + RecordSlot(weak_cell, slot, HeapObject::cast(*slot)); } else { weak_cell->clear(); } @@ -1925,7 +1925,7 @@ void MarkCompactCollector::ClearWeakCells() { } else { // The value of the weak cell is alive. Object** slot = HeapObject::RawField(weak_cell, WeakCell::kValueOffset); - RecordSlot(weak_cell, slot, *slot); + RecordSlot(weak_cell, slot, HeapObject::cast(*slot)); } } } @@ -1957,7 +1957,6 @@ void MarkCompactCollector::AbortWeakObjects() { weak_objects_.transition_arrays.Clear(); weak_objects_.weak_references.Clear(); weak_objects_.weak_objects_in_code.Clear(); - weak_objects_.ephemeron_hash_tables.Clear(); } void MarkCompactCollector::RecordRelocSlot(Code* host, RelocInfo* rinfo, diff --git a/src/heap/mark-compact.h b/src/heap/mark-compact.h index d9c18cf2a8..978b45caea 100644 --- a/src/heap/mark-compact.h +++ b/src/heap/mark-compact.h @@ -572,9 +572,10 @@ class MarkCompactCollector final : public MarkCompactCollectorBase { void RecordRelocSlot(Code* host, RelocInfo* rinfo, Object* target); V8_INLINE static void RecordSlot(HeapObject* object, Object** slot, - Object* target); + HeapObject* target); V8_INLINE static void RecordSlot(HeapObject* object, - HeapObjectReference** slot, Object* target); + HeapObjectReference** slot, + HeapObject* target); void RecordLiveSlotsOnPage(Page* page); void UpdateSlots(SlotsBuffer* buffer); diff --git a/src/heap/objects-visiting.cc b/src/heap/objects-visiting.cc index c7c384f52a..8e97564c08 100644 --- a/src/heap/objects-visiting.cc +++ b/src/heap/objects-visiting.cc @@ -53,7 +53,8 @@ Object* VisitWeakList(Heap* heap, Object* list, WeakObjectRetainer* retainer) { HeapObject* slot_holder = WeakListVisitor::WeakNextHolder(tail); int slot_offset = WeakListVisitor::WeakNextOffset(); Object** slot = HeapObject::RawField(slot_holder, slot_offset); - MarkCompactCollector::RecordSlot(slot_holder, slot, retained); + MarkCompactCollector::RecordSlot(slot_holder, slot, + HeapObject::cast(retained)); } } // Retained object is new tail. @@ -135,7 +136,8 @@ struct WeakListVisitor { for (int idx = Context::FIRST_WEAK_SLOT; idx < Context::NATIVE_CONTEXT_SLOTS; ++idx) { Object** slot = Context::cast(context)->RawFieldOfElementAt(idx); - MarkCompactCollector::RecordSlot(context, slot, *slot); + MarkCompactCollector::RecordSlot(context, slot, + HeapObject::cast(*slot)); } // Code objects are always allocated in Code space, we do not have to // visit them during scavenges. @@ -157,7 +159,8 @@ struct WeakListVisitor { // Record the updated slot if necessary. Object** head_slot = HeapObject::RawField(context, FixedArray::SizeFor(index)); - heap->mark_compact_collector()->RecordSlot(context, head_slot, list_head); + heap->mark_compact_collector()->RecordSlot(context, head_slot, + HeapObject::cast(list_head)); } }