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 1657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1668 heap_->UpdateAllocationSite<Heap::kCached>(object, | 1668 heap_->UpdateAllocationSite<Heap::kCached>(object, |
1669 local_pretenuring_feedback_); | 1669 local_pretenuring_feedback_); |
1670 int size = object->Size(); | 1670 int size = object->Size(); |
1671 HeapObject* target_object = nullptr; | 1671 HeapObject* target_object = nullptr; |
1672 if (heap_->ShouldBePromoted(object->address(), size) && | 1672 if (heap_->ShouldBePromoted(object->address(), size) && |
1673 TryEvacuateObject(compaction_spaces_->Get(OLD_SPACE), object, | 1673 TryEvacuateObject(compaction_spaces_->Get(OLD_SPACE), object, |
1674 &target_object)) { | 1674 &target_object)) { |
1675 // If we end up needing more special cases, we should factor this out. | 1675 // If we end up needing more special cases, we should factor this out. |
1676 if (V8_UNLIKELY(target_object->IsJSArrayBuffer())) { | 1676 if (V8_UNLIKELY(target_object->IsJSArrayBuffer())) { |
1677 heap_->array_buffer_tracker()->Promote( | 1677 heap_->array_buffer_tracker()->Promote( |
1678 JSArrayBuffer::cast(target_object)); | 1678 JSArrayBuffer::cast(target_object), |
| 1679 reinterpret_cast<JSArrayBuffer*>(object)); |
1679 } | 1680 } |
1680 promoted_size_ += size; | 1681 promoted_size_ += size; |
1681 return true; | 1682 return true; |
1682 } | 1683 } |
1683 HeapObject* target = nullptr; | 1684 HeapObject* target = nullptr; |
1684 AllocationSpace space = AllocateTargetObject(object, &target); | 1685 AllocationSpace space = AllocateTargetObject(object, &target); |
1685 MigrateObject(HeapObject::cast(target), object, size, space); | 1686 MigrateObject(HeapObject::cast(target), object, size, space); |
1686 if (V8_UNLIKELY(target->IsJSArrayBuffer())) { | 1687 if (V8_UNLIKELY(target->IsJSArrayBuffer())) { |
1687 heap_->array_buffer_tracker()->MarkLive(JSArrayBuffer::cast(target)); | 1688 heap_->array_buffer_tracker()->SemiSpaceCopy( |
| 1689 JSArrayBuffer::cast(target), |
| 1690 reinterpret_cast<JSArrayBuffer*>(object)); |
1688 } | 1691 } |
1689 semispace_copied_size_ += size; | 1692 semispace_copied_size_ += size; |
1690 return true; | 1693 return true; |
1691 } | 1694 } |
1692 | 1695 |
1693 intptr_t promoted_size() { return promoted_size_; } | 1696 intptr_t promoted_size() { return promoted_size_; } |
1694 intptr_t semispace_copied_size() { return semispace_copied_size_; } | 1697 intptr_t semispace_copied_size() { return semispace_copied_size_; } |
1695 | 1698 |
1696 private: | 1699 private: |
1697 enum NewSpaceAllocationMode { | 1700 enum NewSpaceAllocationMode { |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1804 static void TryMoveToOldSpace(Page* page, PagedSpace* owner) { | 1807 static void TryMoveToOldSpace(Page* page, PagedSpace* owner) { |
1805 if (page->heap()->new_space()->ReplaceWithEmptyPage(page)) { | 1808 if (page->heap()->new_space()->ReplaceWithEmptyPage(page)) { |
1806 Page* new_page = Page::ConvertNewToOld(page, owner); | 1809 Page* new_page = Page::ConvertNewToOld(page, owner); |
1807 new_page->SetFlag(Page::PAGE_NEW_OLD_PROMOTION); | 1810 new_page->SetFlag(Page::PAGE_NEW_OLD_PROMOTION); |
1808 } | 1811 } |
1809 } | 1812 } |
1810 | 1813 |
1811 inline bool Visit(HeapObject* object) { | 1814 inline bool Visit(HeapObject* object) { |
1812 if (V8_UNLIKELY(object->IsJSArrayBuffer())) { | 1815 if (V8_UNLIKELY(object->IsJSArrayBuffer())) { |
1813 object->GetHeap()->array_buffer_tracker()->Promote( | 1816 object->GetHeap()->array_buffer_tracker()->Promote( |
1814 JSArrayBuffer::cast(object)); | 1817 JSArrayBuffer::cast(object), JSArrayBuffer::cast(object)); |
1815 } | 1818 } |
1816 RecordMigratedSlotVisitor visitor; | 1819 RecordMigratedSlotVisitor visitor; |
1817 object->IterateBodyFast(&visitor); | 1820 object->IterateBodyFast(&visitor); |
1818 promoted_size_ += object->Size(); | 1821 promoted_size_ += object->Size(); |
1819 return true; | 1822 return true; |
1820 } | 1823 } |
1821 | 1824 |
1822 intptr_t promoted_size() { return promoted_size_; } | 1825 intptr_t promoted_size() { return promoted_size_; } |
1823 | 1826 |
1824 private: | 1827 private: |
1825 intptr_t promoted_size_; | 1828 intptr_t promoted_size_; |
1826 }; | 1829 }; |
1827 | 1830 |
1828 class MarkCompactCollector::EvacuateOldSpaceVisitor final | 1831 class MarkCompactCollector::EvacuateOldSpaceVisitor final |
1829 : public MarkCompactCollector::EvacuateVisitorBase { | 1832 : public MarkCompactCollector::EvacuateVisitorBase { |
1830 public: | 1833 public: |
1831 EvacuateOldSpaceVisitor(Heap* heap, | 1834 EvacuateOldSpaceVisitor(Heap* heap, |
1832 CompactionSpaceCollection* compaction_spaces) | 1835 CompactionSpaceCollection* compaction_spaces) |
1833 : EvacuateVisitorBase(heap, compaction_spaces) {} | 1836 : EvacuateVisitorBase(heap, compaction_spaces) {} |
1834 | 1837 |
1835 inline bool Visit(HeapObject* object) override { | 1838 inline bool Visit(HeapObject* object) override { |
1836 CompactionSpace* target_space = compaction_spaces_->Get( | 1839 CompactionSpace* target_space = compaction_spaces_->Get( |
1837 Page::FromAddress(object->address())->owner()->identity()); | 1840 Page::FromAddress(object->address())->owner()->identity()); |
1838 HeapObject* target_object = nullptr; | 1841 HeapObject* target_object = nullptr; |
1839 if (TryEvacuateObject(target_space, object, &target_object)) { | 1842 if (TryEvacuateObject(target_space, object, &target_object)) { |
1840 DCHECK(object->map_word().IsForwardingAddress()); | 1843 DCHECK(object->map_word().IsForwardingAddress()); |
| 1844 if (V8_UNLIKELY(target_object->IsJSArrayBuffer())) { |
| 1845 heap_->array_buffer_tracker()->Compact( |
| 1846 JSArrayBuffer::cast(target_object), |
| 1847 reinterpret_cast<JSArrayBuffer*>(object)); |
| 1848 } |
1841 return true; | 1849 return true; |
1842 } | 1850 } |
| 1851 if (V8_UNLIKELY(object->IsJSArrayBuffer())) { |
| 1852 heap_->array_buffer_tracker()->MarkLive(JSArrayBuffer::cast(object)); |
| 1853 } |
1843 return false; | 1854 return false; |
1844 } | 1855 } |
1845 }; | 1856 }; |
1846 | 1857 |
1847 class MarkCompactCollector::EvacuateRecordOnlyVisitor final | 1858 class MarkCompactCollector::EvacuateRecordOnlyVisitor final |
1848 : public MarkCompactCollector::HeapObjectVisitor { | 1859 : public MarkCompactCollector::HeapObjectVisitor { |
1849 public: | 1860 public: |
1850 explicit EvacuateRecordOnlyVisitor(AllocationSpace space) : space_(space) {} | 1861 explicit EvacuateRecordOnlyVisitor(AllocationSpace space) : space_(space) {} |
1851 | 1862 |
1852 inline bool Visit(HeapObject* object) { | 1863 inline bool Visit(HeapObject* object) { |
(...skipping 2094 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3947 MarkBit mark_bit = Marking::MarkBitFrom(host); | 3958 MarkBit mark_bit = Marking::MarkBitFrom(host); |
3948 if (Marking::IsBlack(mark_bit)) { | 3959 if (Marking::IsBlack(mark_bit)) { |
3949 RelocInfo rinfo(isolate(), pc, RelocInfo::CODE_TARGET, 0, host); | 3960 RelocInfo rinfo(isolate(), pc, RelocInfo::CODE_TARGET, 0, host); |
3950 RecordRelocSlot(host, &rinfo, target); | 3961 RecordRelocSlot(host, &rinfo, target); |
3951 } | 3962 } |
3952 } | 3963 } |
3953 } | 3964 } |
3954 | 3965 |
3955 } // namespace internal | 3966 } // namespace internal |
3956 } // namespace v8 | 3967 } // namespace v8 |
OLD | NEW |