| 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" |
| 11 #include "src/heap/store-buffer.h" | 11 #include "src/heap/store-buffer.h" |
| 12 #include "src/macro-assembler.h" | 12 #include "src/macro-assembler.h" |
| 13 | 13 |
| 14 namespace v8 { | 14 namespace v8 { |
| 15 namespace internal { | 15 namespace internal { |
| 16 | 16 |
| 17 template <PointerDirection direction> | 17 template <PointerDirection direction> |
| 18 void RememberedSet<direction>::ClearInvalidSlots(Heap* heap) { | 18 void RememberedSet<direction>::ClearInvalidSlots(Heap* heap) { |
| 19 STATIC_ASSERT(direction == OLD_TO_NEW); | 19 STATIC_ASSERT(direction == OLD_TO_NEW); |
| 20 for (MemoryChunk* chunk : *heap->old_space()) { | 20 for (MemoryChunk* chunk : *heap->old_space()) { |
| 21 SlotSet* slots = GetSlotSet(chunk); | 21 SlotSet* slots = GetSlotSet(chunk); |
| 22 if (slots != nullptr) { | 22 if (slots != nullptr) { |
| 23 slots->Iterate([heap, chunk](Address addr) { | 23 slots->Iterate( |
| 24 Object** slot = reinterpret_cast<Object**>(addr); | 24 [heap, chunk](Address addr) { |
| 25 return IsValidSlot(heap, chunk, slot) ? KEEP_SLOT : REMOVE_SLOT; | 25 Object** slot = reinterpret_cast<Object**>(addr); |
| 26 }); | 26 return IsValidSlot(heap, chunk, slot) ? KEEP_SLOT : REMOVE_SLOT; |
| 27 }, |
| 28 SlotSet::PREFREE_EMPTY_BUCKETS); |
| 27 } | 29 } |
| 28 } | 30 } |
| 29 for (MemoryChunk* chunk : *heap->code_space()) { | 31 for (MemoryChunk* chunk : *heap->code_space()) { |
| 30 TypedSlotSet* slots = GetTypedSlotSet(chunk); | 32 TypedSlotSet* slots = GetTypedSlotSet(chunk); |
| 31 if (slots != nullptr) { | 33 if (slots != nullptr) { |
| 32 slots->Iterate( | 34 slots->Iterate( |
| 33 [heap, chunk](SlotType type, Address host_addr, Address addr) { | 35 [heap, chunk](SlotType type, Address host_addr, Address addr) { |
| 34 if (Marking::IsBlack(ObjectMarking::MarkBitFrom(host_addr))) { | 36 if (Marking::IsBlack(ObjectMarking::MarkBitFrom(host_addr))) { |
| 35 return KEEP_SLOT; | 37 return KEEP_SLOT; |
| 36 } else { | 38 } else { |
| 37 return REMOVE_SLOT; | 39 return REMOVE_SLOT; |
| 38 } | 40 } |
| 39 }, | 41 }, |
| 40 TypedSlotSet::PREFREE_EMPTY_CHUNKS); | 42 TypedSlotSet::PREFREE_EMPTY_CHUNKS); |
| 41 } | 43 } |
| 42 } | 44 } |
| 43 for (MemoryChunk* chunk : *heap->map_space()) { | 45 for (MemoryChunk* chunk : *heap->map_space()) { |
| 44 SlotSet* slots = GetSlotSet(chunk); | 46 SlotSet* slots = GetSlotSet(chunk); |
| 45 if (slots != nullptr) { | 47 if (slots != nullptr) { |
| 46 slots->Iterate([heap, chunk](Address addr) { | 48 slots->Iterate( |
| 47 Object** slot = reinterpret_cast<Object**>(addr); | 49 [heap, chunk](Address addr) { |
| 48 // TODO(mlippautz): In map space all allocations would ideally be map | 50 Object** slot = reinterpret_cast<Object**>(addr); |
| 49 // aligned. After establishing this invariant IsValidSlot could just | 51 // TODO(mlippautz): In map space all allocations would ideally be |
| 50 // refer to the containing object using alignment and check the mark | 52 // map |
| 51 // bits. | 53 // aligned. After establishing this invariant IsValidSlot could just |
| 52 return IsValidSlot(heap, chunk, slot) ? KEEP_SLOT : REMOVE_SLOT; | 54 // refer to the containing object using alignment and check the mark |
| 53 }); | 55 // bits. |
| 56 return IsValidSlot(heap, chunk, slot) ? KEEP_SLOT : REMOVE_SLOT; |
| 57 }, |
| 58 SlotSet::PREFREE_EMPTY_BUCKETS); |
| 54 } | 59 } |
| 55 } | 60 } |
| 56 } | 61 } |
| 57 | 62 |
| 58 template <PointerDirection direction> | 63 template <PointerDirection direction> |
| 59 void RememberedSet<direction>::VerifyValidSlots(Heap* heap) { | 64 void RememberedSet<direction>::VerifyValidSlots(Heap* heap) { |
| 60 Iterate(heap, [heap](Address addr) { | 65 Iterate(heap, [heap](Address addr) { |
| 61 HeapObject* obj = | 66 HeapObject* obj = |
| 62 heap->mark_compact_collector()->FindBlackObjectBySlotSlow(addr); | 67 heap->mark_compact_collector()->FindBlackObjectBySlotSlow(addr); |
| 63 if (obj == nullptr) { | 68 if (obj == nullptr) { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 93 heap->mark_compact_collector()->IsSlotInBlackObject( | 98 heap->mark_compact_collector()->IsSlotInBlackObject( |
| 94 chunk, reinterpret_cast<Address>(slot)); | 99 chunk, reinterpret_cast<Address>(slot)); |
| 95 } | 100 } |
| 96 | 101 |
| 97 template void RememberedSet<OLD_TO_NEW>::ClearInvalidSlots(Heap* heap); | 102 template void RememberedSet<OLD_TO_NEW>::ClearInvalidSlots(Heap* heap); |
| 98 template void RememberedSet<OLD_TO_NEW>::VerifyValidSlots(Heap* heap); | 103 template void RememberedSet<OLD_TO_NEW>::VerifyValidSlots(Heap* heap); |
| 99 template void RememberedSet<OLD_TO_OLD>::VerifyValidSlots(Heap* heap); | 104 template void RememberedSet<OLD_TO_OLD>::VerifyValidSlots(Heap* heap); |
| 100 | 105 |
| 101 } // namespace internal | 106 } // namespace internal |
| 102 } // namespace v8 | 107 } // namespace v8 |
| OLD | NEW |