OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef V8_HEAP_OBJECT_STATS_H_ | 5 #ifndef V8_HEAP_OBJECT_STATS_H_ |
6 #define V8_HEAP_OBJECT_STATS_H_ | 6 #define V8_HEAP_OBJECT_STATS_H_ |
7 | 7 |
| 8 #include <set> |
| 9 |
8 #include "src/base/ieee754.h" | 10 #include "src/base/ieee754.h" |
9 #include "src/heap/heap.h" | 11 #include "src/heap/heap.h" |
10 #include "src/heap/objects-visiting.h" | 12 #include "src/heap/objects-visiting.h" |
11 #include "src/objects.h" | 13 #include "src/objects.h" |
12 | 14 |
13 namespace v8 { | 15 namespace v8 { |
14 namespace internal { | 16 namespace internal { |
15 | 17 |
16 class ObjectStats { | 18 class ObjectStats { |
17 public: | 19 public: |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 code_age_index < OBJECT_STATS_COUNT); | 53 code_age_index < OBJECT_STATS_COUNT); |
52 object_counts_[code_sub_type_index]++; | 54 object_counts_[code_sub_type_index]++; |
53 object_sizes_[code_sub_type_index] += size; | 55 object_sizes_[code_sub_type_index] += size; |
54 object_counts_[code_age_index]++; | 56 object_counts_[code_age_index]++; |
55 object_sizes_[code_age_index] += size; | 57 object_sizes_[code_age_index] += size; |
56 const int idx = HistogramIndexFromSize(size); | 58 const int idx = HistogramIndexFromSize(size); |
57 size_histogram_[code_sub_type_index][idx]++; | 59 size_histogram_[code_sub_type_index][idx]++; |
58 size_histogram_[code_age_index][idx]++; | 60 size_histogram_[code_age_index][idx]++; |
59 } | 61 } |
60 | 62 |
61 void RecordFixedArraySubTypeStats(int array_sub_type, size_t size, | 63 void RecordFixedArraySubTypeStats(FixedArrayBase* array, int array_sub_type, |
62 size_t over_allocated) { | 64 size_t size, size_t over_allocated) { |
| 65 auto it = visited_fixed_array_sub_types_.insert(array); |
| 66 if (!it.second) return; |
63 DCHECK(array_sub_type <= LAST_FIXED_ARRAY_SUB_TYPE); | 67 DCHECK(array_sub_type <= LAST_FIXED_ARRAY_SUB_TYPE); |
64 object_counts_[FIRST_FIXED_ARRAY_SUB_TYPE + array_sub_type]++; | 68 object_counts_[FIRST_FIXED_ARRAY_SUB_TYPE + array_sub_type]++; |
65 object_sizes_[FIRST_FIXED_ARRAY_SUB_TYPE + array_sub_type] += size; | 69 object_sizes_[FIRST_FIXED_ARRAY_SUB_TYPE + array_sub_type] += size; |
66 size_histogram_[FIRST_FIXED_ARRAY_SUB_TYPE + array_sub_type] | 70 size_histogram_[FIRST_FIXED_ARRAY_SUB_TYPE + array_sub_type] |
67 [HistogramIndexFromSize(size)]++; | 71 [HistogramIndexFromSize(size)]++; |
68 over_allocated_[FIRST_FIXED_ARRAY_SUB_TYPE + array_sub_type] += | 72 over_allocated_[FIRST_FIXED_ARRAY_SUB_TYPE + array_sub_type] += |
69 over_allocated; | 73 over_allocated; |
70 over_allocated_histogram_[FIRST_FIXED_ARRAY_SUB_TYPE + array_sub_type] | 74 over_allocated_histogram_[FIRST_FIXED_ARRAY_SUB_TYPE + array_sub_type] |
71 [HistogramIndexFromSize(over_allocated)]++; | 75 [HistogramIndexFromSize(over_allocated)]++; |
72 } | 76 } |
(...skipping 27 matching lines...) Expand all Loading... |
100 // Object counts and used memory by InstanceType. | 104 // Object counts and used memory by InstanceType. |
101 size_t object_counts_[OBJECT_STATS_COUNT]; | 105 size_t object_counts_[OBJECT_STATS_COUNT]; |
102 size_t object_counts_last_time_[OBJECT_STATS_COUNT]; | 106 size_t object_counts_last_time_[OBJECT_STATS_COUNT]; |
103 size_t object_sizes_[OBJECT_STATS_COUNT]; | 107 size_t object_sizes_[OBJECT_STATS_COUNT]; |
104 size_t object_sizes_last_time_[OBJECT_STATS_COUNT]; | 108 size_t object_sizes_last_time_[OBJECT_STATS_COUNT]; |
105 // Approximation of overallocated memory by InstanceType. | 109 // Approximation of overallocated memory by InstanceType. |
106 size_t over_allocated_[OBJECT_STATS_COUNT]; | 110 size_t over_allocated_[OBJECT_STATS_COUNT]; |
107 // Detailed histograms by InstanceType. | 111 // Detailed histograms by InstanceType. |
108 size_t size_histogram_[OBJECT_STATS_COUNT][kNumberOfBuckets]; | 112 size_t size_histogram_[OBJECT_STATS_COUNT][kNumberOfBuckets]; |
109 size_t over_allocated_histogram_[OBJECT_STATS_COUNT][kNumberOfBuckets]; | 113 size_t over_allocated_histogram_[OBJECT_STATS_COUNT][kNumberOfBuckets]; |
| 114 |
| 115 std::set<FixedArrayBase*> visited_fixed_array_sub_types_; |
110 }; | 116 }; |
111 | 117 |
112 class ObjectStatsCollector { | 118 class ObjectStatsCollector { |
113 public: | 119 public: |
114 static void CollectStatistics(ObjectStats* stats, HeapObject* obj); | 120 static void CollectStatistics(ObjectStats* stats, HeapObject* obj); |
115 | 121 |
116 private: | 122 private: |
117 static void RecordMapDetails(ObjectStats* stats, Heap* heap, HeapObject* obj); | 123 static void RecordMapDetails(ObjectStats* stats, Heap* heap, HeapObject* obj); |
118 static void RecordCodeDetails(ObjectStats* stats, Heap* heap, | 124 static void RecordCodeDetails(ObjectStats* stats, Heap* heap, |
119 HeapObject* obj); | 125 HeapObject* obj); |
120 static void RecordSharedFunctionInfoDetails(ObjectStats* stats, Heap* heap, | 126 static void RecordSharedFunctionInfoDetails(ObjectStats* stats, Heap* heap, |
121 HeapObject* obj); | 127 HeapObject* obj); |
122 static void RecordFixedArrayDetails(ObjectStats* stats, Heap* heap, | 128 static void RecordFixedArrayDetails(ObjectStats* stats, Heap* heap, |
123 HeapObject* obj); | 129 HeapObject* obj); |
124 | 130 |
125 static void RecordJSObjectDetails(ObjectStats* stats, Heap* heap, | 131 static void RecordJSObjectDetails(ObjectStats* stats, Heap* heap, |
126 JSObject* object); | 132 JSObject* object); |
127 static void RecordJSWeakCollectionDetails(ObjectStats* stats, Heap* heap, | 133 static void RecordJSWeakCollectionDetails(ObjectStats* stats, Heap* heap, |
128 JSWeakCollection* obj); | 134 JSWeakCollection* obj); |
| 135 static void RecordScriptDetails(ObjectStats* stats, Heap* heap, Script* obj); |
| 136 |
| 137 static void RecordFixedArrayHelper(ObjectStats* stats, Heap* heap, |
| 138 HeapObject* parent, FixedArray* array, |
| 139 int subtype, size_t overhead); |
129 }; | 140 }; |
130 | 141 |
131 } // namespace internal | 142 } // namespace internal |
132 } // namespace v8 | 143 } // namespace v8 |
133 | 144 |
134 #endif // V8_HEAP_OBJECT_STATS_H_ | 145 #endif // V8_HEAP_OBJECT_STATS_H_ |
OLD | NEW |