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

Side by Side Diff: src/heap/sequential-marking-deque.h

Issue 2810893002: [heap] Implement simple concurrent marking deque. (Closed)
Patch Set: Fix comment Created 3 years, 7 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.h ('k') | src/v8.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 the V8 project authors. All rights reserved. 1 // Copyright 2017 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_HEAP_SEQUENTIAL_MARKING_DEQUE_ 5 #ifndef V8_HEAP_SEQUENTIAL_MARKING_DEQUE_
6 #define V8_HEAP_SEQUENTIAL_MARKING_DEQUE_ 6 #define V8_HEAP_SEQUENTIAL_MARKING_DEQUE_
7 7
8 #include <deque> 8 #include <deque>
9 9
10 #include "src/base/platform/mutex.h" 10 #include "src/base/platform/mutex.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 if (IsFull()) { 84 if (IsFull()) {
85 SetOverflowed(); 85 SetOverflowed();
86 return false; 86 return false;
87 } else { 87 } else {
88 bottom_ = ((bottom_ - 1) & mask_); 88 bottom_ = ((bottom_ - 1) & mask_);
89 array_[bottom_] = object; 89 array_[bottom_] = object;
90 return true; 90 return true;
91 } 91 }
92 } 92 }
93 93
94 template <typename Callback>
95 void Iterate(Callback callback) {
96 int i = bottom_;
97 while (i != top_) {
98 callback(array_[i]);
99 i = (i + 1) & mask_;
100 }
101 }
102
103 // Calls the specified callback on each element of the deque and replaces 94 // Calls the specified callback on each element of the deque and replaces
104 // the element with the result of the callback. If the callback returns 95 // the element with the result of the callback. If the callback returns
105 // nullptr then the element is removed from the deque. 96 // nullptr then the element is removed from the deque.
106 // The callback must accept HeapObject* and return HeapObject*. 97 // The callback must accept HeapObject* and return HeapObject*.
107 template <typename Callback> 98 template <typename Callback>
108 void Update(Callback callback) { 99 void Update(Callback callback) {
109 int i = bottom_; 100 int i = bottom_;
110 int new_top = bottom_; 101 int new_top = bottom_;
111 while (i != top_) { 102 while (i != top_) {
112 HeapObject* object = callback(array_[i]); 103 HeapObject* object = callback(array_[i]);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 bool uncommit_task_pending_; 163 bool uncommit_task_pending_;
173 Heap* heap_; 164 Heap* heap_;
174 165
175 DISALLOW_COPY_AND_ASSIGN(SequentialMarkingDeque); 166 DISALLOW_COPY_AND_ASSIGN(SequentialMarkingDeque);
176 }; 167 };
177 168
178 } // namespace internal 169 } // namespace internal
179 } // namespace v8 170 } // namespace v8
180 171
181 #endif // V8_SEQUENTIAL_MARKING_DEQUE_ 172 #endif // V8_SEQUENTIAL_MARKING_DEQUE_
OLDNEW
« no previous file with comments | « src/heap/mark-compact.h ('k') | src/v8.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698