Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/heap/object-stats.h

Issue 2181623002: [heap] ObjectStats: Cleanup and more FIXED_ARRAY sub types (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addressed comments Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/heap/mark-compact.cc ('k') | src/heap/object-stats.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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> 8 #include <set>
9 9
10 #include "src/base/ieee754.h" 10 #include "src/base/ieee754.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 code_age_index < OBJECT_STATS_COUNT); 53 code_age_index < OBJECT_STATS_COUNT);
54 object_counts_[code_sub_type_index]++; 54 object_counts_[code_sub_type_index]++;
55 object_sizes_[code_sub_type_index] += size; 55 object_sizes_[code_sub_type_index] += size;
56 object_counts_[code_age_index]++; 56 object_counts_[code_age_index]++;
57 object_sizes_[code_age_index] += size; 57 object_sizes_[code_age_index] += size;
58 const int idx = HistogramIndexFromSize(size); 58 const int idx = HistogramIndexFromSize(size);
59 size_histogram_[code_sub_type_index][idx]++; 59 size_histogram_[code_sub_type_index][idx]++;
60 size_histogram_[code_age_index][idx]++; 60 size_histogram_[code_age_index][idx]++;
61 } 61 }
62 62
63 void RecordFixedArraySubTypeStats(FixedArrayBase* array, int array_sub_type, 63 bool RecordFixedArraySubTypeStats(FixedArrayBase* array, int array_sub_type,
64 size_t size, size_t over_allocated) { 64 size_t size, size_t over_allocated) {
65 auto it = visited_fixed_array_sub_types_.insert(array); 65 auto it = visited_fixed_array_sub_types_.insert(array);
66 if (!it.second) return; 66 if (!it.second) return false;
67 DCHECK(array_sub_type <= LAST_FIXED_ARRAY_SUB_TYPE); 67 DCHECK(array_sub_type <= LAST_FIXED_ARRAY_SUB_TYPE);
68 object_counts_[FIRST_FIXED_ARRAY_SUB_TYPE + array_sub_type]++; 68 object_counts_[FIRST_FIXED_ARRAY_SUB_TYPE + array_sub_type]++;
69 object_sizes_[FIRST_FIXED_ARRAY_SUB_TYPE + array_sub_type] += size; 69 object_sizes_[FIRST_FIXED_ARRAY_SUB_TYPE + array_sub_type] += size;
70 size_histogram_[FIRST_FIXED_ARRAY_SUB_TYPE + array_sub_type] 70 size_histogram_[FIRST_FIXED_ARRAY_SUB_TYPE + array_sub_type]
71 [HistogramIndexFromSize(size)]++; 71 [HistogramIndexFromSize(size)]++;
72 over_allocated_[FIRST_FIXED_ARRAY_SUB_TYPE + array_sub_type] += 72 if (over_allocated > 0) {
73 over_allocated; 73 over_allocated_[FIRST_FIXED_ARRAY_SUB_TYPE + array_sub_type] +=
74 over_allocated_histogram_[FIRST_FIXED_ARRAY_SUB_TYPE + array_sub_type] 74 over_allocated;
75 [HistogramIndexFromSize(over_allocated)]++; 75 over_allocated_histogram_[FIRST_FIXED_ARRAY_SUB_TYPE + array_sub_type]
76 [HistogramIndexFromSize(over_allocated)]++;
77 }
78 return true;
76 } 79 }
77 80
78 size_t object_count_last_gc(size_t index) { 81 size_t object_count_last_gc(size_t index) {
79 return object_counts_last_time_[index]; 82 return object_counts_last_time_[index];
80 } 83 }
81 84
82 size_t object_size_last_gc(size_t index) { 85 size_t object_size_last_gc(size_t index) {
83 return object_sizes_last_time_[index]; 86 return object_sizes_last_time_[index];
84 } 87 }
85 88
(...skipping 24 matching lines...) Expand all
110 size_t over_allocated_[OBJECT_STATS_COUNT]; 113 size_t over_allocated_[OBJECT_STATS_COUNT];
111 // Detailed histograms by InstanceType. 114 // Detailed histograms by InstanceType.
112 size_t size_histogram_[OBJECT_STATS_COUNT][kNumberOfBuckets]; 115 size_t size_histogram_[OBJECT_STATS_COUNT][kNumberOfBuckets];
113 size_t over_allocated_histogram_[OBJECT_STATS_COUNT][kNumberOfBuckets]; 116 size_t over_allocated_histogram_[OBJECT_STATS_COUNT][kNumberOfBuckets];
114 117
115 std::set<FixedArrayBase*> visited_fixed_array_sub_types_; 118 std::set<FixedArrayBase*> visited_fixed_array_sub_types_;
116 }; 119 };
117 120
118 class ObjectStatsCollector { 121 class ObjectStatsCollector {
119 public: 122 public:
120 static void CollectStatistics(ObjectStats* stats, HeapObject* obj); 123 ObjectStatsCollector(Heap* heap, ObjectStats* stats)
124 : heap_(heap), stats_(stats) {}
125
126 void CollectGlobalStatistics();
127 void CollectStatistics(HeapObject* obj);
121 128
122 private: 129 private:
123 static void RecordMapDetails(ObjectStats* stats, Heap* heap, HeapObject* obj); 130 void RecordCodeDetails(Code* code);
124 static void RecordCodeDetails(ObjectStats* stats, Heap* heap, 131 void RecordFixedArrayDetails(FixedArray* array);
125 HeapObject* obj); 132 void RecordJSCollectionDetails(JSObject* obj);
126 static void RecordSharedFunctionInfoDetails(ObjectStats* stats, Heap* heap, 133 void RecordJSFunctionDetails(JSFunction* function);
127 HeapObject* obj); 134 void RecordJSObjectDetails(JSObject* object);
128 static void RecordFixedArrayDetails(ObjectStats* stats, Heap* heap, 135 void RecordJSWeakCollectionDetails(JSWeakCollection* obj);
129 HeapObject* obj); 136 void RecordMapDetails(Map* map);
137 void RecordScriptDetails(Script* obj);
138 void RecordSharedFunctionInfoDetails(SharedFunctionInfo* sfi);
130 139
131 static void RecordJSObjectDetails(ObjectStats* stats, Heap* heap, 140 bool RecordFixedArrayHelper(HeapObject* parent, FixedArray* array,
132 JSObject* object); 141 int subtype, size_t overhead);
133 static void RecordJSWeakCollectionDetails(ObjectStats* stats, Heap* heap, 142 void RecursivelyRecordFixedArrayHelper(HeapObject* parent, FixedArray* array,
134 JSWeakCollection* obj); 143 int subtype);
135 static void RecordScriptDetails(ObjectStats* stats, Heap* heap, Script* obj); 144 template <class HashTable>
136 145 void RecordHashTableHelper(HeapObject* parent, HashTable* array, int subtype);
137 static void RecordFixedArrayHelper(ObjectStats* stats, Heap* heap, 146 Heap* heap_;
138 HeapObject* parent, FixedArray* array, 147 ObjectStats* stats_;
139 int subtype, size_t overhead);
140 }; 148 };
141 149
142 } // namespace internal 150 } // namespace internal
143 } // namespace v8 151 } // namespace v8
144 152
145 #endif // V8_HEAP_OBJECT_STATS_H_ 153 #endif // V8_HEAP_OBJECT_STATS_H_
OLDNEW
« no previous file with comments | « src/heap/mark-compact.cc ('k') | src/heap/object-stats.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698