| 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 1693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1704 }; | 1704 }; |
| 1705 | 1705 |
| 1706 class MarkCompactCollector::EvacuateNewSpaceVisitor final | 1706 class MarkCompactCollector::EvacuateNewSpaceVisitor final |
| 1707 : public MarkCompactCollector::EvacuateVisitorBase { | 1707 : public MarkCompactCollector::EvacuateVisitorBase { |
| 1708 public: | 1708 public: |
| 1709 static const intptr_t kLabSize = 4 * KB; | 1709 static const intptr_t kLabSize = 4 * KB; |
| 1710 static const intptr_t kMaxLabObjectSize = 256; | 1710 static const intptr_t kMaxLabObjectSize = 256; |
| 1711 | 1711 |
| 1712 explicit EvacuateNewSpaceVisitor(Heap* heap, | 1712 explicit EvacuateNewSpaceVisitor(Heap* heap, |
| 1713 CompactionSpaceCollection* compaction_spaces, | 1713 CompactionSpaceCollection* compaction_spaces, |
| 1714 HashMap* local_pretenuring_feedback) | 1714 base::HashMap* local_pretenuring_feedback) |
| 1715 : EvacuateVisitorBase(heap, compaction_spaces), | 1715 : EvacuateVisitorBase(heap, compaction_spaces), |
| 1716 buffer_(LocalAllocationBuffer::InvalidBuffer()), | 1716 buffer_(LocalAllocationBuffer::InvalidBuffer()), |
| 1717 space_to_allocate_(NEW_SPACE), | 1717 space_to_allocate_(NEW_SPACE), |
| 1718 promoted_size_(0), | 1718 promoted_size_(0), |
| 1719 semispace_copied_size_(0), | 1719 semispace_copied_size_(0), |
| 1720 local_pretenuring_feedback_(local_pretenuring_feedback) {} | 1720 local_pretenuring_feedback_(local_pretenuring_feedback) {} |
| 1721 | 1721 |
| 1722 inline bool Visit(HeapObject* object) override { | 1722 inline bool Visit(HeapObject* object) override { |
| 1723 heap_->UpdateAllocationSite<Heap::kCached>(object, | 1723 heap_->UpdateAllocationSite<Heap::kCached>(object, |
| 1724 local_pretenuring_feedback_); | 1724 local_pretenuring_feedback_); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1841 } | 1841 } |
| 1842 } | 1842 } |
| 1843 } | 1843 } |
| 1844 return allocation; | 1844 return allocation; |
| 1845 } | 1845 } |
| 1846 | 1846 |
| 1847 LocalAllocationBuffer buffer_; | 1847 LocalAllocationBuffer buffer_; |
| 1848 AllocationSpace space_to_allocate_; | 1848 AllocationSpace space_to_allocate_; |
| 1849 intptr_t promoted_size_; | 1849 intptr_t promoted_size_; |
| 1850 intptr_t semispace_copied_size_; | 1850 intptr_t semispace_copied_size_; |
| 1851 HashMap* local_pretenuring_feedback_; | 1851 base::HashMap* local_pretenuring_feedback_; |
| 1852 }; | 1852 }; |
| 1853 | 1853 |
| 1854 class MarkCompactCollector::EvacuateNewSpacePageVisitor final | 1854 class MarkCompactCollector::EvacuateNewSpacePageVisitor final |
| 1855 : public MarkCompactCollector::HeapObjectVisitor { | 1855 : public MarkCompactCollector::HeapObjectVisitor { |
| 1856 public: | 1856 public: |
| 1857 explicit EvacuateNewSpacePageVisitor(Heap* heap) | 1857 explicit EvacuateNewSpacePageVisitor(Heap* heap) |
| 1858 : heap_(heap), promoted_size_(0) {} | 1858 : heap_(heap), promoted_size_(0) {} |
| 1859 | 1859 |
| 1860 static void TryMoveToOldSpace(Page* page, PagedSpace* owner) { | 1860 static void TryMoveToOldSpace(Page* page, PagedSpace* owner) { |
| 1861 if (page->heap()->new_space()->ReplaceWithEmptyPage(page)) { | 1861 if (page->heap()->new_space()->ReplaceWithEmptyPage(page)) { |
| (...skipping 1155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3017 // evacuation. | 3017 // evacuation. |
| 3018 static int PageEvacuationThreshold() { | 3018 static int PageEvacuationThreshold() { |
| 3019 if (FLAG_page_promotion) | 3019 if (FLAG_page_promotion) |
| 3020 return FLAG_page_promotion_threshold * Page::kAllocatableMemory / 100; | 3020 return FLAG_page_promotion_threshold * Page::kAllocatableMemory / 100; |
| 3021 return Page::kAllocatableMemory + kPointerSize; | 3021 return Page::kAllocatableMemory + kPointerSize; |
| 3022 } | 3022 } |
| 3023 | 3023 |
| 3024 explicit Evacuator(MarkCompactCollector* collector) | 3024 explicit Evacuator(MarkCompactCollector* collector) |
| 3025 : collector_(collector), | 3025 : collector_(collector), |
| 3026 compaction_spaces_(collector->heap()), | 3026 compaction_spaces_(collector->heap()), |
| 3027 local_pretenuring_feedback_(HashMap::PointersMatch, | 3027 local_pretenuring_feedback_(base::HashMap::PointersMatch, |
| 3028 kInitialLocalPretenuringFeedbackCapacity), | 3028 kInitialLocalPretenuringFeedbackCapacity), |
| 3029 new_space_visitor_(collector->heap(), &compaction_spaces_, | 3029 new_space_visitor_(collector->heap(), &compaction_spaces_, |
| 3030 &local_pretenuring_feedback_), | 3030 &local_pretenuring_feedback_), |
| 3031 new_space_page_visitor(collector->heap()), | 3031 new_space_page_visitor(collector->heap()), |
| 3032 old_space_visitor_(collector->heap(), &compaction_spaces_), | 3032 old_space_visitor_(collector->heap(), &compaction_spaces_), |
| 3033 duration_(0.0), | 3033 duration_(0.0), |
| 3034 bytes_compacted_(0) {} | 3034 bytes_compacted_(0) {} |
| 3035 | 3035 |
| 3036 inline bool EvacuatePage(Page* chunk); | 3036 inline bool EvacuatePage(Page* chunk); |
| 3037 | 3037 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 3066 bytes_compacted_ += bytes_compacted; | 3066 bytes_compacted_ += bytes_compacted; |
| 3067 } | 3067 } |
| 3068 | 3068 |
| 3069 template <IterationMode mode, class Visitor> | 3069 template <IterationMode mode, class Visitor> |
| 3070 inline bool EvacuateSinglePage(Page* p, Visitor* visitor); | 3070 inline bool EvacuateSinglePage(Page* p, Visitor* visitor); |
| 3071 | 3071 |
| 3072 MarkCompactCollector* collector_; | 3072 MarkCompactCollector* collector_; |
| 3073 | 3073 |
| 3074 // Locally cached collector data. | 3074 // Locally cached collector data. |
| 3075 CompactionSpaceCollection compaction_spaces_; | 3075 CompactionSpaceCollection compaction_spaces_; |
| 3076 HashMap local_pretenuring_feedback_; | 3076 base::HashMap local_pretenuring_feedback_; |
| 3077 | 3077 |
| 3078 // Visitors for the corresponding spaces. | 3078 // Visitors for the corresponding spaces. |
| 3079 EvacuateNewSpaceVisitor new_space_visitor_; | 3079 EvacuateNewSpaceVisitor new_space_visitor_; |
| 3080 EvacuateNewSpacePageVisitor new_space_page_visitor; | 3080 EvacuateNewSpacePageVisitor new_space_page_visitor; |
| 3081 EvacuateOldSpaceVisitor old_space_visitor_; | 3081 EvacuateOldSpaceVisitor old_space_visitor_; |
| 3082 | 3082 |
| 3083 // Book keeping info. | 3083 // Book keeping info. |
| 3084 double duration_; | 3084 double duration_; |
| 3085 intptr_t bytes_compacted_; | 3085 intptr_t bytes_compacted_; |
| 3086 }; | 3086 }; |
| (...skipping 854 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3941 MarkBit mark_bit = Marking::MarkBitFrom(host); | 3941 MarkBit mark_bit = Marking::MarkBitFrom(host); |
| 3942 if (Marking::IsBlack(mark_bit)) { | 3942 if (Marking::IsBlack(mark_bit)) { |
| 3943 RelocInfo rinfo(isolate(), pc, RelocInfo::CODE_TARGET, 0, host); | 3943 RelocInfo rinfo(isolate(), pc, RelocInfo::CODE_TARGET, 0, host); |
| 3944 RecordRelocSlot(host, &rinfo, target); | 3944 RecordRelocSlot(host, &rinfo, target); |
| 3945 } | 3945 } |
| 3946 } | 3946 } |
| 3947 } | 3947 } |
| 3948 | 3948 |
| 3949 } // namespace internal | 3949 } // namespace internal |
| 3950 } // namespace v8 | 3950 } // namespace v8 |
| OLD | NEW |