Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(141)

Side by Side Diff: src/heap/remembered-set.h

Issue 2397373002: [heap] Use the thread-safe free modes also for RemoveRange in SlotSet. (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 27 matching lines...) Expand all
38 DCHECK(chunk->Contains(slot_addr)); 38 DCHECK(chunk->Contains(slot_addr));
39 SlotSet* slot_set = GetSlotSet(chunk); 39 SlotSet* slot_set = GetSlotSet(chunk);
40 if (slot_set != nullptr) { 40 if (slot_set != nullptr) {
41 uintptr_t offset = slot_addr - chunk->address(); 41 uintptr_t offset = slot_addr - chunk->address();
42 slot_set[offset / Page::kPageSize].Remove(offset % Page::kPageSize); 42 slot_set[offset / Page::kPageSize].Remove(offset % Page::kPageSize);
43 } 43 }
44 } 44 }
45 45
46 // Given a page and a range of slots in that page, this function removes the 46 // Given a page and a range of slots in that page, this function removes the
47 // slots from the remembered set. 47 // slots from the remembered set.
48 static void RemoveRange(MemoryChunk* chunk, Address start, Address end) { 48 static void RemoveRange(MemoryChunk* chunk, Address start, Address end,
49 SlotSet::EmptyBucketMode mode) {
49 SlotSet* slot_set = GetSlotSet(chunk); 50 SlotSet* slot_set = GetSlotSet(chunk);
50 if (slot_set != nullptr) { 51 if (slot_set != nullptr) {
51 uintptr_t start_offset = start - chunk->address(); 52 uintptr_t start_offset = start - chunk->address();
52 uintptr_t end_offset = end - chunk->address(); 53 uintptr_t end_offset = end - chunk->address();
53 DCHECK_LT(start_offset, end_offset); 54 DCHECK_LT(start_offset, end_offset);
54 if (end_offset < static_cast<uintptr_t>(Page::kPageSize)) { 55 if (end_offset < static_cast<uintptr_t>(Page::kPageSize)) {
55 slot_set->RemoveRange(static_cast<int>(start_offset), 56 slot_set->RemoveRange(static_cast<int>(start_offset),
56 static_cast<int>(end_offset)); 57 static_cast<int>(end_offset), mode);
57 } else { 58 } else {
58 // The large page has multiple slot sets. 59 // The large page has multiple slot sets.
59 // Compute slot set indicies for the range [start_offset, end_offset). 60 // Compute slot set indicies for the range [start_offset, end_offset).
60 int start_chunk = static_cast<int>(start_offset / Page::kPageSize); 61 int start_chunk = static_cast<int>(start_offset / Page::kPageSize);
61 int end_chunk = static_cast<int>((end_offset - 1) / Page::kPageSize); 62 int end_chunk = static_cast<int>((end_offset - 1) / Page::kPageSize);
62 int offset_in_start_chunk = 63 int offset_in_start_chunk =
63 static_cast<int>(start_offset % Page::kPageSize); 64 static_cast<int>(start_offset % Page::kPageSize);
64 // Note that using end_offset % Page::kPageSize would be incorrect 65 // Note that using end_offset % Page::kPageSize would be incorrect
65 // because end_offset is one beyond the last slot to clear. 66 // because end_offset is one beyond the last slot to clear.
66 int offset_in_end_chunk = static_cast<int>( 67 int offset_in_end_chunk = static_cast<int>(
67 end_offset - static_cast<uintptr_t>(end_chunk) * Page::kPageSize); 68 end_offset - static_cast<uintptr_t>(end_chunk) * Page::kPageSize);
68 if (start_chunk == end_chunk) { 69 if (start_chunk == end_chunk) {
69 slot_set[start_chunk].RemoveRange(offset_in_start_chunk, 70 slot_set[start_chunk].RemoveRange(offset_in_start_chunk,
70 offset_in_end_chunk); 71 offset_in_end_chunk, mode);
71 } else { 72 } else {
72 // Clear all slots from start_offset to the end of first chunk. 73 // Clear all slots from start_offset to the end of first chunk.
73 slot_set[start_chunk].RemoveRange(offset_in_start_chunk, 74 slot_set[start_chunk].RemoveRange(offset_in_start_chunk,
74 Page::kPageSize); 75 Page::kPageSize, mode);
75 // Clear all slots in intermediate chunks. 76 // Clear all slots in intermediate chunks.
76 for (int i = start_chunk + 1; i < end_chunk; i++) { 77 for (int i = start_chunk + 1; i < end_chunk; i++) {
77 slot_set[i].RemoveRange(0, Page::kPageSize); 78 slot_set[i].RemoveRange(0, Page::kPageSize, mode);
78 } 79 }
79 // Clear slots from the beginning of the last page to end_offset. 80 // Clear slots from the beginning of the last page to end_offset.
80 slot_set[end_chunk].RemoveRange(0, offset_in_end_chunk); 81 slot_set[end_chunk].RemoveRange(0, offset_in_end_chunk, mode);
81 } 82 }
82 } 83 }
83 } 84 }
84 } 85 }
85 86
86 // Iterates and filters the remembered set with the given callback. 87 // Iterates and filters the remembered set with the given callback.
87 // The callback should take (Address slot) and return SlotCallbackResult. 88 // The callback should take (Address slot) and return SlotCallbackResult.
88 template <typename Callback> 89 template <typename Callback>
89 static void Iterate(Heap* heap, Callback callback) { 90 static void Iterate(Heap* heap, Callback callback) {
90 IterateMemoryChunks( 91 IterateMemoryChunks(
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 return DEBUG_TARGET_SLOT; 379 return DEBUG_TARGET_SLOT;
379 } 380 }
380 UNREACHABLE(); 381 UNREACHABLE();
381 return CLEARED_SLOT; 382 return CLEARED_SLOT;
382 } 383 }
383 384
384 } // namespace internal 385 } // namespace internal
385 } // namespace v8 386 } // namespace v8
386 387
387 #endif // V8_REMEMBERED_SET_H 388 #endif // V8_REMEMBERED_SET_H
OLDNEW
« src/heap/heap.cc ('K') | « src/heap/mark-compact.cc ('k') | src/heap/slot-set.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698