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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 return Marking::IsBlackOrGrey<access_mode>(MarkBitFrom(obj, state)); | 73 return Marking::IsBlackOrGrey<access_mode>(MarkBitFrom(obj, state)); |
74 } | 74 } |
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 BlackToGrey(HeapObject* obj, | 77 V8_INLINE static bool BlackToGrey(HeapObject* obj, |
78 const MarkingState& state) { | 78 const MarkingState& state) { |
79 DCHECK( | 79 DCHECK( |
80 (access_mode == MarkBit::ATOMIC || IsBlack<access_mode>(obj, state))); | 80 (access_mode == MarkBit::ATOMIC || IsBlack<access_mode>(obj, state))); |
81 MarkBit markbit = MarkBitFrom(obj, state); | 81 MarkBit markbit = MarkBitFrom(obj, state); |
82 if (!Marking::BlackToGrey<access_mode>(markbit)) return false; | 82 if (!Marking::BlackToGrey<access_mode>(markbit)) return false; |
83 state.IncrementLiveBytes(-obj->Size()); | 83 state.IncrementLiveBytes<access_mode>(-obj->Size()); |
84 return true; | 84 return true; |
85 } | 85 } |
86 | 86 |
87 template <MarkBit::AccessMode access_mode = MarkBit::NON_ATOMIC> | 87 template <MarkBit::AccessMode access_mode = MarkBit::NON_ATOMIC> |
88 V8_INLINE static bool WhiteToGrey(HeapObject* obj, | 88 V8_INLINE static bool WhiteToGrey(HeapObject* obj, |
89 const MarkingState& state) { | 89 const MarkingState& state) { |
90 DCHECK( | 90 DCHECK( |
91 (access_mode == MarkBit::ATOMIC || IsWhite<access_mode>(obj, state))); | 91 (access_mode == MarkBit::ATOMIC || IsWhite<access_mode>(obj, state))); |
92 return Marking::WhiteToGrey<access_mode>(MarkBitFrom(obj, state)); | 92 return Marking::WhiteToGrey<access_mode>(MarkBitFrom(obj, state)); |
93 } | 93 } |
94 | 94 |
95 template <MarkBit::AccessMode access_mode = MarkBit::NON_ATOMIC> | 95 template <MarkBit::AccessMode access_mode = MarkBit::NON_ATOMIC> |
96 V8_INLINE static bool WhiteToBlack(HeapObject* obj, | 96 V8_INLINE static bool WhiteToBlack(HeapObject* obj, |
97 const MarkingState& state) { | 97 const MarkingState& state) { |
98 DCHECK( | 98 DCHECK( |
99 (access_mode == MarkBit::ATOMIC || IsWhite<access_mode>(obj, state))); | 99 (access_mode == MarkBit::ATOMIC || IsWhite<access_mode>(obj, state))); |
100 if (!ObjectMarking::WhiteToGrey<access_mode>(obj, state)) return false; | 100 if (!ObjectMarking::WhiteToGrey<access_mode>(obj, state)) return false; |
101 return ObjectMarking::GreyToBlack<access_mode>(obj, state); | 101 return ObjectMarking::GreyToBlack<access_mode>(obj, state); |
102 } | 102 } |
103 | 103 |
104 template <MarkBit::AccessMode access_mode = MarkBit::NON_ATOMIC> | 104 template <MarkBit::AccessMode access_mode = MarkBit::NON_ATOMIC> |
105 V8_INLINE static bool GreyToBlack(HeapObject* obj, | 105 V8_INLINE static bool GreyToBlack(HeapObject* obj, |
106 const MarkingState& state) { | 106 const MarkingState& state) { |
107 DCHECK((access_mode == MarkBit::ATOMIC || IsGrey<access_mode>(obj, state))); | 107 DCHECK((access_mode == MarkBit::ATOMIC || IsGrey<access_mode>(obj, state))); |
108 MarkBit markbit = MarkBitFrom(obj, state); | 108 MarkBit markbit = MarkBitFrom(obj, state); |
109 if (!Marking::GreyToBlack<access_mode>(markbit)) return false; | 109 if (!Marking::GreyToBlack<access_mode>(markbit)) return false; |
110 state.IncrementLiveBytes(obj->Size()); | 110 state.IncrementLiveBytes<access_mode>(obj->Size()); |
111 return true; | 111 return true; |
112 } | 112 } |
113 | 113 |
114 private: | 114 private: |
115 DISALLOW_IMPLICIT_CONSTRUCTORS(ObjectMarking); | 115 DISALLOW_IMPLICIT_CONSTRUCTORS(ObjectMarking); |
116 }; | 116 }; |
117 | 117 |
118 // ---------------------------------------------------------------------------- | 118 // ---------------------------------------------------------------------------- |
119 // Marking deque for tracing live objects. | 119 // Marking deque for tracing live objects. |
120 class MarkingDeque { | 120 class MarkingDeque { |
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
870 | 870 |
871 private: | 871 private: |
872 MarkCompactCollector* collector_; | 872 MarkCompactCollector* collector_; |
873 }; | 873 }; |
874 | 874 |
875 V8_EXPORT_PRIVATE const char* AllocationSpaceName(AllocationSpace space); | 875 V8_EXPORT_PRIVATE const char* AllocationSpaceName(AllocationSpace space); |
876 } // namespace internal | 876 } // namespace internal |
877 } // namespace v8 | 877 } // namespace v8 |
878 | 878 |
879 #endif // V8_HEAP_MARK_COMPACT_H_ | 879 #endif // V8_HEAP_MARK_COMPACT_H_ |
OLD | NEW |