| 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/mark-compact.h" | 5 #include "src/heap/mark-compact.h" |
| 6 | 6 |
| 7 #include "src/base/atomicops.h" | 7 #include "src/base/atomicops.h" |
| 8 #include "src/base/bits.h" | 8 #include "src/base/bits.h" |
| 9 #include "src/base/sys-info.h" | 9 #include "src/base/sys-info.h" |
| 10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
| (...skipping 1535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1546 while (start < end) { | 1546 while (start < end) { |
| 1547 RecordMigratedSlot(*start, reinterpret_cast<Address>(start)); | 1547 RecordMigratedSlot(*start, reinterpret_cast<Address>(start)); |
| 1548 ++start; | 1548 ++start; |
| 1549 } | 1549 } |
| 1550 } | 1550 } |
| 1551 | 1551 |
| 1552 inline void VisitCodeEntry(Address code_entry_slot) final { | 1552 inline void VisitCodeEntry(Address code_entry_slot) final { |
| 1553 Address code_entry = Memory::Address_at(code_entry_slot); | 1553 Address code_entry = Memory::Address_at(code_entry_slot); |
| 1554 if (Page::FromAddress(code_entry)->IsEvacuationCandidate()) { | 1554 if (Page::FromAddress(code_entry)->IsEvacuationCandidate()) { |
| 1555 RememberedSet<OLD_TO_OLD>::InsertTyped(Page::FromAddress(code_entry_slot), | 1555 RememberedSet<OLD_TO_OLD>::InsertTyped(Page::FromAddress(code_entry_slot), |
| 1556 CODE_ENTRY_SLOT, code_entry_slot); | 1556 nullptr, CODE_ENTRY_SLOT, |
| 1557 code_entry_slot); |
| 1557 } | 1558 } |
| 1558 } | 1559 } |
| 1559 | 1560 |
| 1560 inline void VisitCodeTarget(RelocInfo* rinfo) final { | 1561 inline void VisitCodeTarget(RelocInfo* rinfo) final { |
| 1561 DCHECK(RelocInfo::IsCodeTarget(rinfo->rmode())); | 1562 DCHECK(RelocInfo::IsCodeTarget(rinfo->rmode())); |
| 1562 Code* target = Code::GetCodeFromTargetAddress(rinfo->target_address()); | 1563 Code* target = Code::GetCodeFromTargetAddress(rinfo->target_address()); |
| 1563 Code* host = rinfo->host(); | 1564 Code* host = rinfo->host(); |
| 1564 collector_->RecordRelocSlot(host, rinfo, target); | 1565 collector_->RecordRelocSlot(host, rinfo, target); |
| 1565 } | 1566 } |
| 1566 | 1567 |
| (...skipping 1250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2817 SlotType slot_type = SlotTypeForRMode(rmode); | 2818 SlotType slot_type = SlotTypeForRMode(rmode); |
| 2818 if (rinfo->IsInConstantPool()) { | 2819 if (rinfo->IsInConstantPool()) { |
| 2819 addr = rinfo->constant_pool_entry_address(); | 2820 addr = rinfo->constant_pool_entry_address(); |
| 2820 if (RelocInfo::IsCodeTarget(rmode)) { | 2821 if (RelocInfo::IsCodeTarget(rmode)) { |
| 2821 slot_type = CODE_ENTRY_SLOT; | 2822 slot_type = CODE_ENTRY_SLOT; |
| 2822 } else { | 2823 } else { |
| 2823 DCHECK(RelocInfo::IsEmbeddedObject(rmode)); | 2824 DCHECK(RelocInfo::IsEmbeddedObject(rmode)); |
| 2824 slot_type = OBJECT_SLOT; | 2825 slot_type = OBJECT_SLOT; |
| 2825 } | 2826 } |
| 2826 } | 2827 } |
| 2827 RememberedSet<OLD_TO_OLD>::InsertTyped(source_page, slot_type, addr); | 2828 RememberedSet<OLD_TO_OLD>::InsertTyped( |
| 2829 source_page, reinterpret_cast<Address>(host), slot_type, addr); |
| 2828 } | 2830 } |
| 2829 } | 2831 } |
| 2830 | 2832 |
| 2831 static inline SlotCallbackResult UpdateSlot(Object** slot) { | 2833 static inline SlotCallbackResult UpdateSlot(Object** slot) { |
| 2832 Object* obj = reinterpret_cast<Object*>( | 2834 Object* obj = reinterpret_cast<Object*>( |
| 2833 base::NoBarrier_Load(reinterpret_cast<base::AtomicWord*>(slot))); | 2835 base::NoBarrier_Load(reinterpret_cast<base::AtomicWord*>(slot))); |
| 2834 | 2836 |
| 2835 if (obj->IsHeapObject()) { | 2837 if (obj->IsHeapObject()) { |
| 2836 HeapObject* heap_obj = HeapObject::cast(obj); | 2838 HeapObject* heap_obj = HeapObject::cast(obj); |
| 2837 MapWord map_word = heap_obj->map_word(); | 2839 MapWord map_word = heap_obj->map_word(); |
| (...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3598 RememberedSet<OLD_TO_OLD>::Iterate(chunk, [](Address slot) { | 3600 RememberedSet<OLD_TO_OLD>::Iterate(chunk, [](Address slot) { |
| 3599 return UpdateSlot(reinterpret_cast<Object**>(slot)); | 3601 return UpdateSlot(reinterpret_cast<Object**>(slot)); |
| 3600 }); | 3602 }); |
| 3601 } | 3603 } |
| 3602 } | 3604 } |
| 3603 | 3605 |
| 3604 static void UpdateTypedPointers(Heap* heap, MemoryChunk* chunk) { | 3606 static void UpdateTypedPointers(Heap* heap, MemoryChunk* chunk) { |
| 3605 if (direction == OLD_TO_OLD) { | 3607 if (direction == OLD_TO_OLD) { |
| 3606 Isolate* isolate = heap->isolate(); | 3608 Isolate* isolate = heap->isolate(); |
| 3607 RememberedSet<OLD_TO_OLD>::IterateTyped( | 3609 RememberedSet<OLD_TO_OLD>::IterateTyped( |
| 3608 chunk, [isolate](SlotType type, Address slot) { | 3610 chunk, [isolate](SlotType type, Address host_addr, Address slot) { |
| 3609 return UpdateTypedSlotHelper::UpdateTypedSlot(isolate, type, slot, | 3611 return UpdateTypedSlotHelper::UpdateTypedSlot(isolate, type, slot, |
| 3610 UpdateSlot); | 3612 UpdateSlot); |
| 3611 }); | 3613 }); |
| 3612 } else { | 3614 } else { |
| 3613 Isolate* isolate = heap->isolate(); | 3615 Isolate* isolate = heap->isolate(); |
| 3614 RememberedSet<OLD_TO_NEW>::IterateTyped( | 3616 RememberedSet<OLD_TO_NEW>::IterateTyped( |
| 3615 chunk, [isolate, heap](SlotType type, Address slot) { | 3617 chunk, |
| 3618 [isolate, heap](SlotType type, Address host_addr, Address slot) { |
| 3616 return UpdateTypedSlotHelper::UpdateTypedSlot( | 3619 return UpdateTypedSlotHelper::UpdateTypedSlot( |
| 3617 isolate, type, slot, [heap](Object** slot) { | 3620 isolate, type, slot, [heap](Object** slot) { |
| 3618 return CheckAndUpdateOldToNewSlot( | 3621 return CheckAndUpdateOldToNewSlot( |
| 3619 heap, reinterpret_cast<Address>(slot)); | 3622 heap, reinterpret_cast<Address>(slot)); |
| 3620 }); | 3623 }); |
| 3621 }); | 3624 }); |
| 3622 } | 3625 } |
| 3623 } | 3626 } |
| 3624 | 3627 |
| 3625 static SlotCallbackResult CheckAndUpdateOldToNewSlot(Heap* heap, | 3628 static SlotCallbackResult CheckAndUpdateOldToNewSlot(Heap* heap, |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3960 } | 3963 } |
| 3961 | 3964 |
| 3962 void MarkCompactCollector::RecordCodeEntrySlot(HeapObject* host, Address slot, | 3965 void MarkCompactCollector::RecordCodeEntrySlot(HeapObject* host, Address slot, |
| 3963 Code* target) { | 3966 Code* target) { |
| 3964 Page* target_page = Page::FromAddress(reinterpret_cast<Address>(target)); | 3967 Page* target_page = Page::FromAddress(reinterpret_cast<Address>(target)); |
| 3965 Page* source_page = Page::FromAddress(reinterpret_cast<Address>(host)); | 3968 Page* source_page = Page::FromAddress(reinterpret_cast<Address>(host)); |
| 3966 if (target_page->IsEvacuationCandidate() && | 3969 if (target_page->IsEvacuationCandidate() && |
| 3967 !ShouldSkipEvacuationSlotRecording(host)) { | 3970 !ShouldSkipEvacuationSlotRecording(host)) { |
| 3968 // TODO(ulan): remove this check after investigating crbug.com/414964. | 3971 // TODO(ulan): remove this check after investigating crbug.com/414964. |
| 3969 CHECK(target->IsCode()); | 3972 CHECK(target->IsCode()); |
| 3970 RememberedSet<OLD_TO_OLD>::InsertTyped(source_page, CODE_ENTRY_SLOT, slot); | 3973 RememberedSet<OLD_TO_OLD>::InsertTyped( |
| 3974 source_page, reinterpret_cast<Address>(host), CODE_ENTRY_SLOT, slot); |
| 3971 } | 3975 } |
| 3972 } | 3976 } |
| 3973 | 3977 |
| 3974 | 3978 |
| 3975 void MarkCompactCollector::RecordCodeTargetPatch(Address pc, Code* target) { | 3979 void MarkCompactCollector::RecordCodeTargetPatch(Address pc, Code* target) { |
| 3976 DCHECK(heap()->gc_state() == Heap::MARK_COMPACT); | 3980 DCHECK(heap()->gc_state() == Heap::MARK_COMPACT); |
| 3977 if (is_compacting()) { | 3981 if (is_compacting()) { |
| 3978 Code* host = | 3982 Code* host = |
| 3979 isolate()->inner_pointer_to_code_cache()->GcSafeFindCodeForInnerPointer( | 3983 isolate()->inner_pointer_to_code_cache()->GcSafeFindCodeForInnerPointer( |
| 3980 pc); | 3984 pc); |
| 3981 MarkBit mark_bit = Marking::MarkBitFrom(host); | 3985 MarkBit mark_bit = Marking::MarkBitFrom(host); |
| 3982 if (Marking::IsBlack(mark_bit)) { | 3986 if (Marking::IsBlack(mark_bit)) { |
| 3983 RelocInfo rinfo(isolate(), pc, RelocInfo::CODE_TARGET, 0, host); | 3987 RelocInfo rinfo(isolate(), pc, RelocInfo::CODE_TARGET, 0, host); |
| 3984 RecordRelocSlot(host, &rinfo, target); | 3988 RecordRelocSlot(host, &rinfo, target); |
| 3985 } | 3989 } |
| 3986 } | 3990 } |
| 3987 } | 3991 } |
| 3988 | 3992 |
| 3989 } // namespace internal | 3993 } // namespace internal |
| 3990 } // namespace v8 | 3994 } // namespace v8 |
| OLD | NEW |