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(ObjectMarking::IsBlack(obj)); |
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(ObjectMarking::IsBlack(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 (ObjectMarking::IsWhite(obj)) { |
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 void MarkCompactCollector::SetMark(HeapObject* obj) { |
46 void MarkCompactCollector::SetMark(HeapObject* obj, MarkBit mark_bit) { | 40 DCHECK(ObjectMarking::IsWhite(obj)); |
47 DCHECK(Marking::IsWhite(mark_bit)); | 41 ObjectMarking::WhiteToBlack(obj); |
48 DCHECK(ObjectMarking::MarkBitFrom(obj) == mark_bit); | |
49 Marking::WhiteToBlack(mark_bit); | |
50 MemoryChunk::IncrementLiveBytes(obj, obj->Size()); | |
51 } | 42 } |
52 | 43 |
53 | 44 |
54 bool MarkCompactCollector::IsMarked(Object* obj) { | 45 bool MarkCompactCollector::IsMarked(Object* obj) { |
55 DCHECK(obj->IsHeapObject()); | 46 DCHECK(obj->IsHeapObject()); |
56 HeapObject* heap_object = HeapObject::cast(obj); | 47 return ObjectMarking::IsBlackOrGrey(HeapObject::cast(obj)); |
57 return Marking::IsBlackOrGrey(ObjectMarking::MarkBitFrom(heap_object)); | |
58 } | 48 } |
59 | 49 |
60 | 50 |
61 void MarkCompactCollector::RecordSlot(HeapObject* object, Object** slot, | 51 void MarkCompactCollector::RecordSlot(HeapObject* object, Object** slot, |
62 Object* target) { | 52 Object* target) { |
63 Page* target_page = Page::FromAddress(reinterpret_cast<Address>(target)); | 53 Page* target_page = Page::FromAddress(reinterpret_cast<Address>(target)); |
64 Page* source_page = Page::FromAddress(reinterpret_cast<Address>(object)); | 54 Page* source_page = Page::FromAddress(reinterpret_cast<Address>(object)); |
65 if (target_page->IsEvacuationCandidate() && | 55 if (target_page->IsEvacuationCandidate() && |
66 !ShouldSkipEvacuationSlotRecording(object)) { | 56 !ShouldSkipEvacuationSlotRecording(object)) { |
67 DCHECK(Marking::IsBlackOrGrey(ObjectMarking::MarkBitFrom(object))); | 57 DCHECK(IsMarked(object)); |
68 RememberedSet<OLD_TO_OLD>::Insert(source_page, | 58 RememberedSet<OLD_TO_OLD>::Insert(source_page, |
69 reinterpret_cast<Address>(slot)); | 59 reinterpret_cast<Address>(slot)); |
70 } | 60 } |
71 } | 61 } |
72 | 62 |
73 | 63 |
74 void CodeFlusher::AddCandidate(SharedFunctionInfo* shared_info) { | 64 void CodeFlusher::AddCandidate(SharedFunctionInfo* shared_info) { |
75 if (GetNextCandidate(shared_info) == nullptr) { | 65 if (GetNextCandidate(shared_info) == nullptr) { |
76 SetNextCandidate(shared_info, shared_function_info_candidates_head_); | 66 SetNextCandidate(shared_info, shared_function_info_candidates_head_); |
77 shared_function_info_candidates_head_ = shared_info; | 67 shared_function_info_candidates_head_ = shared_info; |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 } | 210 } |
221 if (object != nullptr) return object; | 211 if (object != nullptr) return object; |
222 } | 212 } |
223 return nullptr; | 213 return nullptr; |
224 } | 214 } |
225 | 215 |
226 } // namespace internal | 216 } // namespace internal |
227 } // namespace v8 | 217 } // namespace v8 |
228 | 218 |
229 #endif // V8_HEAP_MARK_COMPACT_INL_H_ | 219 #endif // V8_HEAP_MARK_COMPACT_INL_H_ |
OLD | NEW |