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/heap/heap.h" | 8 #include "src/heap/heap.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 23 matching lines...) Expand all Loading... |
34 // If the slot was never added, then the function does nothing. | 34 // If the slot was never added, then the function does nothing. |
35 static void Remove(Page* page, Address slot_addr) { | 35 static void Remove(Page* page, Address slot_addr) { |
36 DCHECK(page->Contains(slot_addr)); | 36 DCHECK(page->Contains(slot_addr)); |
37 SlotSet* slot_set = GetSlotSet(page); | 37 SlotSet* slot_set = GetSlotSet(page); |
38 if (slot_set != nullptr) { | 38 if (slot_set != nullptr) { |
39 uintptr_t offset = slot_addr - page->address(); | 39 uintptr_t offset = slot_addr - page->address(); |
40 slot_set[offset / Page::kPageSize].Remove(offset % Page::kPageSize); | 40 slot_set[offset / Page::kPageSize].Remove(offset % Page::kPageSize); |
41 } | 41 } |
42 } | 42 } |
43 | 43 |
| 44 // Given a page and a range of slots in that page, this function removes the |
| 45 // slots from the remembered set. |
| 46 static void RemoveRange(Page* page, Address start, Address end) { |
| 47 SlotSet* slot_set = GetSlotSet(page); |
| 48 if (slot_set != nullptr) { |
| 49 uintptr_t start_offset = start - page->address(); |
| 50 uintptr_t end_offset = end - page->address(); |
| 51 DCHECK_LT(start_offset, end_offset); |
| 52 DCHECK_LE(end_offset, static_cast<uintptr_t>(Page::kPageSize)); |
| 53 slot_set->RemoveRange(static_cast<uint32_t>(start_offset), |
| 54 static_cast<uint32_t>(end_offset)); |
| 55 } |
| 56 } |
| 57 |
44 // Iterates and filters the remembered set with the given callback. | 58 // Iterates and filters the remembered set with the given callback. |
45 // The callback should take (Address slot) and return SlotSet::CallbackResult. | 59 // The callback should take (Address slot) and return SlotSet::CallbackResult. |
46 template <typename Callback> | 60 template <typename Callback> |
47 static void Iterate(Heap* heap, Callback callback) { | 61 static void Iterate(Heap* heap, Callback callback) { |
48 PointerChunkIterator it(heap); | 62 PointerChunkIterator it(heap); |
49 MemoryChunk* chunk; | 63 MemoryChunk* chunk; |
50 while ((chunk = it.next()) != nullptr) { | 64 while ((chunk = it.next()) != nullptr) { |
51 SlotSet* slots = GetSlotSet(chunk); | 65 SlotSet* slots = GetSlotSet(chunk); |
52 if (slots != nullptr) { | 66 if (slots != nullptr) { |
53 size_t pages = (chunk->size() + Page::kPageSize - 1) / Page::kPageSize; | 67 size_t pages = (chunk->size() + Page::kPageSize - 1) / Page::kPageSize; |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 return SlotSet::REMOVE_SLOT; | 148 return SlotSet::REMOVE_SLOT; |
135 } | 149 } |
136 | 150 |
137 static bool IsValidSlot(Heap* heap, Object** slot); | 151 static bool IsValidSlot(Heap* heap, Object** slot); |
138 }; | 152 }; |
139 | 153 |
140 } // namespace internal | 154 } // namespace internal |
141 } // namespace v8 | 155 } // namespace v8 |
142 | 156 |
143 #endif // V8_REMEMBERED_SET_H | 157 #endif // V8_REMEMBERED_SET_H |
OLD | NEW |