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 15 matching lines...) Expand all Loading... |
26 Object** slot = reinterpret_cast<Object**>(addr); | 26 Object** slot = reinterpret_cast<Object**>(addr); |
27 return IsValidSlot(heap, slot) ? KEEP_SLOT : REMOVE_SLOT; | 27 return IsValidSlot(heap, slot) ? KEEP_SLOT : REMOVE_SLOT; |
28 }); | 28 }); |
29 } | 29 } |
30 } | 30 } |
31 } | 31 } |
32 | 32 |
33 template <PointerDirection direction> | 33 template <PointerDirection direction> |
34 void RememberedSet<direction>::VerifyValidSlots(Heap* heap) { | 34 void RememberedSet<direction>::VerifyValidSlots(Heap* heap) { |
35 Iterate(heap, [heap](Address addr) { | 35 Iterate(heap, [heap](Address addr) { |
36 HeapObject* obj = | 36 if (!Page::FromAddress(addr)->IsFlagSet(Page::BLACK_PAGE)) { |
37 heap->mark_compact_collector()->FindBlackObjectBySlotSlow(addr); | 37 HeapObject* obj = |
38 if (obj == nullptr) { | 38 heap->mark_compact_collector()->FindBlackObjectBySlotSlow(addr); |
39 // The slot is in dead object. | 39 if (obj == nullptr) { |
40 MemoryChunk* chunk = MemoryChunk::FromAnyPointerAddress(heap, addr); | 40 // The slot is in dead object. |
41 AllocationSpace owner = chunk->owner()->identity(); | 41 MemoryChunk* chunk = MemoryChunk::FromAnyPointerAddress(heap, addr); |
42 // The old to old remembered set should not have dead slots. | 42 AllocationSpace owner = chunk->owner()->identity(); |
43 CHECK_NE(direction, OLD_TO_OLD); | 43 // The old to old remembered set should not have dead slots. |
44 // The old to new remembered set is allowed to have slots in dead | 44 CHECK_NE(direction, OLD_TO_OLD); |
45 // objects only in map and large object space because these spaces cannot | 45 // The old to new remembered set is allowed to have slots in dead |
46 // have raw untaged pointers. | 46 // objects only in map and large object space because these space |
47 CHECK(owner == MAP_SPACE || owner == LO_SPACE); | 47 // cannot have raw untagged pointers. |
48 } else { | 48 CHECK(owner == MAP_SPACE || owner == LO_SPACE); |
49 int offset = static_cast<int>(addr - obj->address()); | 49 } else { |
50 CHECK(obj->IsValidSlot(offset)); | 50 int offset = static_cast<int>(addr - obj->address()); |
| 51 CHECK(obj->IsValidSlot(offset)); |
| 52 } |
51 } | 53 } |
52 return KEEP_SLOT; | 54 return KEEP_SLOT; |
53 }); | 55 }); |
54 } | 56 } |
55 | 57 |
56 template <PointerDirection direction> | 58 template <PointerDirection direction> |
57 bool RememberedSet<direction>::IsValidSlot(Heap* heap, Object** slot) { | 59 bool RememberedSet<direction>::IsValidSlot(Heap* heap, Object** slot) { |
58 STATIC_ASSERT(direction == OLD_TO_NEW); | 60 STATIC_ASSERT(direction == OLD_TO_NEW); |
59 Object* object = *slot; | 61 Object* object = *slot; |
60 if (!heap->InNewSpace(object)) { | 62 if (!heap->InNewSpace(object)) { |
61 return false; | 63 return false; |
62 } | 64 } |
63 HeapObject* heap_object = HeapObject::cast(object); | 65 HeapObject* heap_object = HeapObject::cast(object); |
64 // If the target object is not black, the source slot must be part | 66 // If the target object is not black, the source slot must be part |
65 // of a non-black (dead) object. | 67 // of a non-black (dead) object. |
66 return Marking::IsBlack(Marking::MarkBitFrom(heap_object)) && | 68 return Marking::IsBlack(Marking::MarkBitFrom(heap_object)) && |
67 heap->mark_compact_collector()->IsSlotInLiveObject( | 69 heap->mark_compact_collector()->IsSlotInLiveObject( |
68 reinterpret_cast<Address>(slot)); | 70 reinterpret_cast<Address>(slot)); |
69 } | 71 } |
70 | 72 |
71 template void RememberedSet<OLD_TO_NEW>::ClearInvalidSlots(Heap* heap); | 73 template void RememberedSet<OLD_TO_NEW>::ClearInvalidSlots(Heap* heap); |
72 template void RememberedSet<OLD_TO_NEW>::VerifyValidSlots(Heap* heap); | 74 template void RememberedSet<OLD_TO_NEW>::VerifyValidSlots(Heap* heap); |
73 template void RememberedSet<OLD_TO_OLD>::VerifyValidSlots(Heap* heap); | 75 template void RememberedSet<OLD_TO_OLD>::VerifyValidSlots(Heap* heap); |
74 | 76 |
75 } // namespace internal | 77 } // namespace internal |
76 } // namespace v8 | 78 } // namespace v8 |
OLD | NEW |