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 13 matching lines...) Expand all Loading... |
24 static void Insert(MemoryChunk* chunk, Address slot_addr) { | 24 static void Insert(MemoryChunk* chunk, Address slot_addr) { |
25 DCHECK(chunk->Contains(slot_addr)); | 25 DCHECK(chunk->Contains(slot_addr)); |
26 SlotSet* slot_set = GetSlotSet(chunk); | 26 SlotSet* slot_set = GetSlotSet(chunk); |
27 if (slot_set == nullptr) { | 27 if (slot_set == nullptr) { |
28 slot_set = AllocateSlotSet(chunk); | 28 slot_set = AllocateSlotSet(chunk); |
29 } | 29 } |
30 uintptr_t offset = slot_addr - chunk->address(); | 30 uintptr_t offset = slot_addr - chunk->address(); |
31 slot_set[offset / Page::kPageSize].Insert(offset % Page::kPageSize); | 31 slot_set[offset / Page::kPageSize].Insert(offset % Page::kPageSize); |
32 } | 32 } |
33 | 33 |
| 34 // Given a page and a slot in that page, this function returns true if |
| 35 // the remembered set contains the slot. |
| 36 static bool Contains(MemoryChunk* chunk, Address slot_addr) { |
| 37 DCHECK(chunk->Contains(slot_addr)); |
| 38 SlotSet* slot_set = GetSlotSet(chunk); |
| 39 if (slot_set == nullptr) { |
| 40 return false; |
| 41 } |
| 42 uintptr_t offset = slot_addr - chunk->address(); |
| 43 return slot_set[offset / Page::kPageSize].Contains(offset % |
| 44 Page::kPageSize); |
| 45 } |
| 46 |
34 // Given a page and a slot in that page, this function removes the slot from | 47 // Given a page and a slot in that page, this function removes the slot from |
35 // the remembered set. | 48 // the remembered set. |
36 // If the slot was never added, then the function does nothing. | 49 // If the slot was never added, then the function does nothing. |
37 static void Remove(MemoryChunk* chunk, Address slot_addr) { | 50 static void Remove(MemoryChunk* chunk, Address slot_addr) { |
38 DCHECK(chunk->Contains(slot_addr)); | 51 DCHECK(chunk->Contains(slot_addr)); |
39 SlotSet* slot_set = GetSlotSet(chunk); | 52 SlotSet* slot_set = GetSlotSet(chunk); |
40 if (slot_set != nullptr) { | 53 if (slot_set != nullptr) { |
41 uintptr_t offset = slot_addr - chunk->address(); | 54 uintptr_t offset = slot_addr - chunk->address(); |
42 slot_set[offset / Page::kPageSize].Remove(offset % Page::kPageSize); | 55 slot_set[offset / Page::kPageSize].Remove(offset % Page::kPageSize); |
43 } | 56 } |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 return DEBUG_TARGET_SLOT; | 390 return DEBUG_TARGET_SLOT; |
378 } | 391 } |
379 UNREACHABLE(); | 392 UNREACHABLE(); |
380 return CLEARED_SLOT; | 393 return CLEARED_SLOT; |
381 } | 394 } |
382 | 395 |
383 } // namespace internal | 396 } // namespace internal |
384 } // namespace v8 | 397 } // namespace v8 |
385 | 398 |
386 #endif // V8_REMEMBERED_SET_H | 399 #endif // V8_REMEMBERED_SET_H |
OLD | NEW |