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