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

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

Issue 2781363002: [heap] Take page lock when scavenging old to new references in Scavenger. (Closed)
Patch Set: Created 3 years, 8 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
« src/heap/heap.cc ('K') | « src/heap/mark-compact.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 // Clear slots from the beginning of the last page to end_offset. 91 // Clear slots from the beginning of the last page to end_offset.
92 slot_set[end_chunk].RemoveRange(0, offset_in_end_chunk, mode); 92 slot_set[end_chunk].RemoveRange(0, offset_in_end_chunk, mode);
93 } 93 }
94 } 94 }
95 } 95 }
96 } 96 }
97 97
98 // Iterates and filters the remembered set with the given callback. 98 // Iterates and filters the remembered set with the given callback.
99 // The callback should take (Address slot) and return SlotCallbackResult. 99 // The callback should take (Address slot) and return SlotCallbackResult.
100 template <typename Callback> 100 template <typename Callback>
101 static void Iterate(Heap* heap, Callback callback) { 101 static void Iterate(Heap* heap, bool synchronize, Callback callback) {
102 IterateMemoryChunks( 102 IterateMemoryChunks(heap, [callback, synchronize](MemoryChunk* chunk) {
103 heap, [callback](MemoryChunk* chunk) { Iterate(chunk, callback); }); 103 if (synchronize) chunk->mutex()->Lock();
104 Iterate(chunk, callback);
105 if (synchronize) chunk->mutex()->Unlock();
106 });
104 } 107 }
105 108
106 // Iterates over all memory chunks that contains non-empty slot sets. 109 // Iterates over all memory chunks that contains non-empty slot sets.
107 // The callback should take (MemoryChunk* chunk) and return void. 110 // The callback should take (MemoryChunk* chunk) and return void.
108 template <typename Callback> 111 template <typename Callback>
109 static void IterateMemoryChunks(Heap* heap, Callback callback) { 112 static void IterateMemoryChunks(Heap* heap, Callback callback) {
110 MemoryChunkIterator it(heap); 113 MemoryChunkIterator it(heap);
111 MemoryChunk* chunk; 114 MemoryChunk* chunk;
112 while ((chunk = it.next()) != nullptr) { 115 while ((chunk = it.next()) != nullptr) {
113 SlotSet* slots = chunk->slot_set<type>(); 116 SlotSet* slots = chunk->slot_set<type>();
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 : KEEP_SLOT; 173 : KEEP_SLOT;
171 }, 174 },
172 TypedSlotSet::PREFREE_EMPTY_CHUNKS); 175 TypedSlotSet::PREFREE_EMPTY_CHUNKS);
173 } 176 }
174 } 177 }
175 178
176 // Iterates and filters the remembered set with the given callback. 179 // Iterates and filters the remembered set with the given callback.
177 // The callback should take (SlotType slot_type, SlotAddress slot) and return 180 // The callback should take (SlotType slot_type, SlotAddress slot) and return
178 // SlotCallbackResult. 181 // SlotCallbackResult.
179 template <typename Callback> 182 template <typename Callback>
180 static void IterateTyped(Heap* heap, Callback callback) { 183 static void IterateTyped(Heap* heap, bool synchronize, Callback callback) {
181 IterateMemoryChunks(heap, [callback](MemoryChunk* chunk) { 184 IterateMemoryChunks(heap, [callback, synchronize](MemoryChunk* chunk) {
185 if (synchronize) chunk->mutex()->Lock();
182 IterateTyped(chunk, callback); 186 IterateTyped(chunk, callback);
187 if (synchronize) chunk->mutex()->Unlock();
183 }); 188 });
184 } 189 }
185 190
186 // Iterates and filters typed old to old pointers in the given memory chunk 191 // Iterates and filters typed old to old pointers in the given memory chunk
187 // with the given callback. The callback should take (SlotType slot_type, 192 // with the given callback. The callback should take (SlotType slot_type,
188 // Address slot_addr) and return SlotCallbackResult. 193 // Address slot_addr) and return SlotCallbackResult.
189 template <typename Callback> 194 template <typename Callback>
190 static void IterateTyped(MemoryChunk* chunk, Callback callback) { 195 static void IterateTyped(MemoryChunk* chunk, Callback callback) {
191 TypedSlotSet* slots = chunk->typed_slot_set<type>(); 196 TypedSlotSet* slots = chunk->typed_slot_set<type>();
192 if (slots != nullptr) { 197 if (slots != nullptr) {
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 return DEBUG_TARGET_SLOT; 352 return DEBUG_TARGET_SLOT;
348 } 353 }
349 UNREACHABLE(); 354 UNREACHABLE();
350 return CLEARED_SLOT; 355 return CLEARED_SLOT;
351 } 356 }
352 357
353 } // namespace internal 358 } // namespace internal
354 } // namespace v8 359 } // namespace v8
355 360
356 #endif // V8_REMEMBERED_SET_H 361 #endif // V8_REMEMBERED_SET_H
OLDNEW
« src/heap/heap.cc ('K') | « src/heap/mark-compact.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698