| 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(Marking::MarkBitFrom(obj))); | 16 DCHECK(Marking::IsBlack(ObjectMarking::MarkBitFrom(obj))); |
| 17 if (marking_deque_.Push(obj)) { | 17 if (marking_deque_.Push(obj)) { |
| 18 MemoryChunk::IncrementLiveBytesFromGC(obj, obj->Size()); | 18 MemoryChunk::IncrementLiveBytesFromGC(obj, obj->Size()); |
| 19 } else { | 19 } else { |
| 20 Marking::BlackToGrey(obj); | 20 MarkBit mark_bit = ObjectMarking::MarkBitFrom(obj); |
| 21 Marking::BlackToGrey(mark_bit); |
| 21 } | 22 } |
| 22 } | 23 } |
| 23 | 24 |
| 24 | 25 |
| 25 void MarkCompactCollector::UnshiftBlack(HeapObject* obj) { | 26 void MarkCompactCollector::UnshiftBlack(HeapObject* obj) { |
| 26 DCHECK(Marking::IsBlack(Marking::MarkBitFrom(obj))); | 27 DCHECK(Marking::IsBlack(ObjectMarking::MarkBitFrom(obj))); |
| 27 if (!marking_deque_.Unshift(obj)) { | 28 if (!marking_deque_.Unshift(obj)) { |
| 28 MemoryChunk::IncrementLiveBytesFromGC(obj, -obj->Size()); | 29 MemoryChunk::IncrementLiveBytesFromGC(obj, -obj->Size()); |
| 29 Marking::BlackToGrey(obj); | 30 MarkBit mark_bit = ObjectMarking::MarkBitFrom(obj); |
| 31 Marking::BlackToGrey(mark_bit); |
| 30 } | 32 } |
| 31 } | 33 } |
| 32 | 34 |
| 33 | 35 |
| 34 void MarkCompactCollector::MarkObject(HeapObject* obj, MarkBit mark_bit) { | 36 void MarkCompactCollector::MarkObject(HeapObject* obj, MarkBit mark_bit) { |
| 35 DCHECK(Marking::MarkBitFrom(obj) == mark_bit); | 37 DCHECK(ObjectMarking::MarkBitFrom(obj) == mark_bit); |
| 36 if (Marking::IsWhite(mark_bit)) { | 38 if (Marking::IsWhite(mark_bit)) { |
| 37 Marking::WhiteToBlack(mark_bit); | 39 Marking::WhiteToBlack(mark_bit); |
| 38 DCHECK(obj->GetIsolate()->heap()->Contains(obj)); | 40 DCHECK(obj->GetIsolate()->heap()->Contains(obj)); |
| 39 PushBlack(obj); | 41 PushBlack(obj); |
| 40 } | 42 } |
| 41 } | 43 } |
| 42 | 44 |
| 43 | 45 |
| 44 void MarkCompactCollector::SetMark(HeapObject* obj, MarkBit mark_bit) { | 46 void MarkCompactCollector::SetMark(HeapObject* obj, MarkBit mark_bit) { |
| 45 DCHECK(Marking::IsWhite(mark_bit)); | 47 DCHECK(Marking::IsWhite(mark_bit)); |
| 46 DCHECK(Marking::MarkBitFrom(obj) == mark_bit); | 48 DCHECK(ObjectMarking::MarkBitFrom(obj) == mark_bit); |
| 47 Marking::WhiteToBlack(mark_bit); | 49 Marking::WhiteToBlack(mark_bit); |
| 48 MemoryChunk::IncrementLiveBytesFromGC(obj, obj->Size()); | 50 MemoryChunk::IncrementLiveBytesFromGC(obj, obj->Size()); |
| 49 } | 51 } |
| 50 | 52 |
| 51 | 53 |
| 52 bool MarkCompactCollector::IsMarked(Object* obj) { | 54 bool MarkCompactCollector::IsMarked(Object* obj) { |
| 53 DCHECK(obj->IsHeapObject()); | 55 DCHECK(obj->IsHeapObject()); |
| 54 HeapObject* heap_object = HeapObject::cast(obj); | 56 HeapObject* heap_object = HeapObject::cast(obj); |
| 55 return Marking::IsBlackOrGrey(Marking::MarkBitFrom(heap_object)); | 57 return Marking::IsBlackOrGrey(ObjectMarking::MarkBitFrom(heap_object)); |
| 56 } | 58 } |
| 57 | 59 |
| 58 | 60 |
| 59 void MarkCompactCollector::RecordSlot(HeapObject* object, Object** slot, | 61 void MarkCompactCollector::RecordSlot(HeapObject* object, Object** slot, |
| 60 Object* target) { | 62 Object* target) { |
| 61 Page* target_page = Page::FromAddress(reinterpret_cast<Address>(target)); | 63 Page* target_page = Page::FromAddress(reinterpret_cast<Address>(target)); |
| 62 Page* source_page = Page::FromAddress(reinterpret_cast<Address>(object)); | 64 Page* source_page = Page::FromAddress(reinterpret_cast<Address>(object)); |
| 63 if (target_page->IsEvacuationCandidate() && | 65 if (target_page->IsEvacuationCandidate() && |
| 64 !ShouldSkipEvacuationSlotRecording(object)) { | 66 !ShouldSkipEvacuationSlotRecording(object)) { |
| 65 DCHECK(Marking::IsBlackOrGrey(Marking::MarkBitFrom(object))); | 67 DCHECK(Marking::IsBlackOrGrey(ObjectMarking::MarkBitFrom(object))); |
| 66 RememberedSet<OLD_TO_OLD>::Insert(source_page, | 68 RememberedSet<OLD_TO_OLD>::Insert(source_page, |
| 67 reinterpret_cast<Address>(slot)); | 69 reinterpret_cast<Address>(slot)); |
| 68 } | 70 } |
| 69 } | 71 } |
| 70 | 72 |
| 71 | 73 |
| 72 void CodeFlusher::AddCandidate(SharedFunctionInfo* shared_info) { | 74 void CodeFlusher::AddCandidate(SharedFunctionInfo* shared_info) { |
| 73 if (GetNextCandidate(shared_info) == nullptr) { | 75 if (GetNextCandidate(shared_info) == nullptr) { |
| 74 SetNextCandidate(shared_info, shared_function_info_candidates_head_); | 76 SetNextCandidate(shared_info, shared_function_info_candidates_head_); |
| 75 shared_function_info_candidates_head_ = shared_info; | 77 shared_function_info_candidates_head_ = shared_info; |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 } | 176 } |
| 175 if (object != nullptr) return object; | 177 if (object != nullptr) return object; |
| 176 } | 178 } |
| 177 return nullptr; | 179 return nullptr; |
| 178 } | 180 } |
| 179 | 181 |
| 180 } // namespace internal | 182 } // namespace internal |
| 181 } // namespace v8 | 183 } // namespace v8 |
| 182 | 184 |
| 183 #endif // V8_HEAP_MARK_COMPACT_INL_H_ | 185 #endif // V8_HEAP_MARK_COMPACT_INL_H_ |
| OLD | NEW |