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_INL_H_ | 5 #ifndef V8_HEAP_MARK_COMPACT_INL_H_ |
6 #define V8_HEAP_MARK_COMPACT_INL_H_ | 6 #define V8_HEAP_MARK_COMPACT_INL_H_ |
7 | 7 |
8 #include "src/heap/mark-compact.h" | 8 #include "src/heap/mark-compact.h" |
9 #include "src/heap/remembered-set.h" | 9 #include "src/heap/remembered-set.h" |
10 #include "src/isolate.h" | 10 #include "src/isolate.h" |
11 | 11 |
12 namespace v8 { | 12 namespace v8 { |
13 namespace internal { | 13 namespace internal { |
14 | 14 |
15 void MarkCompactCollector::PushBlack(HeapObject* obj) { | 15 void MarkCompactCollector::PushBlack(HeapObject* obj) { |
16 DCHECK(Marking::IsBlack(ObjectMarking::MarkBitFrom(obj))); | 16 DCHECK(Marking::IsBlack(ObjectMarking::MarkBitFrom(obj))); |
Hannes Payer (out of office)
2017/01/18 14:43:35
That would also short cut the double accessors: Ob
Michael Lippautz
2017/01/18 15:58:07
Done.
| |
17 if (marking_deque()->Push(obj)) { | 17 if (!marking_deque()->Push(obj)) { |
18 MemoryChunk::IncrementLiveBytes(obj, obj->Size()); | 18 ObjectMarking::BlackToGrey(obj); |
19 } else { | |
20 MarkBit mark_bit = ObjectMarking::MarkBitFrom(obj); | |
21 Marking::BlackToGrey(mark_bit); | |
22 } | 19 } |
23 } | 20 } |
24 | 21 |
25 | 22 |
26 void MarkCompactCollector::UnshiftBlack(HeapObject* obj) { | 23 void MarkCompactCollector::UnshiftBlack(HeapObject* obj) { |
27 DCHECK(Marking::IsBlack(ObjectMarking::MarkBitFrom(obj))); | 24 DCHECK(Marking::IsBlack(ObjectMarking::MarkBitFrom(obj))); |
28 if (!marking_deque()->Unshift(obj)) { | 25 if (!marking_deque()->Unshift(obj)) { |
29 MemoryChunk::IncrementLiveBytes(obj, -obj->Size()); | 26 ObjectMarking::BlackToGrey(obj); |
30 MarkBit mark_bit = ObjectMarking::MarkBitFrom(obj); | |
31 Marking::BlackToGrey(mark_bit); | |
32 } | 27 } |
33 } | 28 } |
34 | 29 |
35 | 30 |
36 void MarkCompactCollector::MarkObject(HeapObject* obj, MarkBit mark_bit) { | 31 void MarkCompactCollector::MarkObject(HeapObject* obj, MarkBit mark_bit) { |
37 DCHECK(ObjectMarking::MarkBitFrom(obj) == mark_bit); | 32 DCHECK(ObjectMarking::MarkBitFrom(obj) == mark_bit); |
38 if (Marking::IsWhite(mark_bit)) { | 33 if (Marking::IsWhite(mark_bit)) { |
39 Marking::WhiteToBlack(mark_bit); | 34 ObjectMarking::WhiteToBlack(obj); |
40 DCHECK(obj->GetIsolate()->heap()->Contains(obj)); | |
41 PushBlack(obj); | 35 PushBlack(obj); |
42 } | 36 } |
43 } | 37 } |
44 | 38 |
45 | 39 |
46 void MarkCompactCollector::SetMark(HeapObject* obj, MarkBit mark_bit) { | 40 void MarkCompactCollector::SetMark(HeapObject* obj, MarkBit mark_bit) { |
47 DCHECK(Marking::IsWhite(mark_bit)); | 41 DCHECK(Marking::IsWhite(ObjectMarking::MarkBitFrom(obj))); |
48 DCHECK(ObjectMarking::MarkBitFrom(obj) == mark_bit); | 42 DCHECK(ObjectMarking::MarkBitFrom(obj) == mark_bit); |
49 Marking::WhiteToBlack(mark_bit); | 43 ObjectMarking::WhiteToBlack(obj); |
50 MemoryChunk::IncrementLiveBytes(obj, obj->Size()); | |
51 } | 44 } |
52 | 45 |
53 | 46 |
54 bool MarkCompactCollector::IsMarked(Object* obj) { | 47 bool MarkCompactCollector::IsMarked(Object* obj) { |
55 DCHECK(obj->IsHeapObject()); | 48 DCHECK(obj->IsHeapObject()); |
56 HeapObject* heap_object = HeapObject::cast(obj); | 49 HeapObject* heap_object = HeapObject::cast(obj); |
57 return Marking::IsBlackOrGrey(ObjectMarking::MarkBitFrom(heap_object)); | 50 return Marking::IsBlackOrGrey(ObjectMarking::MarkBitFrom(heap_object)); |
58 } | 51 } |
59 | 52 |
60 | 53 |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
220 } | 213 } |
221 if (object != nullptr) return object; | 214 if (object != nullptr) return object; |
222 } | 215 } |
223 return nullptr; | 216 return nullptr; |
224 } | 217 } |
225 | 218 |
226 } // namespace internal | 219 } // namespace internal |
227 } // namespace v8 | 220 } // namespace v8 |
228 | 221 |
229 #endif // V8_HEAP_MARK_COMPACT_INL_H_ | 222 #endif // V8_HEAP_MARK_COMPACT_INL_H_ |
OLD | NEW |