| 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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 ASSERT(IsGrey(markbit)); | 112 ASSERT(IsGrey(markbit)); |
| 113 markbit.Next().Clear(); | 113 markbit.Next().Clear(); |
| 114 ASSERT(IsBlack(markbit)); | 114 ASSERT(IsBlack(markbit)); |
| 115 } | 115 } |
| 116 | 116 |
| 117 static inline void BlackToGrey(HeapObject* obj) { | 117 static inline void BlackToGrey(HeapObject* obj) { |
| 118 ASSERT(obj->Size() >= 2 * kPointerSize); | 118 ASSERT(obj->Size() >= 2 * kPointerSize); |
| 119 BlackToGrey(MarkBitFrom(obj)); | 119 BlackToGrey(MarkBitFrom(obj)); |
| 120 } | 120 } |
| 121 | 121 |
| 122 void TransferMark(Address old_start, Address new_start); | 122 // Returns true if the the object whose mark is transferred is marked black. |
| 123 bool TransferMark(Address old_start, Address new_start); |
| 123 | 124 |
| 124 #ifdef DEBUG | 125 #ifdef DEBUG |
| 125 enum ObjectColor { | 126 enum ObjectColor { |
| 126 BLACK_OBJECT, | 127 BLACK_OBJECT, |
| 127 WHITE_OBJECT, | 128 WHITE_OBJECT, |
| 128 GREY_OBJECT, | 129 GREY_OBJECT, |
| 129 IMPOSSIBLE_COLOR | 130 IMPOSSIBLE_COLOR |
| 130 }; | 131 }; |
| 131 | 132 |
| 132 static const char* ColorName(ObjectColor color) { | 133 static const char* ColorName(ObjectColor color) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 145 | 146 |
| 146 static ObjectColor Color(MarkBit mark_bit) { | 147 static ObjectColor Color(MarkBit mark_bit) { |
| 147 if (IsBlack(mark_bit)) return BLACK_OBJECT; | 148 if (IsBlack(mark_bit)) return BLACK_OBJECT; |
| 148 if (IsWhite(mark_bit)) return WHITE_OBJECT; | 149 if (IsWhite(mark_bit)) return WHITE_OBJECT; |
| 149 if (IsGrey(mark_bit)) return GREY_OBJECT; | 150 if (IsGrey(mark_bit)) return GREY_OBJECT; |
| 150 UNREACHABLE(); | 151 UNREACHABLE(); |
| 151 return IMPOSSIBLE_COLOR; | 152 return IMPOSSIBLE_COLOR; |
| 152 } | 153 } |
| 153 #endif | 154 #endif |
| 154 | 155 |
| 155 INLINE(static void TransferColor(HeapObject* from, | 156 // Returns true if the transferred color is black. |
| 157 INLINE(static bool TransferColor(HeapObject* from, |
| 156 HeapObject* to)) { | 158 HeapObject* to)) { |
| 157 MarkBit from_mark_bit = MarkBitFrom(from); | 159 MarkBit from_mark_bit = MarkBitFrom(from); |
| 158 MarkBit to_mark_bit = MarkBitFrom(to); | 160 MarkBit to_mark_bit = MarkBitFrom(to); |
| 159 if (from_mark_bit.Get()) to_mark_bit.Set(); | 161 bool is_black = false; |
| 160 if (from_mark_bit.Next().Get()) to_mark_bit.Next().Set(); | 162 if (from_mark_bit.Get()) { |
| 163 to_mark_bit.Set(); |
| 164 is_black = true; // Looks black so far. |
| 165 } |
| 166 if (from_mark_bit.Next().Get()) { |
| 167 to_mark_bit.Next().Set(); |
| 168 is_black = false; // Was actually gray. |
| 169 } |
| 161 ASSERT(Color(from) == Color(to)); | 170 ASSERT(Color(from) == Color(to)); |
| 171 ASSERT(is_black == (Color(to) == BLACK_OBJECT)); |
| 172 return is_black; |
| 162 } | 173 } |
| 163 | 174 |
| 164 private: | 175 private: |
| 165 Heap* heap_; | 176 Heap* heap_; |
| 166 }; | 177 }; |
| 167 | 178 |
| 168 // ---------------------------------------------------------------------------- | 179 // ---------------------------------------------------------------------------- |
| 169 // Marking deque for tracing live objects. | 180 // Marking deque for tracing live objects. |
| 170 | 181 |
| 171 class MarkingDeque { | 182 class MarkingDeque { |
| (...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 593 | 604 |
| 594 List<Page*> evacuation_candidates_; | 605 List<Page*> evacuation_candidates_; |
| 595 | 606 |
| 596 friend class Heap; | 607 friend class Heap; |
| 597 }; | 608 }; |
| 598 | 609 |
| 599 | 610 |
| 600 } } // namespace v8::internal | 611 } } // namespace v8::internal |
| 601 | 612 |
| 602 #endif // V8_MARK_COMPACT_H_ | 613 #endif // V8_MARK_COMPACT_H_ |
| OLD | NEW |