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 "src/base/bits.h" | 8 #include "src/base/bits.h" |
9 #include "src/heap/spaces.h" | 9 #include "src/heap/spaces.h" |
10 | 10 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 } | 43 } |
44 | 44 |
45 // Black markbits: 10 - this is required by the sweeper. | 45 // Black markbits: 10 - this is required by the sweeper. |
46 static const char* kBlackBitPattern; | 46 static const char* kBlackBitPattern; |
47 INLINE(static bool IsBlack(MarkBit mark_bit)) { | 47 INLINE(static bool IsBlack(MarkBit mark_bit)) { |
48 return mark_bit.Get() && !mark_bit.Next().Get(); | 48 return mark_bit.Get() && !mark_bit.Next().Get(); |
49 } | 49 } |
50 | 50 |
51 // White markbits: 00 - this is required by the mark bit clearer. | 51 // White markbits: 00 - this is required by the mark bit clearer. |
52 static const char* kWhiteBitPattern; | 52 static const char* kWhiteBitPattern; |
53 INLINE(static bool IsWhite(MarkBit mark_bit)) { return !mark_bit.Get(); } | 53 INLINE(static bool IsWhite(MarkBit mark_bit)) { |
| 54 DCHECK(!IsImpossible(mark_bit)); |
| 55 return !mark_bit.Get(); |
| 56 } |
54 | 57 |
55 // Grey markbits: 11 | 58 // Grey markbits: 11 |
56 static const char* kGreyBitPattern; | 59 static const char* kGreyBitPattern; |
57 INLINE(static bool IsGrey(MarkBit mark_bit)) { | 60 INLINE(static bool IsGrey(MarkBit mark_bit)) { |
58 return mark_bit.Get() && mark_bit.Next().Get(); | 61 return mark_bit.Get() && mark_bit.Next().Get(); |
59 } | 62 } |
60 | 63 |
| 64 INLINE(static bool IsMarked(MarkBit mark_bit)) { return mark_bit.Get(); } |
| 65 |
61 INLINE(static void MarkBlack(MarkBit mark_bit)) { | 66 INLINE(static void MarkBlack(MarkBit mark_bit)) { |
62 mark_bit.Set(); | 67 mark_bit.Set(); |
63 mark_bit.Next().Clear(); | 68 mark_bit.Next().Clear(); |
64 } | 69 } |
65 | 70 |
66 INLINE(static void BlackToGrey(MarkBit markbit)) { markbit.Next().Set(); } | 71 INLINE(static void MarkWhite(MarkBit mark_bit)) { |
| 72 mark_bit.Clear(); |
| 73 mark_bit.Next().Clear(); |
| 74 } |
| 75 |
| 76 INLINE(static void BlackToWhite(MarkBit markbit)) { |
| 77 DCHECK(IsBlack(markbit)); |
| 78 markbit.Clear(); |
| 79 } |
| 80 |
| 81 INLINE(static void GreyToWhite(MarkBit markbit)) { |
| 82 DCHECK(IsGrey(markbit)); |
| 83 markbit.Clear(); |
| 84 markbit.Next().Clear(); |
| 85 } |
| 86 |
| 87 INLINE(static void BlackToGrey(MarkBit markbit)) { |
| 88 DCHECK(IsBlack(markbit)); |
| 89 markbit.Next().Set(); |
| 90 } |
67 | 91 |
68 INLINE(static void WhiteToGrey(MarkBit markbit)) { | 92 INLINE(static void WhiteToGrey(MarkBit markbit)) { |
| 93 DCHECK(IsWhite(markbit)); |
69 markbit.Set(); | 94 markbit.Set(); |
70 markbit.Next().Set(); | 95 markbit.Next().Set(); |
71 } | 96 } |
72 | 97 |
73 INLINE(static void GreyToBlack(MarkBit markbit)) { markbit.Next().Clear(); } | 98 INLINE(static void WhiteToBlack(MarkBit markbit)) { |
| 99 DCHECK(IsWhite(markbit)); |
| 100 markbit.Set(); |
| 101 } |
| 102 |
| 103 INLINE(static void GreyToBlack(MarkBit markbit)) { |
| 104 DCHECK(IsGrey(markbit)); |
| 105 markbit.Next().Clear(); |
| 106 } |
74 | 107 |
75 INLINE(static void BlackToGrey(HeapObject* obj)) { | 108 INLINE(static void BlackToGrey(HeapObject* obj)) { |
76 BlackToGrey(MarkBitFrom(obj)); | 109 BlackToGrey(MarkBitFrom(obj)); |
77 } | 110 } |
78 | 111 |
79 INLINE(static void AnyToGrey(MarkBit markbit)) { | 112 INLINE(static void AnyToGrey(MarkBit markbit)) { |
80 markbit.Set(); | 113 markbit.Set(); |
81 markbit.Next().Set(); | 114 markbit.Next().Set(); |
82 } | 115 } |
83 | 116 |
| 117 static void SetAllMarkBitsInRange(MarkBit start, MarkBit end); |
| 118 static void ClearAllMarkBitsOfCellsContainedInRange(MarkBit start, |
| 119 MarkBit end); |
| 120 |
84 void TransferMark(Address old_start, Address new_start); | 121 void TransferMark(Address old_start, Address new_start); |
85 | 122 |
86 #ifdef DEBUG | 123 #ifdef DEBUG |
87 enum ObjectColor { | 124 enum ObjectColor { |
88 BLACK_OBJECT, | 125 BLACK_OBJECT, |
89 WHITE_OBJECT, | 126 WHITE_OBJECT, |
90 GREY_OBJECT, | 127 GREY_OBJECT, |
91 IMPOSSIBLE_COLOR | 128 IMPOSSIBLE_COLOR |
92 }; | 129 }; |
93 | 130 |
(...skipping 884 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
978 private: | 1015 private: |
979 MarkCompactCollector* collector_; | 1016 MarkCompactCollector* collector_; |
980 }; | 1017 }; |
981 | 1018 |
982 | 1019 |
983 const char* AllocationSpaceName(AllocationSpace space); | 1020 const char* AllocationSpaceName(AllocationSpace space); |
984 } | 1021 } |
985 } // namespace v8::internal | 1022 } // namespace v8::internal |
986 | 1023 |
987 #endif // V8_HEAP_MARK_COMPACT_H_ | 1024 #endif // V8_HEAP_MARK_COMPACT_H_ |
OLD | NEW |