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

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

Issue 1293773002: [heap] Simplify MarkingDeque implementation. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Moar work. 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
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, 208 // Push the (marked) object on the marking stack if there is room, otherwise
209 // otherwise mark the object as overflowed and wait for a rescan of the 209 // mark the deque as overflowed and wait for a rescan of the heap.
210 // heap. 210 INLINE(bool PushBlack(HeapObject* object)) {
Michael Starzinger 2015/08/14 12:08:23 Note that {PushBlack} and {PushGrey} can now be un
Hannes Payer (out of office) 2015/08/17 09:39:10 I like it, you can do it in a separate cl.
211 INLINE(void PushBlack(HeapObject* object)) {
212 DCHECK(object->IsHeapObject()); 211 DCHECK(object->IsHeapObject());
213 if (IsFull()) { 212 if (IsFull()) {
214 Marking::BlackToGrey(object);
215 MemoryChunk::IncrementLiveBytesFromGC(object, -object->Size());
216 SetOverflowed(); 213 SetOverflowed();
214 return false;
217 } else { 215 } else {
218 array_[top_] = object; 216 array_[top_] = object;
219 top_ = ((top_ + 1) & mask_); 217 top_ = ((top_ + 1) & mask_);
218 return true;
220 } 219 }
221 } 220 }
222 221
223 INLINE(void PushGrey(HeapObject* object)) { 222 INLINE(void PushGrey(HeapObject* object)) {
224 DCHECK(object->IsHeapObject()); 223 DCHECK(object->IsHeapObject());
225 if (IsFull()) { 224 if (IsFull()) {
226 SetOverflowed(); 225 SetOverflowed();
227 } else { 226 } else {
228 array_[top_] = object; 227 array_[top_] = object;
229 top_ = ((top_ + 1) & mask_); 228 top_ = ((top_ + 1) & mask_);
230 } 229 }
231 } 230 }
232 231
233 INLINE(HeapObject* Pop()) { 232 INLINE(HeapObject* Pop()) {
234 DCHECK(!IsEmpty()); 233 DCHECK(!IsEmpty());
235 top_ = ((top_ - 1) & mask_); 234 top_ = ((top_ - 1) & mask_);
236 HeapObject* object = array_[top_]; 235 HeapObject* object = array_[top_];
237 DCHECK(object->IsHeapObject()); 236 DCHECK(object->IsHeapObject());
238 return object; 237 return object;
239 } 238 }
240 239
241 INLINE(void UnshiftGrey(HeapObject* object)) { 240 INLINE(void UnshiftGrey(HeapObject* object)) {
Michael Starzinger 2015/08/14 12:08:23 Likewise for unification of {UnshiftGrey} and {Uns
242 DCHECK(object->IsHeapObject()); 241 DCHECK(object->IsHeapObject());
243 if (IsFull()) { 242 if (IsFull()) {
244 SetOverflowed(); 243 SetOverflowed();
245 } else { 244 } else {
246 bottom_ = ((bottom_ - 1) & mask_); 245 bottom_ = ((bottom_ - 1) & mask_);
247 array_[bottom_] = object; 246 array_[bottom_] = object;
248 } 247 }
249 } 248 }
250 249
251 INLINE(void UnshiftBlack(HeapObject* object)) { 250 INLINE(bool UnshiftBlack(HeapObject* object)) {
252 DCHECK(object->IsHeapObject()); 251 DCHECK(object->IsHeapObject());
253 DCHECK(Marking::IsBlack(Marking::MarkBitFrom(object))); 252 DCHECK(Marking::IsBlack(Marking::MarkBitFrom(object)));
254 if (IsFull()) { 253 if (IsFull()) {
255 Marking::BlackToGrey(object);
256 MemoryChunk::IncrementLiveBytesFromGC(object, -object->Size());
257 SetOverflowed(); 254 SetOverflowed();
255 return false;
258 } else { 256 } else {
259 bottom_ = ((bottom_ - 1) & mask_); 257 bottom_ = ((bottom_ - 1) & mask_);
260 array_[bottom_] = object; 258 array_[bottom_] = object;
259 return true;
261 } 260 }
262 } 261 }
263 262
264 HeapObject** array() { return array_; } 263 HeapObject** array() { return array_; }
265 int bottom() { return bottom_; } 264 int bottom() { return bottom_; }
266 int top() { return top_; } 265 int top() { return top_; }
267 int mask() { return mask_; } 266 int mask() { return mask_; }
268 void set_top(int top) { top_ = top; } 267 void set_top(int top) { top_ = top; }
269 268
270 private: 269 private:
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 // from being flushed. 770 // from being flushed.
772 void PrepareThreadForCodeFlushing(Isolate* isolate, ThreadLocalTop* top); 771 void PrepareThreadForCodeFlushing(Isolate* isolate, ThreadLocalTop* top);
773 772
774 void PrepareForCodeFlushing(); 773 void PrepareForCodeFlushing();
775 774
776 // Marking operations for objects reachable from roots. 775 // Marking operations for objects reachable from roots.
777 void MarkLiveObjects(); 776 void MarkLiveObjects();
778 777
779 void AfterMarking(); 778 void AfterMarking();
780 779
780 // Pushes a black object onto the marking stack and accounts for live bytes.
781 INLINE(void PushBlack(HeapObject* obj));
782
781 // Marks the object black and pushes it on the marking stack. 783 // Marks the object black and pushes it on the marking stack.
782 // This is for non-incremental marking only. 784 // This is for non-incremental marking only.
783 INLINE(void MarkObject(HeapObject* obj, MarkBit mark_bit)); 785 INLINE(void MarkObject(HeapObject* obj, MarkBit mark_bit));
784 786
785 // Marks the object black assuming that it is not yet marked. 787 // Marks the object black assuming that it is not yet marked.
786 // This is for non-incremental marking only. 788 // This is for non-incremental marking only.
787 INLINE(void SetMark(HeapObject* obj, MarkBit mark_bit)); 789 INLINE(void SetMark(HeapObject* obj, MarkBit mark_bit));
788 790
789 // Mark the heap roots and all objects reachable from them. 791 // Mark the heap roots and all objects reachable from them.
790 void MarkRoots(RootMarkingVisitor* visitor); 792 void MarkRoots(RootMarkingVisitor* visitor);
(...skipping 28 matching lines...) Expand all
819 // stack. This function empties the marking stack, but may leave 821 // stack. This function empties the marking stack, but may leave
820 // overflowed objects in the heap, in which case the marking stack's 822 // overflowed objects in the heap, in which case the marking stack's
821 // overflow flag will be set. 823 // overflow flag will be set.
822 void EmptyMarkingDeque(); 824 void EmptyMarkingDeque();
823 825
824 // Refill the marking stack with overflowed objects from the heap. This 826 // Refill the marking stack with overflowed objects from the heap. This
825 // function either leaves the marking stack full or clears the overflow 827 // function either leaves the marking stack full or clears the overflow
826 // flag on the marking stack. 828 // flag on the marking stack.
827 void RefillMarkingDeque(); 829 void RefillMarkingDeque();
828 830
831 // Helper methods for refilling the marking stack by discovering grey objects
832 // on various pages of the heap. Used by {RefillMarkingDeque} only.
833 template <class T>
834 void DiscoverGreyObjectsWithIterator(T* it);
835 void DiscoverGreyObjectsOnPage(MemoryChunk* p);
836 void DiscoverGreyObjectsInSpace(PagedSpace* space);
837 void DiscoverGreyObjectsInNewSpace();
838
829 // Callback function for telling whether the object *p is an unmarked 839 // Callback function for telling whether the object *p is an unmarked
830 // heap object. 840 // heap object.
831 static bool IsUnmarkedHeapObject(Object** p); 841 static bool IsUnmarkedHeapObject(Object** p);
832 842
833 // Map transitions from a live map to a dead map must be killed. 843 // Map transitions from a live map to a dead map must be killed.
834 // We replace them with a null descriptor, with the same key. 844 // We replace them with a null descriptor, with the same key.
835 void ClearNonLiveReferences(); 845 void ClearNonLiveReferences();
836 void ClearNonLivePrototypeTransitions(Map* map); 846 void ClearNonLivePrototypeTransitions(Map* map);
837 void ClearNonLiveMapTransitions(Map* map, MarkBit map_mark); 847 void ClearNonLiveMapTransitions(Map* map, MarkBit map_mark);
838 void ClearMapTransitions(Map* map, Map* dead_transition); 848 void ClearMapTransitions(Map* map, Map* dead_transition);
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
981 private: 991 private:
982 MarkCompactCollector* collector_; 992 MarkCompactCollector* collector_;
983 }; 993 };
984 994
985 995
986 const char* AllocationSpaceName(AllocationSpace space); 996 const char* AllocationSpaceName(AllocationSpace space);
987 } 997 }
988 } // namespace v8::internal 998 } // namespace v8::internal
989 999
990 #endif // V8_HEAP_MARK_COMPACT_H_ 1000 #endif // V8_HEAP_MARK_COMPACT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698