OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/heap/remembered-set.h" | 5 #include "src/heap/remembered-set.h" |
6 #include "src/heap/heap-inl.h" | 6 #include "src/heap/heap-inl.h" |
7 #include "src/heap/heap.h" | 7 #include "src/heap/heap.h" |
8 #include "src/heap/mark-compact.h" | 8 #include "src/heap/mark-compact.h" |
9 #include "src/heap/slot-set.h" | 9 #include "src/heap/slot-set.h" |
10 #include "src/heap/spaces.h" | 10 #include "src/heap/spaces.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 slots->Iterate( | 32 slots->Iterate( |
33 [heap, chunk](SlotType type, Address host_addr, Address addr) { | 33 [heap, chunk](SlotType type, Address host_addr, Address addr) { |
34 if (Marking::IsBlack(Marking::MarkBitFrom(host_addr))) { | 34 if (Marking::IsBlack(Marking::MarkBitFrom(host_addr))) { |
35 return KEEP_SLOT; | 35 return KEEP_SLOT; |
36 } else { | 36 } else { |
37 return REMOVE_SLOT; | 37 return REMOVE_SLOT; |
38 } | 38 } |
39 }); | 39 }); |
40 } | 40 } |
41 } | 41 } |
| 42 if (Heap::ShouldZapGarbage()) { |
| 43 // Need to filter invalid slots as we overwrite them with zap values in |
| 44 // during sweeping which runs concurrently with pointer updating. |
| 45 for (MemoryChunk* chunk : *heap->map_space()) { |
| 46 SlotSet* slots = GetSlotSet(chunk); |
| 47 if (slots != nullptr) { |
| 48 slots->Iterate([heap, chunk](Address addr) { |
| 49 Object** slot = reinterpret_cast<Object**>(addr); |
| 50 return IsValidSlot(heap, chunk, slot) ? KEEP_SLOT : REMOVE_SLOT; |
| 51 }); |
| 52 } |
| 53 } |
| 54 } |
42 } | 55 } |
43 | 56 |
44 template <PointerDirection direction> | 57 template <PointerDirection direction> |
45 void RememberedSet<direction>::VerifyValidSlots(Heap* heap) { | 58 void RememberedSet<direction>::VerifyValidSlots(Heap* heap) { |
46 Iterate(heap, [heap](Address addr) { | 59 Iterate(heap, [heap](Address addr) { |
47 HeapObject* obj = | 60 HeapObject* obj = |
48 heap->mark_compact_collector()->FindBlackObjectBySlotSlow(addr); | 61 heap->mark_compact_collector()->FindBlackObjectBySlotSlow(addr); |
49 if (obj == nullptr) { | 62 if (obj == nullptr) { |
50 // The slot is in dead object. | 63 // The slot is in dead object. |
51 MemoryChunk* chunk = MemoryChunk::FromAnyPointerAddress(heap, addr); | 64 MemoryChunk* chunk = MemoryChunk::FromAnyPointerAddress(heap, addr); |
(...skipping 27 matching lines...) Expand all Loading... |
79 heap->mark_compact_collector()->IsSlotInBlackObject( | 92 heap->mark_compact_collector()->IsSlotInBlackObject( |
80 chunk, reinterpret_cast<Address>(slot)); | 93 chunk, reinterpret_cast<Address>(slot)); |
81 } | 94 } |
82 | 95 |
83 template void RememberedSet<OLD_TO_NEW>::ClearInvalidSlots(Heap* heap); | 96 template void RememberedSet<OLD_TO_NEW>::ClearInvalidSlots(Heap* heap); |
84 template void RememberedSet<OLD_TO_NEW>::VerifyValidSlots(Heap* heap); | 97 template void RememberedSet<OLD_TO_NEW>::VerifyValidSlots(Heap* heap); |
85 template void RememberedSet<OLD_TO_OLD>::VerifyValidSlots(Heap* heap); | 98 template void RememberedSet<OLD_TO_OLD>::VerifyValidSlots(Heap* heap); |
86 | 99 |
87 } // namespace internal | 100 } // namespace internal |
88 } // namespace v8 | 101 } // namespace v8 |
OLD | NEW |