Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 51 } | 51 } |
| 52 | 52 |
| 53 static inline bool IsStopped() { return state() == STOPPED; } | 53 static inline bool IsStopped() { return state() == STOPPED; } |
| 54 | 54 |
| 55 static bool WorthActivating(); | 55 static bool WorthActivating(); |
| 56 | 56 |
| 57 static void Start(); | 57 static void Start(); |
| 58 | 58 |
| 59 static void Stop(); | 59 static void Stop(); |
| 60 | 60 |
| 61 static void PrepareForScavenge(); | |
| 62 | |
| 63 static void UpdateMarkingStackAfterScavenge(); | |
| 64 | |
| 61 static void Hurry(); | 65 static void Hurry(); |
| 62 | 66 |
| 63 static void Finalize(); | 67 static void Finalize(); |
| 64 | 68 |
| 65 static void MarkingComplete(); | 69 static void MarkingComplete(); |
| 66 | 70 |
| 67 static const intptr_t kAllocatedThreshold = 1024; | 71 static const intptr_t kAllocatedThreshold = 1024; |
| 68 static const intptr_t kAllocationMarkingFactor = 8; | 72 static const intptr_t kAllocationMarkingFactor = 8; |
| 69 | 73 |
| 70 static void Step(intptr_t allocated); | 74 static void Step(intptr_t allocated); |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 128 ASSERT(!IsImpossible(mark_bit)); | 132 ASSERT(!IsImpossible(mark_bit)); |
| 129 return !mark_bit.Get(); | 133 return !mark_bit.Get(); |
| 130 } | 134 } |
| 131 | 135 |
| 132 // Grey markbits: 11 | 136 // Grey markbits: 11 |
| 133 static inline bool IsGrey(MarkBit mark_bit) { | 137 static inline bool IsGrey(MarkBit mark_bit) { |
| 134 ASSERT(!IsImpossible(mark_bit)); | 138 ASSERT(!IsImpossible(mark_bit)); |
| 135 return mark_bit.Get() && mark_bit.Next().Get(); | 139 return mark_bit.Get() && mark_bit.Next().Get(); |
| 136 } | 140 } |
| 137 | 141 |
| 138 static inline void BlackToGrey(HeapObject* obj, MarkBit mark_bit) { | 142 static inline void BlackToGrey(HeapObject* obj, MarkBit mark_bit) { |
|
Erik Corry
2011/03/23 12:04:32
Peraps this should be called BlackToGreyAndPush an
| |
| 139 ASSERT(Marking::MarkBitFrom(obj) == mark_bit); | 143 ASSERT(Marking::MarkBitFrom(obj) == mark_bit); |
| 140 ASSERT(obj->Size() >= 2*kPointerSize); | 144 ASSERT(obj->Size() >= 2*kPointerSize); |
| 141 ASSERT(!IsStopped()); | 145 ASSERT(!IsStopped()); |
| 142 ASSERT(IsBlack(mark_bit)); | 146 ASSERT(IsBlack(mark_bit)); |
| 143 mark_bit.Next().Set(); | 147 mark_bit.Next().Set(); |
| 144 ASSERT(IsGrey(mark_bit)); | 148 ASSERT(IsGrey(mark_bit)); |
| 145 | 149 |
| 146 marking_stack_.Push(obj); | 150 marking_stack_.Push(obj); |
| 147 ASSERT(!marking_stack_.overflowed()); | 151 ASSERT(!marking_stack_.overflowed()); |
| 148 } | 152 } |
| 149 | 153 |
| 150 static inline void WhiteToGrey(HeapObject* obj, MarkBit mark_bit) { | 154 static inline void WhiteToGrey(HeapObject* obj, MarkBit mark_bit) { |
| 151 ASSERT(Marking::MarkBitFrom(obj) == mark_bit); | 155 ASSERT(Marking::MarkBitFrom(obj) == mark_bit); |
| 152 ASSERT(obj->Size() >= 2*kPointerSize); | 156 ASSERT(obj->Size() >= 2*kPointerSize); |
| 153 ASSERT(!IsStopped()); | 157 ASSERT(!IsStopped()); |
| 154 ASSERT(IsWhite(mark_bit)); | 158 ASSERT(IsWhite(mark_bit)); |
| 155 mark_bit.Set(); | 159 mark_bit.Set(); |
| 156 mark_bit.Next().Set(); | 160 mark_bit.Next().Set(); |
| 157 ASSERT(IsGrey(mark_bit)); | 161 ASSERT(IsGrey(mark_bit)); |
| 158 | 162 |
| 159 marking_stack_.Push(obj); | 163 marking_stack_.Push(obj); |
| 160 ASSERT(!marking_stack_.overflowed()); | 164 ASSERT(!marking_stack_.overflowed()); |
| 161 } | 165 } |
| 162 | 166 |
| 167 static inline void MarkWhiteObjectGrey(HeapObject* obj, MarkBit mark_bit) { | |
| 168 ASSERT(Marking::MarkBitFrom(obj) == mark_bit); | |
| 169 ASSERT(obj->Size() >= 2*kPointerSize); | |
| 170 ASSERT(!IsStopped()); | |
| 171 ASSERT(IsWhite(mark_bit)); | |
| 172 mark_bit.Set(); | |
| 173 mark_bit.Next().Set(); | |
| 174 ASSERT(IsGrey(mark_bit)); | |
| 175 } | |
| 176 | |
| 163 static inline void MarkBlack(MarkBit mark_bit) { | 177 static inline void MarkBlack(MarkBit mark_bit) { |
| 164 mark_bit.Set(); | 178 mark_bit.Set(); |
| 165 mark_bit.Next().Clear(); | 179 mark_bit.Next().Clear(); |
| 166 ASSERT(IsBlack(mark_bit)); | 180 ASSERT(IsBlack(mark_bit)); |
| 167 } | 181 } |
| 168 | 182 |
| 169 static inline const char* ColorStr(MarkBit mark_bit) { | 183 static inline const char* ColorStr(MarkBit mark_bit) { |
| 170 if (IsBlack(mark_bit)) return "black"; | 184 if (IsBlack(mark_bit)) return "black"; |
| 171 if (IsWhite(mark_bit)) return "white"; | 185 if (IsWhite(mark_bit)) return "white"; |
| 172 if (IsGrey(mark_bit)) return "grey"; | 186 if (IsGrey(mark_bit)) return "grey"; |
| 173 UNREACHABLE(); | 187 UNREACHABLE(); |
| 174 return "???"; | 188 return "???"; |
| 175 } | 189 } |
| 176 | 190 |
| 191 enum ObjectColor { | |
| 192 BLACK_OBJECT, | |
| 193 WHITE_OBJECT, | |
| 194 GREY_OBJECT, | |
| 195 IMPOSSIBLE_COLOR | |
| 196 }; | |
| 197 | |
| 198 static inline ObjectColor Color(HeapObject* obj) { | |
| 199 MarkBit mark_bit = Marking::MarkBitFrom(obj); | |
| 200 if (IsBlack(mark_bit)) return BLACK_OBJECT; | |
| 201 if (IsWhite(mark_bit)) return WHITE_OBJECT; | |
| 202 if (IsGrey(mark_bit)) return GREY_OBJECT; | |
| 203 UNREACHABLE(); | |
| 204 return IMPOSSIBLE_COLOR; | |
| 205 } | |
| 206 | |
| 177 private: | 207 private: |
| 178 static State state_; | 208 static State state_; |
| 179 static MarkingStack marking_stack_; | 209 static MarkingStack marking_stack_; |
| 180 }; | 210 }; |
| 181 | 211 |
| 182 } } // namespace v8::internal | 212 } } // namespace v8::internal |
| 183 | 213 |
| 184 #endif // V8_INCREMENTAL_MARKING_H_ | 214 #endif // V8_INCREMENTAL_MARKING_H_ |
| OLD | NEW |