| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef V8_MARK_COMPACT_INL_H_ | |
| 6 #define V8_MARK_COMPACT_INL_H_ | |
| 7 | |
| 8 #include <memory.h> | |
| 9 | |
| 10 #include "src/isolate.h" | |
| 11 #include "src/mark-compact.h" | |
| 12 | |
| 13 | |
| 14 namespace v8 { | |
| 15 namespace internal { | |
| 16 | |
| 17 | |
| 18 MarkBit Marking::MarkBitFrom(Address addr) { | |
| 19 MemoryChunk* p = MemoryChunk::FromAddress(addr); | |
| 20 return p->markbits()->MarkBitFromIndex(p->AddressToMarkbitIndex(addr), | |
| 21 p->ContainsOnlyData()); | |
| 22 } | |
| 23 | |
| 24 | |
| 25 void MarkCompactCollector::SetFlags(int flags) { | |
| 26 sweep_precisely_ = ((flags & Heap::kSweepPreciselyMask) != 0); | |
| 27 reduce_memory_footprint_ = ((flags & Heap::kReduceMemoryFootprintMask) != 0); | |
| 28 abort_incremental_marking_ = | |
| 29 ((flags & Heap::kAbortIncrementalMarkingMask) != 0); | |
| 30 } | |
| 31 | |
| 32 | |
| 33 void MarkCompactCollector::MarkObject(HeapObject* obj, MarkBit mark_bit) { | |
| 34 DCHECK(Marking::MarkBitFrom(obj) == mark_bit); | |
| 35 if (!mark_bit.Get()) { | |
| 36 mark_bit.Set(); | |
| 37 MemoryChunk::IncrementLiveBytesFromGC(obj->address(), obj->Size()); | |
| 38 DCHECK(IsMarked(obj)); | |
| 39 DCHECK(obj->GetIsolate()->heap()->Contains(obj)); | |
| 40 marking_deque_.PushBlack(obj); | |
| 41 } | |
| 42 } | |
| 43 | |
| 44 | |
| 45 void MarkCompactCollector::SetMark(HeapObject* obj, MarkBit mark_bit) { | |
| 46 DCHECK(!mark_bit.Get()); | |
| 47 DCHECK(Marking::MarkBitFrom(obj) == mark_bit); | |
| 48 mark_bit.Set(); | |
| 49 MemoryChunk::IncrementLiveBytesFromGC(obj->address(), obj->Size()); | |
| 50 } | |
| 51 | |
| 52 | |
| 53 bool MarkCompactCollector::IsMarked(Object* obj) { | |
| 54 DCHECK(obj->IsHeapObject()); | |
| 55 HeapObject* heap_object = HeapObject::cast(obj); | |
| 56 return Marking::MarkBitFrom(heap_object).Get(); | |
| 57 } | |
| 58 | |
| 59 | |
| 60 void MarkCompactCollector::RecordSlot(Object** anchor_slot, | |
| 61 Object** slot, | |
| 62 Object* object, | |
| 63 SlotsBuffer::AdditionMode mode) { | |
| 64 Page* object_page = Page::FromAddress(reinterpret_cast<Address>(object)); | |
| 65 if (object_page->IsEvacuationCandidate() && | |
| 66 !ShouldSkipEvacuationSlotRecording(anchor_slot)) { | |
| 67 if (!SlotsBuffer::AddTo(&slots_buffer_allocator_, | |
| 68 object_page->slots_buffer_address(), | |
| 69 slot, | |
| 70 mode)) { | |
| 71 EvictEvacuationCandidate(object_page); | |
| 72 } | |
| 73 } | |
| 74 } | |
| 75 | |
| 76 | |
| 77 } } // namespace v8::internal | |
| 78 | |
| 79 #endif // V8_MARK_COMPACT_INL_H_ | |
| OLD | NEW |