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 #include "src/heap/heap.h" | 5 #include "src/heap/heap.h" |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/api.h" | 8 #include "src/api.h" |
9 #include "src/ast/scopeinfo.h" | 9 #include "src/ast/scopeinfo.h" |
10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
(...skipping 1650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1661 { | 1661 { |
1662 // Copy roots. | 1662 // Copy roots. |
1663 TRACE_GC(tracer(), GCTracer::Scope::SCAVENGER_ROOTS); | 1663 TRACE_GC(tracer(), GCTracer::Scope::SCAVENGER_ROOTS); |
1664 IterateRoots(&scavenge_visitor, VISIT_ALL_IN_SCAVENGE); | 1664 IterateRoots(&scavenge_visitor, VISIT_ALL_IN_SCAVENGE); |
1665 } | 1665 } |
1666 | 1666 |
1667 { | 1667 { |
1668 // Copy objects reachable from the old generation. | 1668 // Copy objects reachable from the old generation. |
1669 TRACE_GC(tracer(), GCTracer::Scope::SCAVENGER_OLD_TO_NEW_POINTERS); | 1669 TRACE_GC(tracer(), GCTracer::Scope::SCAVENGER_OLD_TO_NEW_POINTERS); |
1670 RememberedSet<OLD_TO_NEW>::Iterate(this, [this](Address addr) { | 1670 RememberedSet<OLD_TO_NEW>::Iterate(this, [this](Address addr) { |
1671 return Scavenger::CheckAndScavengeObject(this, addr, DEFAULT_PROMOTION); | 1671 return Scavenger::CheckAndScavengeObject(this, addr); |
1672 }); | 1672 }); |
1673 | 1673 |
1674 RememberedSet<OLD_TO_NEW>::IterateTyped( | 1674 RememberedSet<OLD_TO_NEW>::IterateTyped( |
1675 this, [this](SlotType type, Address addr) { | 1675 this, [this](SlotType type, Address addr) { |
1676 return UpdateTypedSlotHelper::UpdateTypedSlot( | 1676 return UpdateTypedSlotHelper::UpdateTypedSlot( |
1677 isolate(), type, addr, [this](Object** addr) { | 1677 isolate(), type, addr, [this](Object** addr) { |
1678 // We expect that objects referenced by code are long living. | |
1679 // If we do not force promotion, then we need to clear | |
1680 // old_to_new slots in dead code objects after mark-compact. | |
1681 return Scavenger::CheckAndScavengeObject( | 1678 return Scavenger::CheckAndScavengeObject( |
1682 this, reinterpret_cast<Address>(addr), FORCE_PROMOTION); | 1679 this, reinterpret_cast<Address>(addr)); |
1683 }); | 1680 }); |
1684 }); | 1681 }); |
1685 } | 1682 } |
1686 | 1683 |
1687 { | 1684 { |
1688 TRACE_GC(tracer(), GCTracer::Scope::SCAVENGER_WEAK); | 1685 TRACE_GC(tracer(), GCTracer::Scope::SCAVENGER_WEAK); |
1689 // Copy objects reachable from the encountered weak collections list. | 1686 // Copy objects reachable from the encountered weak collections list. |
1690 scavenge_visitor.VisitPointer(&encountered_weak_collections_); | 1687 scavenge_visitor.VisitPointer(&encountered_weak_collections_); |
1691 // Copy objects reachable from the encountered weak cells. | 1688 // Copy objects reachable from the encountered weak cells. |
1692 scavenge_visitor.VisitPointer(&encountered_weak_cells_); | 1689 scavenge_visitor.VisitPointer(&encountered_weak_cells_); |
(...skipping 2968 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4661 Address end, bool record_slots, | 4658 Address end, bool record_slots, |
4662 ObjectSlotCallback callback) { | 4659 ObjectSlotCallback callback) { |
4663 Address slot_address = start; | 4660 Address slot_address = start; |
4664 Page* page = Page::FromAddress(start); | 4661 Page* page = Page::FromAddress(start); |
4665 | 4662 |
4666 while (slot_address < end) { | 4663 while (slot_address < end) { |
4667 Object** slot = reinterpret_cast<Object**>(slot_address); | 4664 Object** slot = reinterpret_cast<Object**>(slot_address); |
4668 Object* target = *slot; | 4665 Object* target = *slot; |
4669 if (target->IsHeapObject()) { | 4666 if (target->IsHeapObject()) { |
4670 if (Heap::InFromSpace(target)) { | 4667 if (Heap::InFromSpace(target)) { |
4671 callback(reinterpret_cast<HeapObject**>(slot), HeapObject::cast(target), | 4668 callback(reinterpret_cast<HeapObject**>(slot), |
4672 DEFAULT_PROMOTION); | 4669 HeapObject::cast(target)); |
4673 Object* new_target = *slot; | 4670 Object* new_target = *slot; |
4674 if (InNewSpace(new_target)) { | 4671 if (InNewSpace(new_target)) { |
4675 SLOW_DCHECK(Heap::InToSpace(new_target)); | 4672 SLOW_DCHECK(Heap::InToSpace(new_target)); |
4676 SLOW_DCHECK(new_target->IsHeapObject()); | 4673 SLOW_DCHECK(new_target->IsHeapObject()); |
4677 RememberedSet<OLD_TO_NEW>::Insert(page, slot_address); | 4674 RememberedSet<OLD_TO_NEW>::Insert(page, slot_address); |
4678 } | 4675 } |
4679 SLOW_DCHECK(!MarkCompactCollector::IsOnEvacuationCandidate(new_target)); | 4676 SLOW_DCHECK(!MarkCompactCollector::IsOnEvacuationCandidate(new_target)); |
4680 } else if (record_slots && | 4677 } else if (record_slots && |
4681 MarkCompactCollector::IsOnEvacuationCandidate(target)) { | 4678 MarkCompactCollector::IsOnEvacuationCandidate(target)) { |
4682 mark_compact_collector()->RecordSlot(object, slot, target); | 4679 mark_compact_collector()->RecordSlot(object, slot, target); |
(...skipping 1687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6370 } | 6367 } |
6371 | 6368 |
6372 | 6369 |
6373 // static | 6370 // static |
6374 int Heap::GetStaticVisitorIdForMap(Map* map) { | 6371 int Heap::GetStaticVisitorIdForMap(Map* map) { |
6375 return StaticVisitorBase::GetVisitorId(map); | 6372 return StaticVisitorBase::GetVisitorId(map); |
6376 } | 6373 } |
6377 | 6374 |
6378 } // namespace internal | 6375 } // namespace internal |
6379 } // namespace v8 | 6376 } // namespace v8 |
OLD | NEW |