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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 return p->markbits()->MarkBitFromIndex(p->AddressToMarkbitIndex(addr), | 42 return p->markbits()->MarkBitFromIndex(p->AddressToMarkbitIndex(addr), |
43 p->ContainsOnlyData()); | 43 p->ContainsOnlyData()); |
44 } | 44 } |
45 | 45 |
46 | 46 |
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::ClearCacheOnMap(Map* map) { |
| 53 if (FLAG_cleanup_code_caches_at_gc) { |
| 54 map->ClearCodeCache(heap()); |
| 55 } |
| 56 } |
| 57 |
| 58 |
52 void MarkCompactCollector::MarkObject(HeapObject* obj, MarkBit mark_bit) { | 59 void MarkCompactCollector::MarkObject(HeapObject* obj, MarkBit mark_bit) { |
53 ASSERT(Marking::MarkBitFrom(obj) == mark_bit); | 60 ASSERT(Marking::MarkBitFrom(obj) == mark_bit); |
54 if (!mark_bit.Get()) { | 61 if (!mark_bit.Get()) { |
55 mark_bit.Set(); | 62 mark_bit.Set(); |
56 MemoryChunk::IncrementLiveBytesFromGC(obj->address(), obj->Size()); | 63 MemoryChunk::IncrementLiveBytesFromGC(obj->address(), obj->Size()); |
57 ProcessNewlyMarkedObject(obj); | 64 ProcessNewlyMarkedObject(obj); |
58 } | 65 } |
59 } | 66 } |
60 | 67 |
61 | 68 |
62 void MarkCompactCollector::SetMark(HeapObject* obj, MarkBit mark_bit) { | 69 void MarkCompactCollector::SetMark(HeapObject* obj, MarkBit mark_bit) { |
63 ASSERT(!mark_bit.Get()); | 70 ASSERT(!mark_bit.Get()); |
64 ASSERT(Marking::MarkBitFrom(obj) == mark_bit); | 71 ASSERT(Marking::MarkBitFrom(obj) == mark_bit); |
65 mark_bit.Set(); | 72 mark_bit.Set(); |
66 MemoryChunk::IncrementLiveBytesFromGC(obj->address(), obj->Size()); | 73 MemoryChunk::IncrementLiveBytesFromGC(obj->address(), obj->Size()); |
| 74 if (obj->IsMap()) { |
| 75 ClearCacheOnMap(Map::cast(obj)); |
| 76 } |
67 } | 77 } |
68 | 78 |
69 | 79 |
70 bool MarkCompactCollector::IsMarked(Object* obj) { | 80 bool MarkCompactCollector::IsMarked(Object* obj) { |
71 ASSERT(obj->IsHeapObject()); | 81 ASSERT(obj->IsHeapObject()); |
72 HeapObject* heap_object = HeapObject::cast(obj); | 82 HeapObject* heap_object = HeapObject::cast(obj); |
73 return Marking::MarkBitFrom(heap_object).Get(); | 83 return Marking::MarkBitFrom(heap_object).Get(); |
74 } | 84 } |
75 | 85 |
76 | 86 |
77 void MarkCompactCollector::RecordSlot(Object** anchor_slot, | 87 void MarkCompactCollector::RecordSlot(Object** anchor_slot, |
78 Object** slot, | 88 Object** slot, |
79 Object* object) { | 89 Object* object) { |
80 Page* object_page = Page::FromAddress(reinterpret_cast<Address>(object)); | 90 Page* object_page = Page::FromAddress(reinterpret_cast<Address>(object)); |
81 if (object_page->IsEvacuationCandidate() && | 91 if (object_page->IsEvacuationCandidate() && |
82 !ShouldSkipEvacuationSlotRecording(anchor_slot)) { | 92 !ShouldSkipEvacuationSlotRecording(anchor_slot)) { |
83 if (!SlotsBuffer::AddTo(&slots_buffer_allocator_, | 93 if (!SlotsBuffer::AddTo(&slots_buffer_allocator_, |
84 object_page->slots_buffer_address(), | 94 object_page->slots_buffer_address(), |
85 slot, | 95 slot, |
86 SlotsBuffer::FAIL_ON_OVERFLOW)) { | 96 SlotsBuffer::FAIL_ON_OVERFLOW)) { |
87 EvictEvacuationCandidate(object_page); | 97 EvictEvacuationCandidate(object_page); |
88 } | 98 } |
89 } | 99 } |
90 } | 100 } |
91 | 101 |
92 | 102 |
93 } } // namespace v8::internal | 103 } } // namespace v8::internal |
94 | 104 |
95 #endif // V8_MARK_COMPACT_INL_H_ | 105 #endif // V8_MARK_COMPACT_INL_H_ |
OLD | NEW |