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

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

Issue 2786313003: Revert of [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
« no previous file with comments | « 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"
11 #include "src/heap/spaces.h" 11 #include "src/heap/spaces.h"
12 12
13 namespace v8 { 13 namespace v8 {
14 namespace internal { 14 namespace internal {
15 15
16 enum RememberedSetIterationMode { SYNCHRONIZED, NON_SYNCHRONIZED };
17
18 // TODO(ulan): Investigate performance of de-templatizing this class. 16 // TODO(ulan): Investigate performance of de-templatizing this class.
19 template <RememberedSetType type> 17 template <RememberedSetType type>
20 class RememberedSet : public AllStatic { 18 class RememberedSet : public AllStatic {
21 public: 19 public:
22 // Given a page and a slot in that page, this function adds the slot to the 20 // Given a page and a slot in that page, this function adds the slot to the
23 // remembered set. 21 // remembered set.
24 static void Insert(MemoryChunk* chunk, Address slot_addr) { 22 static void Insert(MemoryChunk* chunk, Address slot_addr) {
25 DCHECK(chunk->Contains(slot_addr)); 23 DCHECK(chunk->Contains(slot_addr));
26 SlotSet* slot_set = chunk->slot_set<type>(); 24 SlotSet* slot_set = chunk->slot_set<type>();
27 if (slot_set == nullptr) { 25 if (slot_set == nullptr) {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 // 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.
94 slot_set[end_chunk].RemoveRange(0, offset_in_end_chunk, mode); 92 slot_set[end_chunk].RemoveRange(0, offset_in_end_chunk, mode);
95 } 93 }
96 } 94 }
97 } 95 }
98 } 96 }
99 97
100 // Iterates and filters the remembered set with the given callback. 98 // Iterates and filters the remembered set with the given callback.
101 // The callback should take (Address slot) and return SlotCallbackResult. 99 // The callback should take (Address slot) and return SlotCallbackResult.
102 template <typename Callback> 100 template <typename Callback>
103 static void Iterate(Heap* heap, RememberedSetIterationMode mode, 101 static void Iterate(Heap* heap, Callback callback) {
104 Callback callback) { 102 IterateMemoryChunks(
105 IterateMemoryChunks(heap, [mode, callback](MemoryChunk* chunk) { 103 heap, [callback](MemoryChunk* chunk) { Iterate(chunk, callback); });
106 if (mode == SYNCHRONIZED) chunk->mutex()->Lock();
107 Iterate(chunk, callback);
108 if (mode == SYNCHRONIZED) chunk->mutex()->Unlock();
109 });
110 } 104 }
111 105
112 // Iterates over all memory chunks that contains non-empty slot sets. 106 // Iterates over all memory chunks that contains non-empty slot sets.
113 // The callback should take (MemoryChunk* chunk) and return void. 107 // The callback should take (MemoryChunk* chunk) and return void.
114 template <typename Callback> 108 template <typename Callback>
115 static void IterateMemoryChunks(Heap* heap, Callback callback) { 109 static void IterateMemoryChunks(Heap* heap, Callback callback) {
116 MemoryChunkIterator it(heap); 110 MemoryChunkIterator it(heap);
117 MemoryChunk* chunk; 111 MemoryChunk* chunk;
118 while ((chunk = it.next()) != nullptr) { 112 while ((chunk = it.next()) != nullptr) {
119 SlotSet* slots = chunk->slot_set<type>(); 113 SlotSet* slots = chunk->slot_set<type>();
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 : KEEP_SLOT; 170 : KEEP_SLOT;
177 }, 171 },
178 TypedSlotSet::PREFREE_EMPTY_CHUNKS); 172 TypedSlotSet::PREFREE_EMPTY_CHUNKS);
179 } 173 }
180 } 174 }
181 175
182 // Iterates and filters the remembered set with the given callback. 176 // Iterates and filters the remembered set with the given callback.
183 // The callback should take (SlotType slot_type, SlotAddress slot) and return 177 // The callback should take (SlotType slot_type, SlotAddress slot) and return
184 // SlotCallbackResult. 178 // SlotCallbackResult.
185 template <typename Callback> 179 template <typename Callback>
186 static void IterateTyped(Heap* heap, RememberedSetIterationMode mode, 180 static void IterateTyped(Heap* heap, Callback callback) {
187 Callback callback) { 181 IterateMemoryChunks(heap, [callback](MemoryChunk* chunk) {
188 IterateMemoryChunks(heap, [mode, callback](MemoryChunk* chunk) {
189 if (mode == SYNCHRONIZED) chunk->mutex()->Lock();
190 IterateTyped(chunk, callback); 182 IterateTyped(chunk, callback);
191 if (mode == SYNCHRONIZED) chunk->mutex()->Unlock();
192 }); 183 });
193 } 184 }
194 185
195 // Iterates and filters typed old to old pointers in the given memory chunk 186 // Iterates and filters typed old to old pointers in the given memory chunk
196 // with the given callback. The callback should take (SlotType slot_type, 187 // with the given callback. The callback should take (SlotType slot_type,
197 // Address slot_addr) and return SlotCallbackResult. 188 // Address slot_addr) and return SlotCallbackResult.
198 template <typename Callback> 189 template <typename Callback>
199 static void IterateTyped(MemoryChunk* chunk, Callback callback) { 190 static void IterateTyped(MemoryChunk* chunk, Callback callback) {
200 TypedSlotSet* slots = chunk->typed_slot_set<type>(); 191 TypedSlotSet* slots = chunk->typed_slot_set<type>();
201 if (slots != nullptr) { 192 if (slots != nullptr) {
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 return DEBUG_TARGET_SLOT; 347 return DEBUG_TARGET_SLOT;
357 } 348 }
358 UNREACHABLE(); 349 UNREACHABLE();
359 return CLEARED_SLOT; 350 return CLEARED_SLOT;
360 } 351 }
361 352
362 } // namespace internal 353 } // namespace internal
363 } // namespace v8 354 } // namespace v8
364 355
365 #endif // V8_REMEMBERED_SET_H 356 #endif // V8_REMEMBERED_SET_H
OLDNEW
« no previous file with comments | « src/heap/mark-compact.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698