| 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/isolate.h" | 9 #include "src/isolate.h" |
| 10 | 10 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 void MarkCompactCollector::SetFlags(int flags) { | 23 void MarkCompactCollector::SetFlags(int flags) { |
| 24 reduce_memory_footprint_ = ((flags & Heap::kReduceMemoryFootprintMask) != 0); | 24 reduce_memory_footprint_ = ((flags & Heap::kReduceMemoryFootprintMask) != 0); |
| 25 abort_incremental_marking_ = | 25 abort_incremental_marking_ = |
| 26 ((flags & Heap::kAbortIncrementalMarkingMask) != 0); | 26 ((flags & Heap::kAbortIncrementalMarkingMask) != 0); |
| 27 } | 27 } |
| 28 | 28 |
| 29 | 29 |
| 30 void MarkCompactCollector::MarkObject(HeapObject* obj, MarkBit mark_bit) { | 30 void MarkCompactCollector::MarkObject(HeapObject* obj, MarkBit mark_bit) { |
| 31 DCHECK(Marking::MarkBitFrom(obj) == mark_bit); | 31 DCHECK(Marking::MarkBitFrom(obj) == mark_bit); |
| 32 if (!mark_bit.Get()) { | 32 if (Marking::IsWhite(mark_bit)) { |
| 33 mark_bit.Set(); | 33 Marking::WhiteToBlack(mark_bit); |
| 34 MemoryChunk::IncrementLiveBytesFromGC(obj->address(), obj->Size()); | 34 MemoryChunk::IncrementLiveBytesFromGC(obj->address(), obj->Size()); |
| 35 DCHECK(IsMarked(obj)); | |
| 36 DCHECK(obj->GetIsolate()->heap()->Contains(obj)); | 35 DCHECK(obj->GetIsolate()->heap()->Contains(obj)); |
| 37 marking_deque_.PushBlack(obj); | 36 marking_deque_.PushBlack(obj); |
| 38 } | 37 } |
| 39 } | 38 } |
| 40 | 39 |
| 41 | 40 |
| 42 void MarkCompactCollector::SetMark(HeapObject* obj, MarkBit mark_bit) { | 41 void MarkCompactCollector::SetMark(HeapObject* obj, MarkBit mark_bit) { |
| 43 DCHECK(!mark_bit.Get()); | 42 DCHECK(Marking::IsWhite(mark_bit)); |
| 44 DCHECK(Marking::MarkBitFrom(obj) == mark_bit); | 43 DCHECK(Marking::MarkBitFrom(obj) == mark_bit); |
| 45 mark_bit.Set(); | 44 Marking::WhiteToBlack(mark_bit); |
| 46 MemoryChunk::IncrementLiveBytesFromGC(obj->address(), obj->Size()); | 45 MemoryChunk::IncrementLiveBytesFromGC(obj->address(), obj->Size()); |
| 47 } | 46 } |
| 48 | 47 |
| 49 | 48 |
| 50 bool MarkCompactCollector::IsMarked(Object* obj) { | 49 bool MarkCompactCollector::IsMarked(Object* obj) { |
| 51 DCHECK(obj->IsHeapObject()); | 50 DCHECK(obj->IsHeapObject()); |
| 52 HeapObject* heap_object = HeapObject::cast(obj); | 51 HeapObject* heap_object = HeapObject::cast(obj); |
| 53 return Marking::MarkBitFrom(heap_object).Get(); | 52 return Marking::IsMarked(Marking::MarkBitFrom(heap_object)); |
| 54 } | 53 } |
| 55 | 54 |
| 56 | 55 |
| 57 void MarkCompactCollector::RecordSlot(Object** anchor_slot, Object** slot, | 56 void MarkCompactCollector::RecordSlot(Object** anchor_slot, Object** slot, |
| 58 Object* object, | 57 Object* object, |
| 59 SlotsBuffer::AdditionMode mode) { | 58 SlotsBuffer::AdditionMode mode) { |
| 60 Page* object_page = Page::FromAddress(reinterpret_cast<Address>(object)); | 59 Page* object_page = Page::FromAddress(reinterpret_cast<Address>(object)); |
| 61 if (object_page->IsEvacuationCandidate() && | 60 if (object_page->IsEvacuationCandidate() && |
| 62 !ShouldSkipEvacuationSlotRecording(anchor_slot)) { | 61 !ShouldSkipEvacuationSlotRecording(anchor_slot)) { |
| 63 if (!SlotsBuffer::AddTo(&slots_buffer_allocator_, | 62 if (!SlotsBuffer::AddTo(&slots_buffer_allocator_, |
| 64 object_page->slots_buffer_address(), slot, mode)) { | 63 object_page->slots_buffer_address(), slot, mode)) { |
| 65 EvictEvacuationCandidate(object_page); | 64 EvictEvacuationCandidate(object_page); |
| 66 } | 65 } |
| 67 } | 66 } |
| 68 } | 67 } |
| 69 } | 68 } |
| 70 } // namespace v8::internal | 69 } // namespace v8::internal |
| 71 | 70 |
| 72 #endif // V8_HEAP_MARK_COMPACT_INL_H_ | 71 #endif // V8_HEAP_MARK_COMPACT_INL_H_ |
| OLD | NEW |