Index: src/heap/mark-compact.cc |
diff --git a/src/heap/mark-compact.cc b/src/heap/mark-compact.cc |
index b5f191094c9b96f532aa3c9749eb48cf475d87d7..55e7b8e82b136b2e78d6583f0b0949ebbd714fd9 100644 |
--- a/src/heap/mark-compact.cc |
+++ b/src/heap/mark-compact.cc |
@@ -4522,9 +4522,18 @@ void SlotsBuffer::RemoveInvalidSlots(Heap* heap, SlotsBuffer* buffer) { |
ObjectSlot slot = slots[slot_idx]; |
if (!IsTypedSlot(slot)) { |
Object* object = *slot; |
- if ((object->IsHeapObject() && heap->InNewSpace(object)) || |
+ // Slots are invalid when they currently: |
+ // - do not point to a heap object (SMI) |
+ // - point to a heap object in new space |
+ // - are not within a live heap object on a valid pointer slot |
+ // - point to a heap object not on an evacuation candidate |
+ if (!object->IsHeapObject() || heap->InNewSpace(object) || |
!heap->mark_compact_collector()->IsSlotInLiveObject( |
- reinterpret_cast<Address>(slot))) { |
+ reinterpret_cast<Address>(slot)) || |
+ !Page::FromAddress(reinterpret_cast<Address>(object)) |
+ ->IsEvacuationCandidate()) { |
+ // TODO(hpayer): Instead of replacing slots with kRemovedEntry we |
+ // could shrink the slots buffer in-place. |
slots[slot_idx] = kRemovedEntry; |
} |
} else { |
@@ -4556,6 +4565,8 @@ void SlotsBuffer::RemoveObjectSlots(Heap* heap, SlotsBuffer* buffer, |
if (!IsTypedSlot(slot)) { |
Address slot_address = reinterpret_cast<Address>(slot); |
if (slot_address >= start_slot && slot_address < end_slot) { |
+ // TODO(hpayer): Instead of replacing slots with kRemovedEntry we |
+ // could shrink the slots buffer in-place. |
slots[slot_idx] = kRemovedEntry; |
if (is_typed_slot) { |
slots[slot_idx - 1] = kRemovedEntry; |