| 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 #ifndef V8_REMEMBERED_SET_H | 5 #ifndef V8_REMEMBERED_SET_H |
| 6 #define V8_REMEMBERED_SET_H | 6 #define V8_REMEMBERED_SET_H |
| 7 | 7 |
| 8 #include "src/assembler.h" | 8 #include "src/assembler.h" |
| 9 #include "src/heap/heap.h" | 9 #include "src/heap/heap.h" |
| 10 #include "src/heap/slot-set.h" | 10 #include "src/heap/slot-set.h" |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 DCHECK_LT(host_offset, static_cast<uintptr_t>(TypedSlotSet::kMaxOffset)); | 142 DCHECK_LT(host_offset, static_cast<uintptr_t>(TypedSlotSet::kMaxOffset)); |
| 143 slot_set->Insert(slot_type, static_cast<uint32_t>(host_offset), | 143 slot_set->Insert(slot_type, static_cast<uint32_t>(host_offset), |
| 144 static_cast<uint32_t>(offset)); | 144 static_cast<uint32_t>(offset)); |
| 145 } | 145 } |
| 146 | 146 |
| 147 // Given a page and a range of typed slots in that page, this function removes | 147 // Given a page and a range of typed slots in that page, this function removes |
| 148 // the slots from the remembered set. | 148 // the slots from the remembered set. |
| 149 static void RemoveRangeTyped(MemoryChunk* page, Address start, Address end) { | 149 static void RemoveRangeTyped(MemoryChunk* page, Address start, Address end) { |
| 150 TypedSlotSet* slots = GetTypedSlotSet(page); | 150 TypedSlotSet* slots = GetTypedSlotSet(page); |
| 151 if (slots != nullptr) { | 151 if (slots != nullptr) { |
| 152 slots->Iterate( | 152 slots->Iterate([start, end](SlotType slot_type, Address host_addr, |
| 153 [start, end](SlotType slot_type, Address host_addr, | 153 Address slot_addr) { |
| 154 Address slot_addr) { | 154 return start <= slot_addr && slot_addr < end ? REMOVE_SLOT : KEEP_SLOT; |
| 155 return start <= slot_addr && slot_addr < end ? REMOVE_SLOT | 155 }); |
| 156 : KEEP_SLOT; | |
| 157 }, | |
| 158 TypedSlotSet::PREFREE_EMPTY_CHUNKS); | |
| 159 } | 156 } |
| 160 } | 157 } |
| 161 | 158 |
| 162 // Iterates and filters the remembered set with the given callback. | 159 // Iterates and filters the remembered set with the given callback. |
| 163 // The callback should take (SlotType slot_type, SlotAddress slot) and return | 160 // The callback should take (SlotType slot_type, SlotAddress slot) and return |
| 164 // SlotCallbackResult. | 161 // SlotCallbackResult. |
| 165 template <typename Callback> | 162 template <typename Callback> |
| 166 static void IterateTyped(Heap* heap, Callback callback) { | 163 static void IterateTyped(Heap* heap, Callback callback) { |
| 167 IterateMemoryChunks(heap, [callback](MemoryChunk* chunk) { | 164 IterateMemoryChunks(heap, [callback](MemoryChunk* chunk) { |
| 168 IterateTyped(chunk, callback); | 165 IterateTyped(chunk, callback); |
| 169 }); | 166 }); |
| 170 } | 167 } |
| 171 | 168 |
| 172 // Iterates and filters typed old to old pointers in the given memory chunk | 169 // Iterates and filters typed old to old pointers in the given memory chunk |
| 173 // with the given callback. The callback should take (SlotType slot_type, | 170 // with the given callback. The callback should take (SlotType slot_type, |
| 174 // Address slot_addr) and return SlotCallbackResult. | 171 // Address slot_addr) and return SlotCallbackResult. |
| 175 template <typename Callback> | 172 template <typename Callback> |
| 176 static void IterateTyped(MemoryChunk* chunk, Callback callback) { | 173 static void IterateTyped(MemoryChunk* chunk, Callback callback) { |
| 177 TypedSlotSet* slots = GetTypedSlotSet(chunk); | 174 TypedSlotSet* slots = GetTypedSlotSet(chunk); |
| 178 if (slots != nullptr) { | 175 if (slots != nullptr) { |
| 179 int new_count = slots->Iterate(callback, TypedSlotSet::KEEP_EMPTY_CHUNKS); | 176 int new_count = slots->Iterate(callback); |
| 180 if (new_count == 0) { | 177 if (new_count == 0) { |
| 181 ReleaseTypedSlotSet(chunk); | 178 ReleaseTypedSlotSet(chunk); |
| 182 } | 179 } |
| 183 } | 180 } |
| 184 } | 181 } |
| 185 | 182 |
| 186 // Clear all old to old slots from the remembered set. | 183 // Clear all old to old slots from the remembered set. |
| 187 static void ClearAll(Heap* heap) { | 184 static void ClearAll(Heap* heap) { |
| 188 STATIC_ASSERT(direction == OLD_TO_OLD); | 185 STATIC_ASSERT(direction == OLD_TO_OLD); |
| 189 MemoryChunkIterator it(heap); | 186 MemoryChunkIterator it(heap); |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 return DEBUG_TARGET_SLOT; | 382 return DEBUG_TARGET_SLOT; |
| 386 } | 383 } |
| 387 UNREACHABLE(); | 384 UNREACHABLE(); |
| 388 return CLEARED_SLOT; | 385 return CLEARED_SLOT; |
| 389 } | 386 } |
| 390 | 387 |
| 391 } // namespace internal | 388 } // namespace internal |
| 392 } // namespace v8 | 389 } // namespace v8 |
| 393 | 390 |
| 394 #endif // V8_REMEMBERED_SET_H | 391 #endif // V8_REMEMBERED_SET_H |
| OLD | NEW |