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, | |
19 MemoryChunk* chunk) { | |
20 STATIC_ASSERT(direction == OLD_TO_NEW); | |
21 DCHECK(chunk->owner()->identity() == OLD_SPACE || | |
22 chunk->owner()->identity() == MAP_SPACE); | |
23 SlotSet* slots = GetSlotSet(chunk); | |
24 if (slots != nullptr) { | |
25 slots->Iterate( | |
26 [heap, chunk](Address addr) { | |
27 Object** slot = reinterpret_cast<Object**>(addr); | |
28 return IsValidSlot(heap, chunk, slot) ? KEEP_SLOT : REMOVE_SLOT; | |
29 }, | |
30 SlotSet::KEEP_EMPTY_BUCKETS); | |
31 } | |
32 } | |
33 | |
34 template <PointerDirection direction> | |
35 void RememberedSet<direction>::ClearInvalidTypedSlots(Heap* heap, | 18 void RememberedSet<direction>::ClearInvalidTypedSlots(Heap* heap, |
36 MemoryChunk* chunk) { | 19 MemoryChunk* chunk) { |
37 STATIC_ASSERT(direction == OLD_TO_NEW); | 20 STATIC_ASSERT(direction == OLD_TO_NEW); |
38 DCHECK(chunk->owner()->identity() == CODE_SPACE); | 21 DCHECK(chunk->owner()->identity() == CODE_SPACE); |
39 TypedSlotSet* slots = GetTypedSlotSet(chunk); | 22 TypedSlotSet* slots = GetTypedSlotSet(chunk); |
40 if (slots != nullptr) { | 23 if (slots != nullptr) { |
41 slots->Iterate( | 24 slots->Iterate( |
42 [heap, chunk](SlotType type, Address host_addr, Address addr) { | 25 [heap, chunk](SlotType type, Address host_addr, Address addr) { |
43 if (Marking::IsBlack(ObjectMarking::MarkBitFrom(host_addr))) { | 26 if (Marking::IsBlack(ObjectMarking::MarkBitFrom(host_addr))) { |
44 return KEEP_SLOT; | 27 return KEEP_SLOT; |
45 } else { | 28 } else { |
46 return REMOVE_SLOT; | 29 return REMOVE_SLOT; |
47 } | 30 } |
48 }, | 31 }, |
49 TypedSlotSet::KEEP_EMPTY_CHUNKS); | 32 TypedSlotSet::KEEP_EMPTY_CHUNKS); |
50 } | 33 } |
51 } | 34 } |
52 | 35 |
53 template <PointerDirection direction> | 36 template <PointerDirection direction> |
54 bool RememberedSet<direction>::IsValidSlot(Heap* heap, MemoryChunk* chunk, | 37 bool RememberedSet<direction>::IsValidSlot(Heap* heap, MemoryChunk* chunk, |
55 Object** slot) { | 38 Object** slot) { |
56 STATIC_ASSERT(direction == OLD_TO_NEW); | 39 STATIC_ASSERT(direction == OLD_TO_NEW); |
57 // If the target object is not black, the source slot must be part | 40 // If the target object is not black, the source slot must be part |
58 // of a non-black (dead) object. | 41 // of a non-black (dead) object. |
59 return heap->mark_compact_collector()->IsSlotInBlackObject( | 42 return heap->mark_compact_collector()->IsSlotInBlackObject( |
60 chunk, reinterpret_cast<Address>(slot)); | 43 chunk, reinterpret_cast<Address>(slot)); |
61 } | 44 } |
62 | 45 |
63 template void RememberedSet<OLD_TO_NEW>::ClearInvalidSlots(Heap* heap, | |
64 MemoryChunk* chunk); | |
65 template void RememberedSet<OLD_TO_NEW>::ClearInvalidTypedSlots( | 46 template void RememberedSet<OLD_TO_NEW>::ClearInvalidTypedSlots( |
66 Heap* heap, MemoryChunk* chunk); | 47 Heap* heap, MemoryChunk* chunk); |
67 | 48 |
68 } // namespace internal | 49 } // namespace internal |
69 } // namespace v8 | 50 } // namespace v8 |
OLD | NEW |