| 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 1136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2035 } | 2032 } |
| 2036 } | 2033 } |
| 2037 LOG(isolate, HeapSampleEndEvent("NewSpace", description)); | 2034 LOG(isolate, HeapSampleEndEvent("NewSpace", description)); |
| 2038 } | 2035 } |
| 2039 | 2036 |
| 2040 | 2037 |
| 2041 void NewSpace::ReportStatistics() { | 2038 void NewSpace::ReportStatistics() { |
| 2042 #ifdef DEBUG | 2039 #ifdef DEBUG |
| 2043 if (FLAG_heap_stats) { | 2040 if (FLAG_heap_stats) { |
| 2044 float pct = static_cast<float>(Available()) / TotalCapacity(); | 2041 float pct = static_cast<float>(Available()) / TotalCapacity(); |
| 2045 PrintF(" capacity: %" V8_PTR_PREFIX | 2042 PrintF(" capacity: %" V8PRIdPTR ", available: %" V8PRIdPTR ", %%%d\n", |
| 2046 "d" | |
| 2047 ", available: %" V8_PTR_PREFIX "d, %%%d\n", | |
| 2048 TotalCapacity(), Available(), static_cast<int>(pct * 100)); | 2043 TotalCapacity(), Available(), static_cast<int>(pct * 100)); |
| 2049 PrintF("\n Object Histogram:\n"); | 2044 PrintF("\n Object Histogram:\n"); |
| 2050 for (int i = 0; i <= LAST_TYPE; i++) { | 2045 for (int i = 0; i <= LAST_TYPE; i++) { |
| 2051 if (allocated_histogram_[i].number() > 0) { | 2046 if (allocated_histogram_[i].number() > 0) { |
| 2052 PrintF(" %-34s%10d (%10d bytes)\n", allocated_histogram_[i].name(), | 2047 PrintF(" %-34s%10d (%10d bytes)\n", allocated_histogram_[i].name(), |
| 2053 allocated_histogram_[i].number(), | 2048 allocated_histogram_[i].number(), |
| 2054 allocated_histogram_[i].bytes()); | 2049 allocated_histogram_[i].bytes()); |
| 2055 } | 2050 } |
| 2056 } | 2051 } |
| 2057 PrintF("\n"); | 2052 PrintF("\n"); |
| (...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2763 prev_pc <= code->instruction_end()); | 2758 prev_pc <= code->instruction_end()); |
| 2764 delta += static_cast<int>(code->instruction_end() - prev_pc); | 2759 delta += static_cast<int>(code->instruction_end() - prev_pc); |
| 2765 EnterComment(isolate, "NoComment", delta); | 2760 EnterComment(isolate, "NoComment", delta); |
| 2766 } | 2761 } |
| 2767 } | 2762 } |
| 2768 } | 2763 } |
| 2769 | 2764 |
| 2770 | 2765 |
| 2771 void PagedSpace::ReportStatistics() { | 2766 void PagedSpace::ReportStatistics() { |
| 2772 int pct = static_cast<int>(Available() * 100 / Capacity()); | 2767 int pct = static_cast<int>(Available() * 100 / Capacity()); |
| 2773 PrintF(" capacity: %" V8_PTR_PREFIX | 2768 PrintF(" capacity: %" V8PRIdPTR ", waste: %" V8PRIdPTR |
| 2774 "d" | 2769 ", available: %" V8PRIdPTR ", %%%d\n", |
| 2775 ", waste: %" V8_PTR_PREFIX | |
| 2776 "d" | |
| 2777 ", available: %" V8_PTR_PREFIX "d, %%%d\n", | |
| 2778 Capacity(), Waste(), Available(), pct); | 2770 Capacity(), Waste(), Available(), pct); |
| 2779 | 2771 |
| 2780 if (heap()->mark_compact_collector()->sweeping_in_progress()) { | 2772 if (heap()->mark_compact_collector()->sweeping_in_progress()) { |
| 2781 heap()->mark_compact_collector()->EnsureSweepingCompleted(); | 2773 heap()->mark_compact_collector()->EnsureSweepingCompleted(); |
| 2782 } | 2774 } |
| 2783 ClearHistograms(heap()->isolate()); | 2775 ClearHistograms(heap()->isolate()); |
| 2784 HeapObjectIterator obj_it(this); | 2776 HeapObjectIterator obj_it(this); |
| 2785 for (HeapObject* obj = obj_it.Next(); obj != NULL; obj = obj_it.Next()) | 2777 for (HeapObject* obj = obj_it.Next(); obj != NULL; obj = obj_it.Next()) |
| 2786 CollectHistogramInfo(obj); | 2778 CollectHistogramInfo(obj); |
| 2787 ReportHistogram(heap()->isolate(), true); | 2779 ReportHistogram(heap()->isolate(), true); |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3068 void LargeObjectSpace::Print() { | 3060 void LargeObjectSpace::Print() { |
| 3069 OFStream os(stdout); | 3061 OFStream os(stdout); |
| 3070 LargeObjectIterator it(this); | 3062 LargeObjectIterator it(this); |
| 3071 for (HeapObject* obj = it.Next(); obj != NULL; obj = it.Next()) { | 3063 for (HeapObject* obj = it.Next(); obj != NULL; obj = it.Next()) { |
| 3072 obj->Print(os); | 3064 obj->Print(os); |
| 3073 } | 3065 } |
| 3074 } | 3066 } |
| 3075 | 3067 |
| 3076 | 3068 |
| 3077 void LargeObjectSpace::ReportStatistics() { | 3069 void LargeObjectSpace::ReportStatistics() { |
| 3078 PrintF(" size: %" V8_PTR_PREFIX "d\n", size_); | 3070 PrintF(" size: %" V8PRIdPTR "\n", size_); |
| 3079 int num_objects = 0; | 3071 int num_objects = 0; |
| 3080 ClearHistograms(heap()->isolate()); | 3072 ClearHistograms(heap()->isolate()); |
| 3081 LargeObjectIterator it(this); | 3073 LargeObjectIterator it(this); |
| 3082 for (HeapObject* obj = it.Next(); obj != NULL; obj = it.Next()) { | 3074 for (HeapObject* obj = it.Next(); obj != NULL; obj = it.Next()) { |
| 3083 num_objects++; | 3075 num_objects++; |
| 3084 CollectHistogramInfo(obj); | 3076 CollectHistogramInfo(obj); |
| 3085 } | 3077 } |
| 3086 | 3078 |
| 3087 PrintF( | 3079 PrintF( |
| 3088 " number of objects %d, " | 3080 " number of objects %d, " |
| 3089 "size of objects %" V8_PTR_PREFIX "d\n", | 3081 "size of objects %" V8PRIdPTR "\n", |
| 3090 num_objects, objects_size_); | 3082 num_objects, objects_size_); |
| 3091 if (num_objects > 0) ReportHistogram(heap()->isolate(), false); | 3083 if (num_objects > 0) ReportHistogram(heap()->isolate(), false); |
| 3092 } | 3084 } |
| 3093 | 3085 |
| 3094 | 3086 |
| 3095 void LargeObjectSpace::CollectCodeStatistics() { | 3087 void LargeObjectSpace::CollectCodeStatistics() { |
| 3096 Isolate* isolate = heap()->isolate(); | 3088 Isolate* isolate = heap()->isolate(); |
| 3097 LargeObjectIterator obj_it(this); | 3089 LargeObjectIterator obj_it(this); |
| 3098 for (HeapObject* obj = obj_it.Next(); obj != NULL; obj = obj_it.Next()) { | 3090 for (HeapObject* obj = obj_it.Next(); obj != NULL; obj = obj_it.Next()) { |
| 3099 if (obj->IsAbstractCode()) { | 3091 if (obj->IsAbstractCode()) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 3121 object->ShortPrint(); | 3113 object->ShortPrint(); |
| 3122 PrintF("\n"); | 3114 PrintF("\n"); |
| 3123 } | 3115 } |
| 3124 printf(" --------------------------------------\n"); | 3116 printf(" --------------------------------------\n"); |
| 3125 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); | 3117 printf(" Marked: %x, LiveCount: %x\n", mark_size, LiveBytes()); |
| 3126 } | 3118 } |
| 3127 | 3119 |
| 3128 #endif // DEBUG | 3120 #endif // DEBUG |
| 3129 } // namespace internal | 3121 } // namespace internal |
| 3130 } // namespace v8 | 3122 } // namespace v8 |
| OLD | NEW |