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