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 22 matching lines...) Expand all Loading... |
33 namespace v8 { | 33 namespace v8 { |
34 namespace internal { | 34 namespace internal { |
35 | 35 |
36 | 36 |
37 void IncrementalMarking::RecordWrite(HeapObject* obj, Object* value) { | 37 void IncrementalMarking::RecordWrite(HeapObject* obj, Object* value) { |
38 if (!IsStopped() && value->IsHeapObject()) { | 38 if (!IsStopped() && value->IsHeapObject()) { |
39 MarkBit value_bit = heap_->marking()->MarkBitFrom(HeapObject::cast(value)); | 39 MarkBit value_bit = heap_->marking()->MarkBitFrom(HeapObject::cast(value)); |
40 if (IsWhite(value_bit)) { | 40 if (IsWhite(value_bit)) { |
41 MarkBit obj_bit = heap_->marking()->MarkBitFrom(obj); | 41 MarkBit obj_bit = heap_->marking()->MarkBitFrom(obj); |
42 if (IsBlack(obj_bit)) { | 42 if (IsBlack(obj_bit)) { |
43 BlackToGreyAndPush(obj, obj_bit); | 43 BlackToGreyAndUnshift(obj, obj_bit); |
44 RestartIfNotMarking(); | 44 RestartIfNotMarking(); |
45 } | 45 } |
46 } | 46 } |
47 } | 47 } |
48 } | 48 } |
49 | 49 |
50 | 50 |
51 void IncrementalMarking::RecordWriteOf(HeapObject* value) { | 51 void IncrementalMarking::RecordWriteOf(HeapObject* value) { |
52 if (state_ != STOPPED) { | 52 if (state_ != STOPPED) { |
53 MarkBit value_bit = heap_->marking()->MarkBitFrom(value); | 53 MarkBit value_bit = heap_->marking()->MarkBitFrom(value); |
54 if (IsWhite(value_bit)) { | 54 if (IsWhite(value_bit)) { |
55 WhiteToGreyAndPush(value, value_bit); | 55 WhiteToGreyAndPush(value, value_bit); |
56 RestartIfNotMarking(); | 56 RestartIfNotMarking(); |
57 } | 57 } |
58 } | 58 } |
59 } | 59 } |
60 | 60 |
61 | 61 |
62 void IncrementalMarking::RecordWrites(HeapObject* obj) { | 62 void IncrementalMarking::RecordWrites(HeapObject* obj) { |
63 if (!IsStopped()) { | 63 if (!IsStopped()) { |
64 MarkBit obj_bit = heap_->marking()->MarkBitFrom(obj); | 64 MarkBit obj_bit = heap_->marking()->MarkBitFrom(obj); |
65 if (IsBlack(obj_bit)) { | 65 if (IsBlack(obj_bit)) { |
66 BlackToGreyAndPush(obj, obj_bit); | 66 BlackToGreyAndUnshift(obj, obj_bit); |
67 RestartIfNotMarking(); | 67 RestartIfNotMarking(); |
68 } | 68 } |
69 } | 69 } |
70 } | 70 } |
71 | 71 |
72 | 72 |
73 void IncrementalMarking::BlackToGreyAndPush(HeapObject* obj, MarkBit mark_bit) { | 73 void IncrementalMarking::BlackToGreyAndUnshift(HeapObject* obj, |
| 74 MarkBit mark_bit) { |
74 ASSERT(heap_->marking()->MarkBitFrom(obj) == mark_bit); | 75 ASSERT(heap_->marking()->MarkBitFrom(obj) == mark_bit); |
75 ASSERT(obj->Size() >= 2*kPointerSize); | 76 ASSERT(obj->Size() >= 2*kPointerSize); |
76 ASSERT(!IsStopped()); | 77 ASSERT(!IsStopped()); |
77 ASSERT(IsBlack(mark_bit)); | 78 ASSERT(IsBlack(mark_bit)); |
78 mark_bit.Next().Set(); | 79 mark_bit.Next().Set(); |
79 ASSERT(IsGrey(mark_bit)); | 80 ASSERT(IsGrey(mark_bit)); |
80 | 81 |
81 marking_stack_.Push(obj); | 82 marking_deque_.Unshift(obj); |
82 ASSERT(!marking_stack_.overflowed()); | 83 ASSERT(!marking_deque_.overflowed()); |
83 } | 84 } |
84 | 85 |
85 | 86 |
86 void IncrementalMarking::WhiteToGreyAndPush(HeapObject* obj, MarkBit mark_bit) { | 87 void IncrementalMarking::WhiteToGreyAndPush(HeapObject* obj, MarkBit mark_bit) { |
87 WhiteToGrey(obj, mark_bit); | 88 WhiteToGrey(obj, mark_bit); |
88 marking_stack_.Push(obj); | 89 marking_deque_.Push(obj); |
89 ASSERT(!marking_stack_.overflowed()); | 90 ASSERT(!marking_deque_.overflowed()); |
90 } | 91 } |
91 | 92 |
92 | 93 |
93 void IncrementalMarking::WhiteToGrey(HeapObject* obj, MarkBit mark_bit) { | 94 void IncrementalMarking::WhiteToGrey(HeapObject* obj, MarkBit mark_bit) { |
94 ASSERT(heap_->marking()->MarkBitFrom(obj) == mark_bit); | 95 ASSERT(heap_->marking()->MarkBitFrom(obj) == mark_bit); |
95 ASSERT(obj->Size() >= 2*kPointerSize); | 96 ASSERT(obj->Size() >= 2*kPointerSize); |
96 ASSERT(!IsStopped()); | 97 ASSERT(!IsStopped()); |
97 ASSERT(IsWhite(mark_bit)); | 98 ASSERT(IsWhite(mark_bit)); |
98 mark_bit.Set(); | 99 mark_bit.Set(); |
99 mark_bit.Next().Set(); | 100 mark_bit.Next().Set(); |
100 ASSERT(IsGrey(mark_bit)); | 101 ASSERT(IsGrey(mark_bit)); |
101 } | 102 } |
102 | 103 |
103 | 104 |
104 IncrementalMarking::ObjectColor IncrementalMarking::Color(HeapObject* obj) { | 105 IncrementalMarking::ObjectColor IncrementalMarking::Color(HeapObject* obj) { |
105 MarkBit mark_bit = heap_->marking()->MarkBitFrom(obj); | 106 MarkBit mark_bit = heap_->marking()->MarkBitFrom(obj); |
106 if (IsBlack(mark_bit)) return BLACK_OBJECT; | 107 if (IsBlack(mark_bit)) return BLACK_OBJECT; |
107 if (IsWhite(mark_bit)) return WHITE_OBJECT; | 108 if (IsWhite(mark_bit)) return WHITE_OBJECT; |
108 if (IsGrey(mark_bit)) return GREY_OBJECT; | 109 if (IsGrey(mark_bit)) return GREY_OBJECT; |
109 UNREACHABLE(); | 110 UNREACHABLE(); |
110 return IMPOSSIBLE_COLOR; | 111 return IMPOSSIBLE_COLOR; |
111 } | 112 } |
112 | 113 |
113 | 114 |
114 } } // namespace v8::internal | 115 } } // namespace v8::internal |
115 | 116 |
116 #endif // V8_INCREMENTAL_MARKING_INL_H_ | 117 #endif // V8_INCREMENTAL_MARKING_INL_H_ |
OLD | NEW |