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

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

Issue 2644523002: [heap] Provide ObjectMarking with marking transitions (Closed)
Patch Set: Rebase Created 3 years, 11 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.cc ('k') | src/heap/mark-compact.cc » ('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 <deque> 8 #include <deque>
9 9
10 #include "src/base/bits.h" 10 #include "src/base/bits.h"
(...skipping 28 matching lines...) Expand all
39 V8_INLINE static MarkBit MarkBitFrom(HeapObject* obj) { 39 V8_INLINE static MarkBit MarkBitFrom(HeapObject* obj) {
40 const Address address = obj->address(); 40 const Address address = obj->address();
41 MemoryChunk* p = MemoryChunk::FromAddress(address); 41 MemoryChunk* p = MemoryChunk::FromAddress(address);
42 return p->markbits()->MarkBitFromIndex(p->AddressToMarkbitIndex(address)); 42 return p->markbits()->MarkBitFromIndex(p->AddressToMarkbitIndex(address));
43 } 43 }
44 44
45 static Marking::ObjectColor Color(HeapObject* obj) { 45 static Marking::ObjectColor Color(HeapObject* obj) {
46 return Marking::Color(ObjectMarking::MarkBitFrom(obj)); 46 return Marking::Color(ObjectMarking::MarkBitFrom(obj));
47 } 47 }
48 48
49 V8_INLINE static bool IsImpossible(HeapObject* obj) {
50 return Marking::IsImpossible(MarkBitFrom(obj));
51 }
52
53 V8_INLINE static bool IsBlack(HeapObject* obj) {
54 return Marking::IsBlack(MarkBitFrom(obj));
55 }
56
57 V8_INLINE static bool IsWhite(HeapObject* obj) {
58 return Marking::IsWhite(MarkBitFrom(obj));
59 }
60
61 V8_INLINE static bool IsGrey(HeapObject* obj) {
62 return Marking::IsGrey(MarkBitFrom(obj));
63 }
64
65 V8_INLINE static bool IsBlackOrGrey(HeapObject* obj) {
66 return Marking::IsBlackOrGrey(MarkBitFrom(obj));
67 }
68
69 V8_INLINE static void ClearMarkBit(HeapObject* obj) {
70 Marking::MarkWhite(MarkBitFrom(obj));
71 }
72
73 V8_INLINE static void BlackToWhite(HeapObject* obj) {
74 DCHECK(IsBlack(obj));
75 MarkBit markbit = MarkBitFrom(obj);
76 Marking::BlackToWhite(markbit);
77 MemoryChunk::IncrementLiveBytes(obj, -obj->Size());
78 }
79
80 V8_INLINE static void GreyToWhite(HeapObject* obj) {
81 DCHECK(IsGrey(obj));
82 Marking::GreyToWhite(MarkBitFrom(obj));
83 }
84
85 V8_INLINE static void BlackToGrey(HeapObject* obj) {
86 DCHECK(IsBlack(obj));
87 MarkBit markbit = MarkBitFrom(obj);
88 Marking::BlackToGrey(markbit);
89 MemoryChunk::IncrementLiveBytes(obj, -obj->Size());
90 }
91
92 V8_INLINE static void WhiteToGrey(HeapObject* obj) {
93 DCHECK(IsWhite(obj));
94 Marking::WhiteToGrey(MarkBitFrom(obj));
95 }
96
97 V8_INLINE static void WhiteToBlack(HeapObject* obj) {
98 DCHECK(IsWhite(obj));
99 MarkBit markbit = MarkBitFrom(obj);
100 Marking::WhiteToBlack(markbit);
101 MemoryChunk::IncrementLiveBytes(obj, obj->Size());
102 }
103
104 V8_INLINE static void GreyToBlack(HeapObject* obj) {
105 DCHECK(IsGrey(obj));
106 MarkBit markbit = MarkBitFrom(obj);
107 Marking::GreyToBlack(markbit);
108 MemoryChunk::IncrementLiveBytes(obj, obj->Size());
109 }
110
111 V8_INLINE static void AnyToGrey(HeapObject* obj) {
112 MarkBit markbit = MarkBitFrom(obj);
113 if (Marking::IsBlack(markbit)) {
114 MemoryChunk::IncrementLiveBytes(obj, -obj->Size());
115 }
116 Marking::AnyToGrey(markbit);
117 }
118
49 private: 119 private:
50 DISALLOW_IMPLICIT_CONSTRUCTORS(ObjectMarking); 120 DISALLOW_IMPLICIT_CONSTRUCTORS(ObjectMarking);
51 }; 121 };
52 122
53 // ---------------------------------------------------------------------------- 123 // ----------------------------------------------------------------------------
54 // Marking deque for tracing live objects. 124 // Marking deque for tracing live objects.
55 class MarkingDeque { 125 class MarkingDeque {
56 public: 126 public:
57 explicit MarkingDeque(Heap* heap) 127 explicit MarkingDeque(Heap* heap)
58 : backing_store_(nullptr), 128 : backing_store_(nullptr),
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 // Unshifts a black object into the marking stack and accounts for live bytes. 658 // Unshifts a black object into the marking stack and accounts for live bytes.
589 // Note that this assumes lives bytes have already been counted. 659 // Note that this assumes lives bytes have already been counted.
590 INLINE(void UnshiftBlack(HeapObject* obj)); 660 INLINE(void UnshiftBlack(HeapObject* obj));
591 661
592 // Marks the object black and pushes it on the marking stack. 662 // Marks the object black and pushes it on the marking stack.
593 // This is for non-incremental marking only. 663 // This is for non-incremental marking only.
594 INLINE(void MarkObject(HeapObject* obj, MarkBit mark_bit)); 664 INLINE(void MarkObject(HeapObject* obj, MarkBit mark_bit));
595 665
596 // Marks the object black assuming that it is not yet marked. 666 // Marks the object black assuming that it is not yet marked.
597 // This is for non-incremental marking only. 667 // This is for non-incremental marking only.
598 INLINE(void SetMark(HeapObject* obj, MarkBit mark_bit)); 668 INLINE(void SetMark(HeapObject* obj));
599 669
600 // Mark the heap roots and all objects reachable from them. 670 // Mark the heap roots and all objects reachable from them.
601 void MarkRoots(RootMarkingVisitor<MarkCompactMode::FULL>* visitor); 671 void MarkRoots(RootMarkingVisitor<MarkCompactMode::FULL>* visitor);
602 672
603 // Mark the string table specially. References to internalized strings from 673 // Mark the string table specially. References to internalized strings from
604 // the string table are weak. 674 // the string table are weak.
605 void MarkStringTable(RootMarkingVisitor<MarkCompactMode::FULL>* visitor); 675 void MarkStringTable(RootMarkingVisitor<MarkCompactMode::FULL>* visitor);
606 676
607 // Mark objects reachable (transitively) from objects in the marking stack 677 // Mark objects reachable (transitively) from objects in the marking stack
608 // or overflowed in the heap. 678 // or overflowed in the heap.
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 848
779 private: 849 private:
780 MarkCompactCollector* collector_; 850 MarkCompactCollector* collector_;
781 }; 851 };
782 852
783 V8_EXPORT_PRIVATE const char* AllocationSpaceName(AllocationSpace space); 853 V8_EXPORT_PRIVATE const char* AllocationSpaceName(AllocationSpace space);
784 } // namespace internal 854 } // namespace internal
785 } // namespace v8 855 } // namespace v8
786 856
787 #endif // V8_HEAP_MARK_COMPACT_H_ 857 #endif // V8_HEAP_MARK_COMPACT_H_
OLDNEW
« no previous file with comments | « src/heap/incremental-marking.cc ('k') | src/heap/mark-compact.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698