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

Side by Side Diff: src/heap/mark-compact.h

Issue 1294093003: [heap] Unify MarkingDeque push and unshift operations. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@local_cleanup-includes-heap-2
Patch Set: Fix test case. Created 5 years, 4 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/incremental-marking-inl.h ('k') | src/heap/mark-compact-inl.h » ('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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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_MARK_COMPACT_H_ 5 #ifndef V8_HEAP_MARK_COMPACT_H_
6 #define V8_HEAP_MARK_COMPACT_H_ 6 #define V8_HEAP_MARK_COMPACT_H_
7 7
8 #include "src/base/bits.h" 8 #include "src/base/bits.h"
9 #include "src/heap/spaces.h" 9 #include "src/heap/spaces.h"
10 10
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 inline bool IsEmpty() { return top_ == bottom_; } 198 inline bool IsEmpty() { return top_ == bottom_; }
199 199
200 bool overflowed() const { return overflowed_; } 200 bool overflowed() const { return overflowed_; }
201 201
202 bool in_use() const { return in_use_; } 202 bool in_use() const { return in_use_; }
203 203
204 void ClearOverflowed() { overflowed_ = false; } 204 void ClearOverflowed() { overflowed_ = false; }
205 205
206 void SetOverflowed() { overflowed_ = true; } 206 void SetOverflowed() { overflowed_ = true; }
207 207
208 // Push the (marked) object on the marking stack if there is room, otherwise 208 // Push the object on the marking stack if there is room, otherwise mark the
209 // mark the deque as overflowed and wait for a rescan of the heap. 209 // deque as overflowed and wait for a rescan of the heap.
210 INLINE(bool PushBlack(HeapObject* object)) { 210 INLINE(bool Push(HeapObject* object)) {
211 DCHECK(object->IsHeapObject()); 211 DCHECK(object->IsHeapObject());
212 if (IsFull()) { 212 if (IsFull()) {
213 SetOverflowed(); 213 SetOverflowed();
214 return false; 214 return false;
215 } else { 215 } else {
216 array_[top_] = object; 216 array_[top_] = object;
217 top_ = ((top_ + 1) & mask_); 217 top_ = ((top_ + 1) & mask_);
218 return true; 218 return true;
219 } 219 }
220 } 220 }
221 221
222 INLINE(void PushGrey(HeapObject* object)) {
223 DCHECK(object->IsHeapObject());
224 if (IsFull()) {
225 SetOverflowed();
226 } else {
227 array_[top_] = object;
228 top_ = ((top_ + 1) & mask_);
229 }
230 }
231
232 INLINE(HeapObject* Pop()) { 222 INLINE(HeapObject* Pop()) {
233 DCHECK(!IsEmpty()); 223 DCHECK(!IsEmpty());
234 top_ = ((top_ - 1) & mask_); 224 top_ = ((top_ - 1) & mask_);
235 HeapObject* object = array_[top_]; 225 HeapObject* object = array_[top_];
236 DCHECK(object->IsHeapObject()); 226 DCHECK(object->IsHeapObject());
237 return object; 227 return object;
238 } 228 }
239 229
240 INLINE(void UnshiftGrey(HeapObject* object)) { 230 // Unshift the object into the marking stack if there is room, otherwise mark
231 // the deque as overflowed and wait for a rescan of the heap.
232 INLINE(bool Unshift(HeapObject* object)) {
241 DCHECK(object->IsHeapObject()); 233 DCHECK(object->IsHeapObject());
242 if (IsFull()) { 234 if (IsFull()) {
243 SetOverflowed(); 235 SetOverflowed();
244 } else {
245 bottom_ = ((bottom_ - 1) & mask_);
246 array_[bottom_] = object;
247 }
248 }
249
250 INLINE(bool UnshiftBlack(HeapObject* object)) {
251 DCHECK(object->IsHeapObject());
252 DCHECK(Marking::IsBlack(Marking::MarkBitFrom(object)));
253 if (IsFull()) {
254 SetOverflowed();
255 return false; 236 return false;
256 } else { 237 } else {
257 bottom_ = ((bottom_ - 1) & mask_); 238 bottom_ = ((bottom_ - 1) & mask_);
258 array_[bottom_] = object; 239 array_[bottom_] = object;
259 return true; 240 return true;
260 } 241 }
261 } 242 }
262 243
263 HeapObject** array() { return array_; } 244 HeapObject** array() { return array_; }
264 int bottom() { return bottom_; } 245 int bottom() { return bottom_; }
(...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after
997 private: 978 private:
998 MarkCompactCollector* collector_; 979 MarkCompactCollector* collector_;
999 }; 980 };
1000 981
1001 982
1002 const char* AllocationSpaceName(AllocationSpace space); 983 const char* AllocationSpaceName(AllocationSpace space);
1003 } 984 }
1004 } // namespace v8::internal 985 } // namespace v8::internal
1005 986
1006 #endif // V8_HEAP_MARK_COMPACT_H_ 987 #endif // V8_HEAP_MARK_COMPACT_H_
OLDNEW
« no previous file with comments | « src/heap/incremental-marking-inl.h ('k') | src/heap/mark-compact-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698