OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "src/heap/remembered-set.h" |
| 6 #include "src/heap/heap-inl.h" |
| 7 #include "src/heap/heap.h" |
| 8 #include "src/heap/mark-compact.h" |
| 9 #include "src/heap/slot-set.h" |
| 10 #include "src/heap/spaces.h" |
| 11 #include "src/heap/store-buffer.h" |
| 12 |
| 13 namespace v8 { |
| 14 namespace internal { |
| 15 |
| 16 template <PointerDirection direction> |
| 17 void RememberedSet<direction>::ClearInvalidSlots(Heap* heap) { |
| 18 STATIC_ASSERT(direction == OLD_TO_NEW); |
| 19 PageIterator it(heap->old_space()); |
| 20 MemoryChunk* chunk; |
| 21 while (it.has_next()) { |
| 22 chunk = it.next(); |
| 23 SlotSet* slots = GetSlotSet(chunk); |
| 24 if (slots != nullptr) { |
| 25 slots->Iterate([heap](Address addr) { |
| 26 Object** slot = reinterpret_cast<Object**>(addr); |
| 27 return IsValidSlot(heap, slot) ? SlotSet::KEEP_SLOT |
| 28 : SlotSet::REMOVE_SLOT; |
| 29 }); |
| 30 } |
| 31 } |
| 32 } |
| 33 |
| 34 template <PointerDirection direction> |
| 35 void RememberedSet<direction>::VerifyValidSlots(Heap* heap) { |
| 36 STATIC_ASSERT(direction == OLD_TO_NEW); |
| 37 Iterate(heap, [heap](Address addr) { |
| 38 Object** slot = reinterpret_cast<Object**>(addr); |
| 39 Object* object = *slot; |
| 40 if (Page::FromAddress(addr)->owner() != nullptr && |
| 41 Page::FromAddress(addr)->owner()->identity() == OLD_SPACE) { |
| 42 CHECK(IsValidSlot(heap, slot)); |
| 43 heap->mark_compact_collector()->VerifyIsSlotInLiveObject( |
| 44 reinterpret_cast<Address>(slot), HeapObject::cast(object)); |
| 45 } |
| 46 return SlotSet::KEEP_SLOT; |
| 47 }); |
| 48 } |
| 49 |
| 50 template <PointerDirection direction> |
| 51 bool RememberedSet<direction>::IsValidSlot(Heap* heap, Object** slot) { |
| 52 STATIC_ASSERT(direction == OLD_TO_NEW); |
| 53 Object* object = *slot; |
| 54 if (!heap->InNewSpace(object)) { |
| 55 return false; |
| 56 } |
| 57 HeapObject* heap_object = HeapObject::cast(object); |
| 58 // If the target object is not black, the source slot must be part |
| 59 // of a non-black (dead) object. |
| 60 return Marking::IsBlack(Marking::MarkBitFrom(heap_object)) && |
| 61 heap->mark_compact_collector()->IsSlotInLiveObject( |
| 62 reinterpret_cast<Address>(slot)); |
| 63 } |
| 64 |
| 65 template void RememberedSet<OLD_TO_NEW>::ClearInvalidSlots(Heap* heap); |
| 66 template void RememberedSet<OLD_TO_NEW>::VerifyValidSlots(Heap* heap); |
| 67 |
| 68 } // namespace internal |
| 69 } // namespace v8 |
OLD | NEW |