| 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 "src/base/bits.h" | 7 #include "src/base/bits.h" |
| 8 #include "src/base/platform/platform.h" | 8 #include "src/base/platform/platform.h" |
| 9 #include "src/full-codegen/full-codegen.h" | 9 #include "src/full-codegen/full-codegen.h" |
| 10 #include "src/heap/slot-set.h" | 10 #include "src/heap/slot-set.h" |
| (...skipping 864 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 875 } | 875 } |
| 876 } | 876 } |
| 877 UNREACHABLE(); | 877 UNREACHABLE(); |
| 878 } | 878 } |
| 879 | 879 |
| 880 | 880 |
| 881 #ifdef DEBUG | 881 #ifdef DEBUG |
| 882 void MemoryAllocator::ReportStatistics() { | 882 void MemoryAllocator::ReportStatistics() { |
| 883 intptr_t size = Size(); | 883 intptr_t size = Size(); |
| 884 float pct = static_cast<float>(capacity_ - size) / capacity_; | 884 float pct = static_cast<float>(capacity_ - size) / capacity_; |
| 885 PrintF(" capacity: %" V8_PTR_PREFIX | 885 PrintF(" capacity: %" V8PRIdPTR ", used: %" V8PRIdPTR |
| 886 "d" | |
| 887 ", used: %" V8_PTR_PREFIX | |
| 888 "d" | |
| 889 ", available: %%%d\n\n", | 886 ", available: %%%d\n\n", |
| 890 capacity_, size, static_cast<int>(pct * 100)); | 887 capacity_, size, static_cast<int>(pct * 100)); |
| 891 } | 888 } |
| 892 #endif | 889 #endif |
| 893 | 890 |
| 894 | 891 |
| 895 int MemoryAllocator::CodePageGuardStartOffset() { | 892 int MemoryAllocator::CodePageGuardStartOffset() { |
| 896 // We are guarding code pages: the first OS page after the header | 893 // We are guarding code pages: the first OS page after the header |
| 897 // will be protected as non-writable. | 894 // will be protected as non-writable. |
| 898 return RoundUp(Page::kObjectStartOffset, base::OS::CommitPageSize()); | 895 return RoundUp(Page::kObjectStartOffset, base::OS::CommitPageSize()); |
| (...skipping 1156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2055 } | 2052 } |
| 2056 } | 2053 } |
| 2057 LOG(isolate, HeapSampleEndEvent("NewSpace", description)); | 2054 LOG(isolate, HeapSampleEndEvent("NewSpace", description)); |
| 2058 } | 2055 } |
| 2059 | 2056 |
| 2060 | 2057 |
| 2061 void NewSpace::ReportStatistics() { | 2058 void NewSpace::ReportStatistics() { |
| 2062 #ifdef DEBUG | 2059 #ifdef DEBUG |
| 2063 if (FLAG_heap_stats) { | 2060 if (FLAG_heap_stats) { |
| 2064 float pct = static_cast<float>(Available()) / TotalCapacity(); | 2061 float pct = static_cast<float>(Available()) / TotalCapacity(); |
| 2065 PrintF(" capacity: %" V8_PTR_PREFIX | 2062 PrintF(" capacity: %" V8PRIdPTR ", available: %" V8PRIdPTR ", %%%d\n", |
| 2066 "d" | |
| 2067 ", available: %" V8_PTR_PREFIX "d, %%%d\n", | |
| 2068 TotalCapacity(), Available(), static_cast<int>(pct * 100)); | 2063 TotalCapacity(), Available(), static_cast<int>(pct * 100)); |
| 2069 PrintF("\n Object Histogram:\n"); | 2064 PrintF("\n Object Histogram:\n"); |
| 2070 for (int i = 0; i <= LAST_TYPE; i++) { | 2065 for (int i = 0; i <= LAST_TYPE; i++) { |
| 2071 if (allocated_histogram_[i].number() > 0) { | 2066 if (allocated_histogram_[i].number() > 0) { |
| 2072 PrintF(" %-34s%10d (%10d bytes)\n", allocated_histogram_[i].name(), | 2067 PrintF(" %-34s%10d (%10d bytes)\n", allocated_histogram_[i].name(), |
| 2073 allocated_histogram_[i].number(), | 2068 allocated_histogram_[i].number(), |
| 2074 allocated_histogram_[i].bytes()); | 2069 allocated_histogram_[i].bytes()); |
| 2075 } | 2070 } |
| 2076 } | 2071 } |
| 2077 PrintF("\n"); | 2072 PrintF("\n"); |
| (...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2783 prev_pc <= code->instruction_end()); | 2778 prev_pc <= code->instruction_end()); |
| 2784 delta += static_cast<int>(code->instruction_end() - prev_pc); | 2779 delta += static_cast<int>(code->instruction_end() - prev_pc); |
| 2785 EnterComment(isolate, "NoComment", delta); | 2780 EnterComment(isolate, "NoComment", delta); |
| 2786 } | 2781 } |
| 2787 } | 2782 } |
| 2788 } | 2783 } |
| 2789 | 2784 |
| 2790 | 2785 |
| 2791 void PagedSpace::ReportStatistics() { | 2786 void PagedSpace::ReportStatistics() { |
| 2792 int pct = static_cast<int>(Available() * 100 / Capacity()); | 2787 int pct = static_cast<int>(Available() * 100 / Capacity()); |
| 2793 PrintF(" capacity: %" V8_PTR_PREFIX | 2788 PrintF(" capacity: %" V8PRIdPTR ", waste: %" V8PRIdPTR |
| 2794 "d" | 2789 ", available: %" V8PRIdPTR ", %%%d\n", |
| 2795 ", waste: %" V8_PTR_PREFIX | |
| 2796 "d" | |
| 2797 ", available: %" V8_PTR_PREFIX "d, %%%d\n", | |
| 2798 Capacity(), Waste(), Available(), pct); | 2790 Capacity(), Waste(), Available(), pct); |
| 2799 | 2791 |
| 2800 if (heap()->mark_compact_collector()->sweeping_in_progress()) { | 2792 if (heap()->mark_compact_collector()->sweeping_in_progress()) { |
| 2801 heap()->mark_compact_collector()->EnsureSweepingCompleted(); | 2793 heap()->mark_compact_collector()->EnsureSweepingCompleted(); |
| 2802 } | 2794 } |
| 2803 ClearHistograms(heap()->isolate()); | 2795 ClearHistograms(heap()->isolate()); |
| 2804 HeapObjectIterator obj_it(this); | 2796 HeapObjectIterator obj_it(this); |
| 2805 for (HeapObject* obj = obj_it.Next(); obj != NULL; obj = obj_it.Next()) | 2797 for (HeapObject* obj = obj_it.Next(); obj != NULL; obj = obj_it.Next()) |
| 2806 CollectHistogramInfo(obj); | 2798 CollectHistogramInfo(obj); |
| 2807 ReportHistogram(heap()->isolate(), true); | 2799 ReportHistogram(heap()->isolate(), true); |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3083 void LargeObjectSpace::Print() { | 3075 void LargeObjectSpace::Print() { |
| 3084 OFStream os(stdout); | 3076 OFStream os(stdout); |
| 3085 LargeObjectIterator it(this); | 3077 LargeObjectIterator it(this); |
| 3086 for (HeapObject* obj = it.Next(); obj != NULL; obj = it.Next()) { | 3078 for (HeapObject* obj = it.Next(); obj != NULL; obj = it.Next()) { |
| 3087 obj->Print(os); | 3079 obj->Print(os); |
| 3088 } | 3080 } |
| 3089 } | 3081 } |
| 3090 | 3082 |
| 3091 | 3083 |
| 3092 void LargeObjectSpace::ReportStatistics() { | 3084 void LargeObjectSpace::ReportStatistics() { |
| 3093 PrintF(" size: %" V8_PTR_PREFIX "d\n", size_); | 3085 PrintF(" size: %" V8PRIdPTR "\n", size_); |
| 3094 int num_objects = 0; | 3086 int num_objects = 0; |
| 3095 ClearHistograms(heap()->isolate()); | 3087 ClearHistograms(heap()->isolate()); |
| 3096 LargeObjectIterator it(this); | 3088 LargeObjectIterator it(this); |
| 3097 for (HeapObject* obj = it.Next(); obj != NULL; obj = it.Next()) { | 3089 for (HeapObject* obj = it.Next(); obj != NULL; obj = it.Next()) { |
| 3098 num_objects++; | 3090 num_objects++; |
| 3099 CollectHistogramInfo(obj); | 3091 CollectHistogramInfo(obj); |
| 3100 } | 3092 } |
| 3101 | 3093 |
| 3102 PrintF( | 3094 PrintF( |
| 3103 " number of objects %d, " | 3095 " number of objects %d, " |
| 3104 "size of objects %" V8_PTR_PREFIX "d\n", | 3096 "size of objects %" V8PRIdPTR "\n", |
| 3105 num_objects, objects_size_); | 3097 num_objects, objects_size_); |
| 3106 if (num_objects > 0) ReportHistogram(heap()->isolate(), false); | 3098 if (num_objects > 0) ReportHistogram(heap()->isolate(), false); |
| 3107 } | 3099 } |
| 3108 | 3100 |
| 3109 | 3101 |
| 3110 void LargeObjectSpace::CollectCodeStatistics() { | 3102 void LargeObjectSpace::CollectCodeStatistics() { |
| 3111 Isolate* isolate = heap()->isolate(); | 3103 Isolate* isolate = heap()->isolate(); |
| 3112 LargeObjectIterator obj_it(this); | 3104 LargeObjectIterator obj_it(this); |
| 3113 for (HeapObject* obj = obj_it.Next(); obj != NULL; obj = obj_it.Next()) { | 3105 for (HeapObject* obj = obj_it.Next(); obj != NULL; obj = obj_it.Next()) { |
| 3114 if (obj->IsAbstractCode()) { | 3106 if (obj->IsAbstractCode()) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 3136 object->ShortPrint(); | 3128 object->ShortPrint(); |
| 3137 PrintF("\n"); | 3129 PrintF("\n"); |
| 3138 } | 3130 } |
| 3139 printf(" --------------------------------------\n"); | 3131 printf(" --------------------------------------\n"); |
| 3140 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 3132 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); |
| 3141 } | 3133 } |
| 3142 | 3134 |
| 3143 #endif // DEBUG | 3135 #endif // DEBUG |
| 3144 } // namespace internal | 3136 } // namespace internal |
| 3145 } // namespace v8 | 3137 } // namespace v8 |
| OLD | NEW |