OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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/spaces.h" | 5 #include "src/heap/spaces.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/base/platform/platform.h" | 10 #include "src/base/platform/platform.h" |
(...skipping 2769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2780 for (Page* page : *this) { | 2780 for (Page* page : *this) { |
2781 size_t size = page->wasted_memory(); | 2781 size_t size = page->wasted_memory(); |
2782 if (size == 0) continue; | 2782 if (size == 0) continue; |
2783 DCHECK_GE(static_cast<size_t>(Page::kPageSize), size); | 2783 DCHECK_GE(static_cast<size_t>(Page::kPageSize), size); |
2784 Address address = page->OffsetToAddress(Page::kPageSize - size); | 2784 Address address = page->OffsetToAddress(Page::kPageSize - size); |
2785 heap()->CreateFillerObjectAt(address, static_cast<int>(size), | 2785 heap()->CreateFillerObjectAt(address, static_cast<int>(size), |
2786 ClearRecordedSlots::kNo); | 2786 ClearRecordedSlots::kNo); |
2787 } | 2787 } |
2788 } | 2788 } |
2789 | 2789 |
2790 | |
2791 HeapObject* PagedSpace::SweepAndRetryAllocation(int size_in_bytes) { | 2790 HeapObject* PagedSpace::SweepAndRetryAllocation(int size_in_bytes) { |
2792 MarkCompactCollector* collector = heap()->mark_compact_collector(); | 2791 MarkCompactCollector* collector = heap()->mark_compact_collector(); |
2793 if (collector->sweeping_in_progress()) { | 2792 if (collector->sweeping_in_progress()) { |
2794 // Wait for the sweeper threads here and complete the sweeping phase. | 2793 // Wait for the sweeper threads here and complete the sweeping phase. |
2795 collector->EnsureSweepingCompleted(); | 2794 collector->EnsureSweepingCompleted(); |
2796 | 2795 |
2797 // After waiting for the sweeper threads, there may be new free-list | 2796 // After waiting for the sweeper threads, there may be new free-list |
2798 // entries. | 2797 // entries. |
2799 return free_list_.Allocate(size_in_bytes); | 2798 return free_list_.Allocate(size_in_bytes); |
2800 } | 2799 } |
2801 return nullptr; | 2800 return nullptr; |
2802 } | 2801 } |
2803 | 2802 |
2804 | |
2805 HeapObject* CompactionSpace::SweepAndRetryAllocation(int size_in_bytes) { | 2803 HeapObject* CompactionSpace::SweepAndRetryAllocation(int size_in_bytes) { |
2806 MarkCompactCollector* collector = heap()->mark_compact_collector(); | 2804 MarkCompactCollector* collector = heap()->mark_compact_collector(); |
2807 if (collector->sweeping_in_progress()) { | 2805 if (collector->sweeping_in_progress()) { |
2808 collector->SweepAndRefill(this); | 2806 collector->SweepAndRefill(this); |
2809 return free_list_.Allocate(size_in_bytes); | 2807 return free_list_.Allocate(size_in_bytes); |
2810 } | 2808 } |
2811 return nullptr; | 2809 return nullptr; |
2812 } | 2810 } |
2813 | 2811 |
2814 HeapObject* PagedSpace::SlowAllocateRaw(int size_in_bytes) { | 2812 HeapObject* PagedSpace::SlowAllocateRaw(int size_in_bytes) { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2851 return SweepAndRetryAllocation(size_in_bytes); | 2849 return SweepAndRetryAllocation(size_in_bytes); |
2852 } | 2850 } |
2853 | 2851 |
2854 #ifdef DEBUG | 2852 #ifdef DEBUG |
2855 void PagedSpace::ReportStatistics() { | 2853 void PagedSpace::ReportStatistics() { |
2856 int pct = static_cast<int>(Available() * 100 / Capacity()); | 2854 int pct = static_cast<int>(Available() * 100 / Capacity()); |
2857 PrintF(" capacity: %" V8PRIdPTR ", waste: %" V8PRIdPTR | 2855 PrintF(" capacity: %" V8PRIdPTR ", waste: %" V8PRIdPTR |
2858 ", available: %" V8PRIdPTR ", %%%d\n", | 2856 ", available: %" V8PRIdPTR ", %%%d\n", |
2859 Capacity(), Waste(), Available(), pct); | 2857 Capacity(), Waste(), Available(), pct); |
2860 | 2858 |
2861 if (heap()->mark_compact_collector()->sweeping_in_progress()) { | 2859 heap()->mark_compact_collector()->EnsureSweepingCompleted(); |
2862 heap()->mark_compact_collector()->EnsureSweepingCompleted(); | |
2863 } | |
2864 ClearHistograms(heap()->isolate()); | 2860 ClearHistograms(heap()->isolate()); |
2865 HeapObjectIterator obj_it(this); | 2861 HeapObjectIterator obj_it(this); |
2866 for (HeapObject* obj = obj_it.Next(); obj != NULL; obj = obj_it.Next()) | 2862 for (HeapObject* obj = obj_it.Next(); obj != NULL; obj = obj_it.Next()) |
2867 CollectHistogramInfo(obj); | 2863 CollectHistogramInfo(obj); |
2868 ReportHistogram(heap()->isolate(), true); | 2864 ReportHistogram(heap()->isolate(), true); |
2869 } | 2865 } |
2870 #endif | 2866 #endif |
2871 | 2867 |
2872 | 2868 |
2873 // ----------------------------------------------------------------------------- | 2869 // ----------------------------------------------------------------------------- |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3229 object->ShortPrint(); | 3225 object->ShortPrint(); |
3230 PrintF("\n"); | 3226 PrintF("\n"); |
3231 } | 3227 } |
3232 printf(" --------------------------------------\n"); | 3228 printf(" --------------------------------------\n"); |
3233 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 3229 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); |
3234 } | 3230 } |
3235 | 3231 |
3236 #endif // DEBUG | 3232 #endif // DEBUG |
3237 } // namespace internal | 3233 } // namespace internal |
3238 } // namespace v8 | 3234 } // namespace v8 |
OLD | NEW |