OLD | NEW |
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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 | 75 |
76 template <MarkBit::AccessMode access_mode = MarkBit::NON_ATOMIC> | 76 template <MarkBit::AccessMode access_mode = MarkBit::NON_ATOMIC> |
77 V8_INLINE static bool IsBlackOrGrey(HeapObject* obj, | 77 V8_INLINE static bool IsBlackOrGrey(HeapObject* obj, |
78 const MarkingState& state) { | 78 const MarkingState& state) { |
79 return Marking::IsBlackOrGrey<access_mode>(MarkBitFrom(obj, state)); | 79 return Marking::IsBlackOrGrey<access_mode>(MarkBitFrom(obj, state)); |
80 } | 80 } |
81 | 81 |
82 template <MarkBit::AccessMode access_mode = MarkBit::NON_ATOMIC> | 82 template <MarkBit::AccessMode access_mode = MarkBit::NON_ATOMIC> |
83 V8_INLINE static bool BlackToGrey(HeapObject* obj, | 83 V8_INLINE static bool BlackToGrey(HeapObject* obj, |
84 const MarkingState& state) { | 84 const MarkingState& state) { |
85 DCHECK( | |
86 (access_mode == MarkBit::ATOMIC || IsBlack<access_mode>(obj, state))); | |
87 MarkBit markbit = MarkBitFrom(obj, state); | 85 MarkBit markbit = MarkBitFrom(obj, state); |
88 if (!Marking::BlackToGrey<access_mode>(markbit)) return false; | 86 if (!Marking::BlackToGrey<access_mode>(markbit)) return false; |
89 state.IncrementLiveBytes<access_mode>(-obj->Size()); | 87 state.IncrementLiveBytes<access_mode>(-obj->Size()); |
90 return true; | 88 return true; |
91 } | 89 } |
92 | 90 |
93 template <MarkBit::AccessMode access_mode = MarkBit::NON_ATOMIC> | 91 template <MarkBit::AccessMode access_mode = MarkBit::NON_ATOMIC> |
94 V8_INLINE static bool WhiteToGrey(HeapObject* obj, | 92 V8_INLINE static bool WhiteToGrey(HeapObject* obj, |
95 const MarkingState& state) { | 93 const MarkingState& state) { |
96 DCHECK( | |
97 (access_mode == MarkBit::ATOMIC || IsWhite<access_mode>(obj, state))); | |
98 return Marking::WhiteToGrey<access_mode>(MarkBitFrom(obj, state)); | 94 return Marking::WhiteToGrey<access_mode>(MarkBitFrom(obj, state)); |
99 } | 95 } |
100 | 96 |
101 template <MarkBit::AccessMode access_mode = MarkBit::NON_ATOMIC> | 97 template <MarkBit::AccessMode access_mode = MarkBit::NON_ATOMIC> |
102 V8_INLINE static bool WhiteToBlack(HeapObject* obj, | 98 V8_INLINE static bool WhiteToBlack(HeapObject* obj, |
103 const MarkingState& state) { | 99 const MarkingState& state) { |
104 DCHECK( | 100 return ObjectMarking::WhiteToGrey<access_mode>(obj, state) && |
105 (access_mode == MarkBit::ATOMIC || IsWhite<access_mode>(obj, state))); | 101 ObjectMarking::GreyToBlack<access_mode>(obj, state); |
106 if (!ObjectMarking::WhiteToGrey<access_mode>(obj, state)) return false; | |
107 return ObjectMarking::GreyToBlack<access_mode>(obj, state); | |
108 } | 102 } |
109 | 103 |
110 template <MarkBit::AccessMode access_mode = MarkBit::NON_ATOMIC> | 104 template <MarkBit::AccessMode access_mode = MarkBit::NON_ATOMIC> |
111 V8_INLINE static bool GreyToBlack(HeapObject* obj, | 105 V8_INLINE static bool GreyToBlack(HeapObject* obj, |
112 const MarkingState& state) { | 106 const MarkingState& state) { |
113 DCHECK((access_mode == MarkBit::ATOMIC || IsGrey<access_mode>(obj, state))); | |
114 MarkBit markbit = MarkBitFrom(obj, state); | 107 MarkBit markbit = MarkBitFrom(obj, state); |
115 if (!Marking::GreyToBlack<access_mode>(markbit)) return false; | 108 if (!Marking::GreyToBlack<access_mode>(markbit)) return false; |
116 state.IncrementLiveBytes<access_mode>(obj->Size()); | 109 state.IncrementLiveBytes<access_mode>(obj->Size()); |
117 return true; | 110 return true; |
118 } | 111 } |
119 | 112 |
120 private: | 113 private: |
121 DISALLOW_IMPLICIT_CONSTRUCTORS(ObjectMarking); | 114 DISALLOW_IMPLICIT_CONSTRUCTORS(ObjectMarking); |
122 }; | 115 }; |
123 | 116 |
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
752 ~EvacuationScope() { collector_->set_evacuation(false); } | 745 ~EvacuationScope() { collector_->set_evacuation(false); } |
753 | 746 |
754 private: | 747 private: |
755 MarkCompactCollector* collector_; | 748 MarkCompactCollector* collector_; |
756 }; | 749 }; |
757 | 750 |
758 } // namespace internal | 751 } // namespace internal |
759 } // namespace v8 | 752 } // namespace v8 |
760 | 753 |
761 #endif // V8_HEAP_MARK_COMPACT_H_ | 754 #endif // V8_HEAP_MARK_COMPACT_H_ |
OLD | NEW |