OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 void MarkCompactCollector::SetFlags(int flags) { | 47 void MarkCompactCollector::SetFlags(int flags) { |
48 sweep_precisely_ = ((flags & Heap::kMakeHeapIterableMask) != 0); | 48 sweep_precisely_ = ((flags & Heap::kMakeHeapIterableMask) != 0); |
49 } | 49 } |
50 | 50 |
51 | 51 |
52 void MarkCompactCollector::MarkObject(HeapObject* obj, MarkBit mark_bit) { | 52 void MarkCompactCollector::MarkObject(HeapObject* obj, MarkBit mark_bit) { |
53 ASSERT(Marking::MarkBitFrom(obj) == mark_bit); | 53 ASSERT(Marking::MarkBitFrom(obj) == mark_bit); |
54 if (!mark_bit.Get()) { | 54 if (!mark_bit.Get()) { |
55 mark_bit.Set(); | 55 mark_bit.Set(); |
56 MemoryChunk::IncrementLiveBytes(obj->address(), obj->Size()); | 56 MemoryChunk::IncrementLiveBytes(obj->address(), obj->Size()); |
57 #ifdef DEBUG | |
58 UpdateLiveObjectCount(obj); | |
59 #endif | |
60 ProcessNewlyMarkedObject(obj); | 57 ProcessNewlyMarkedObject(obj); |
61 } | 58 } |
62 } | 59 } |
63 | 60 |
64 | 61 |
65 void MarkCompactCollector::SetMark(HeapObject* obj, MarkBit mark_bit) { | 62 void MarkCompactCollector::SetMark(HeapObject* obj, MarkBit mark_bit) { |
66 ASSERT(!mark_bit.Get()); | 63 ASSERT(!mark_bit.Get()); |
67 ASSERT(Marking::MarkBitFrom(obj) == mark_bit); | 64 ASSERT(Marking::MarkBitFrom(obj) == mark_bit); |
68 mark_bit.Set(); | 65 mark_bit.Set(); |
69 MemoryChunk::IncrementLiveBytes(obj->address(), obj->Size()); | 66 MemoryChunk::IncrementLiveBytes(obj->address(), obj->Size()); |
70 #ifdef DEBUG | |
71 UpdateLiveObjectCount(obj); | |
72 #endif | |
73 } | 67 } |
74 | 68 |
75 | 69 |
76 bool MarkCompactCollector::IsMarked(Object* obj) { | 70 bool MarkCompactCollector::IsMarked(Object* obj) { |
77 ASSERT(obj->IsHeapObject()); | 71 ASSERT(obj->IsHeapObject()); |
78 HeapObject* heap_object = HeapObject::cast(obj); | 72 HeapObject* heap_object = HeapObject::cast(obj); |
79 return Marking::MarkBitFrom(heap_object).Get(); | 73 return Marking::MarkBitFrom(heap_object).Get(); |
80 } | 74 } |
81 | 75 |
82 | 76 |
83 void MarkCompactCollector::RecordSlot(Object** anchor_slot, | 77 void MarkCompactCollector::RecordSlot(Object** anchor_slot, |
84 Object** slot, | 78 Object** slot, |
85 Object* object) { | 79 Object* object) { |
86 Page* object_page = Page::FromAddress(reinterpret_cast<Address>(object)); | 80 Page* object_page = Page::FromAddress(reinterpret_cast<Address>(object)); |
87 if (object_page->IsEvacuationCandidate() && | 81 if (object_page->IsEvacuationCandidate() && |
88 !ShouldSkipEvacuationSlotRecording(anchor_slot)) { | 82 !ShouldSkipEvacuationSlotRecording(anchor_slot)) { |
89 if (!SlotsBuffer::AddTo(&slots_buffer_allocator_, | 83 if (!SlotsBuffer::AddTo(&slots_buffer_allocator_, |
90 object_page->slots_buffer_address(), | 84 object_page->slots_buffer_address(), |
91 slot, | 85 slot, |
92 SlotsBuffer::FAIL_ON_OVERFLOW)) { | 86 SlotsBuffer::FAIL_ON_OVERFLOW)) { |
93 EvictEvacuationCandidate(object_page); | 87 EvictEvacuationCandidate(object_page); |
94 } | 88 } |
95 } | 89 } |
96 } | 90 } |
97 | 91 |
98 | 92 |
99 } } // namespace v8::internal | 93 } } // namespace v8::internal |
100 | 94 |
101 #endif // V8_MARK_COMPACT_INL_H_ | 95 #endif // V8_MARK_COMPACT_INL_H_ |
OLD | NEW |