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))); |
85 MarkBit markbit = MarkBitFrom(obj, state); | 87 MarkBit markbit = MarkBitFrom(obj, state); |
86 if (!Marking::BlackToGrey<access_mode>(markbit)) return false; | 88 if (!Marking::BlackToGrey<access_mode>(markbit)) return false; |
87 state.IncrementLiveBytes<access_mode>(-obj->Size()); | 89 state.IncrementLiveBytes<access_mode>(-obj->Size()); |
88 return true; | 90 return true; |
89 } | 91 } |
90 | 92 |
91 template <MarkBit::AccessMode access_mode = MarkBit::NON_ATOMIC> | 93 template <MarkBit::AccessMode access_mode = MarkBit::NON_ATOMIC> |
92 V8_INLINE static bool WhiteToGrey(HeapObject* obj, | 94 V8_INLINE static bool WhiteToGrey(HeapObject* obj, |
93 const MarkingState& state) { | 95 const MarkingState& state) { |
| 96 DCHECK( |
| 97 (access_mode == MarkBit::ATOMIC || IsWhite<access_mode>(obj, state))); |
94 return Marking::WhiteToGrey<access_mode>(MarkBitFrom(obj, state)); | 98 return Marking::WhiteToGrey<access_mode>(MarkBitFrom(obj, state)); |
95 } | 99 } |
96 | 100 |
97 template <MarkBit::AccessMode access_mode = MarkBit::NON_ATOMIC> | 101 template <MarkBit::AccessMode access_mode = MarkBit::NON_ATOMIC> |
98 V8_INLINE static bool WhiteToBlack(HeapObject* obj, | 102 V8_INLINE static bool WhiteToBlack(HeapObject* obj, |
99 const MarkingState& state) { | 103 const MarkingState& state) { |
100 return ObjectMarking::WhiteToGrey<access_mode>(obj, state) && | 104 DCHECK( |
101 ObjectMarking::GreyToBlack<access_mode>(obj, state); | 105 (access_mode == MarkBit::ATOMIC || IsWhite<access_mode>(obj, state))); |
| 106 if (!ObjectMarking::WhiteToGrey<access_mode>(obj, state)) return false; |
| 107 return ObjectMarking::GreyToBlack<access_mode>(obj, state); |
102 } | 108 } |
103 | 109 |
104 template <MarkBit::AccessMode access_mode = MarkBit::NON_ATOMIC> | 110 template <MarkBit::AccessMode access_mode = MarkBit::NON_ATOMIC> |
105 V8_INLINE static bool GreyToBlack(HeapObject* obj, | 111 V8_INLINE static bool GreyToBlack(HeapObject* obj, |
106 const MarkingState& state) { | 112 const MarkingState& state) { |
| 113 DCHECK((access_mode == MarkBit::ATOMIC || IsGrey<access_mode>(obj, state))); |
107 MarkBit markbit = MarkBitFrom(obj, state); | 114 MarkBit markbit = MarkBitFrom(obj, state); |
108 if (!Marking::GreyToBlack<access_mode>(markbit)) return false; | 115 if (!Marking::GreyToBlack<access_mode>(markbit)) return false; |
109 state.IncrementLiveBytes<access_mode>(obj->Size()); | 116 state.IncrementLiveBytes<access_mode>(obj->Size()); |
110 return true; | 117 return true; |
111 } | 118 } |
112 | 119 |
113 private: | 120 private: |
114 DISALLOW_IMPLICIT_CONSTRUCTORS(ObjectMarking); | 121 DISALLOW_IMPLICIT_CONSTRUCTORS(ObjectMarking); |
115 }; | 122 }; |
116 | 123 |
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
728 ~EvacuationScope() { collector_->set_evacuation(false); } | 735 ~EvacuationScope() { collector_->set_evacuation(false); } |
729 | 736 |
730 private: | 737 private: |
731 MarkCompactCollector* collector_; | 738 MarkCompactCollector* collector_; |
732 }; | 739 }; |
733 | 740 |
734 } // namespace internal | 741 } // namespace internal |
735 } // namespace v8 | 742 } // namespace v8 |
736 | 743 |
737 #endif // V8_HEAP_MARK_COMPACT_H_ | 744 #endif // V8_HEAP_MARK_COMPACT_H_ |
OLD | NEW |