| 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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 // Iterates and filters the remembered set in the given memory chunk with | 109 // Iterates and filters the remembered set in the given memory chunk with |
| 110 // the given callback. The callback should take (Address slot) and return | 110 // the given callback. The callback should take (Address slot) and return |
| 111 // SlotCallbackResult. | 111 // SlotCallbackResult. |
| 112 template <typename Callback> | 112 template <typename Callback> |
| 113 static void Iterate(MemoryChunk* chunk, Callback callback) { | 113 static void Iterate(MemoryChunk* chunk, Callback callback) { |
| 114 SlotSet* slots = GetSlotSet(chunk); | 114 SlotSet* slots = GetSlotSet(chunk); |
| 115 if (slots != nullptr) { | 115 if (slots != nullptr) { |
| 116 size_t pages = (chunk->size() + Page::kPageSize - 1) / Page::kPageSize; | 116 size_t pages = (chunk->size() + Page::kPageSize - 1) / Page::kPageSize; |
| 117 int new_count = 0; | 117 int new_count = 0; |
| 118 for (size_t page = 0; page < pages; page++) { | 118 for (size_t page = 0; page < pages; page++) { |
| 119 new_count += slots[page].Iterate(callback); | 119 new_count += |
| 120 slots[page].Iterate(callback, SlotSet::PREFREE_EMPTY_BUCKETS); |
| 120 } | 121 } |
| 121 if (new_count == 0) { | 122 // Only old-to-old slot sets are released eagerly. Old-new-slot sets are |
| 122 ReleaseSlotSet(chunk); | 123 // released by the sweeper threads. |
| 124 if (direction == OLD_TO_OLD && new_count == 0) { |
| 125 chunk->ReleaseOldToOldSlots(); |
| 123 } | 126 } |
| 124 } | 127 } |
| 125 } | 128 } |
| 126 | 129 |
| 127 // Given a page and a typed slot in that page, this function adds the slot | 130 // Given a page and a typed slot in that page, this function adds the slot |
| 128 // to the remembered set. | 131 // to the remembered set. |
| 129 static void InsertTyped(Page* page, Address host_addr, SlotType slot_type, | 132 static void InsertTyped(Page* page, Address host_addr, SlotType slot_type, |
| 130 Address slot_addr) { | 133 Address slot_addr) { |
| 131 TypedSlotSet* slot_set = GetTypedSlotSet(page); | 134 TypedSlotSet* slot_set = GetTypedSlotSet(page); |
| 132 if (slot_set == nullptr) { | 135 if (slot_set == nullptr) { |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 } | 215 } |
| 213 | 216 |
| 214 static TypedSlotSet* GetTypedSlotSet(MemoryChunk* chunk) { | 217 static TypedSlotSet* GetTypedSlotSet(MemoryChunk* chunk) { |
| 215 if (direction == OLD_TO_OLD) { | 218 if (direction == OLD_TO_OLD) { |
| 216 return chunk->typed_old_to_old_slots(); | 219 return chunk->typed_old_to_old_slots(); |
| 217 } else { | 220 } else { |
| 218 return chunk->typed_old_to_new_slots(); | 221 return chunk->typed_old_to_new_slots(); |
| 219 } | 222 } |
| 220 } | 223 } |
| 221 | 224 |
| 222 static void ReleaseSlotSet(MemoryChunk* chunk) { | |
| 223 if (direction == OLD_TO_OLD) { | |
| 224 chunk->ReleaseOldToOldSlots(); | |
| 225 } else { | |
| 226 chunk->ReleaseOldToNewSlots(); | |
| 227 } | |
| 228 } | |
| 229 | |
| 230 static void ReleaseTypedSlotSet(MemoryChunk* chunk) { | 225 static void ReleaseTypedSlotSet(MemoryChunk* chunk) { |
| 231 if (direction == OLD_TO_OLD) { | 226 if (direction == OLD_TO_OLD) { |
| 232 chunk->ReleaseTypedOldToOldSlots(); | 227 chunk->ReleaseTypedOldToOldSlots(); |
| 233 } | 228 } |
| 234 } | 229 } |
| 235 | 230 |
| 236 static SlotSet* AllocateSlotSet(MemoryChunk* chunk) { | 231 static SlotSet* AllocateSlotSet(MemoryChunk* chunk) { |
| 237 if (direction == OLD_TO_OLD) { | 232 if (direction == OLD_TO_OLD) { |
| 238 chunk->AllocateOldToOldSlots(); | 233 chunk->AllocateOldToOldSlots(); |
| 239 return chunk->old_to_old_slots(); | 234 return chunk->old_to_old_slots(); |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 return DEBUG_TARGET_SLOT; | 378 return DEBUG_TARGET_SLOT; |
| 384 } | 379 } |
| 385 UNREACHABLE(); | 380 UNREACHABLE(); |
| 386 return CLEARED_SLOT; | 381 return CLEARED_SLOT; |
| 387 } | 382 } |
| 388 | 383 |
| 389 } // namespace internal | 384 } // namespace internal |
| 390 } // namespace v8 | 385 } // namespace v8 |
| 391 | 386 |
| 392 #endif // V8_REMEMBERED_SET_H | 387 #endif // V8_REMEMBERED_SET_H |
| OLD | NEW |