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

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

Issue 1310953008: [heap] Move ObjectStatsVisitor into the proper component. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@local_cleanup-heap-object-stats-1
Patch Set: Created 5 years, 3 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/object-stats.h ('k') | no next file » | 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 #include "src/heap/object-stats.h" 5 #include "src/heap/object-stats.h"
6 6
7 #include "src/counters.h" 7 #include "src/counters.h"
8 #include "src/heap/heap-inl.h" 8 #include "src/heap/heap-inl.h"
9 #include "src/isolate.h" 9 #include "src/isolate.h"
10 #include "src/utils.h" 10 #include "src/utils.h"
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 #undef ADJUST_LAST_TIME_OBJECT_COUNT 127 #undef ADJUST_LAST_TIME_OBJECT_COUNT
128 128
129 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); 129 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_));
130 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); 130 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_));
131 ClearObjectStats(); 131 ClearObjectStats();
132 } 132 }
133 133
134 134
135 Isolate* ObjectStats::isolate() { return heap()->isolate(); } 135 Isolate* ObjectStats::isolate() { return heap()->isolate(); }
136 136
137
138 void ObjectStatsVisitor::CountFixedArray(
139 FixedArrayBase* fixed_array, FixedArraySubInstanceType fast_type,
140 FixedArraySubInstanceType dictionary_type) {
141 Heap* heap = fixed_array->map()->GetHeap();
142 if (fixed_array->map() != heap->fixed_cow_array_map() &&
143 fixed_array->map() != heap->fixed_double_array_map() &&
144 fixed_array != heap->empty_fixed_array()) {
145 if (fixed_array->IsDictionary()) {
146 heap->object_stats_->RecordFixedArraySubTypeStats(dictionary_type,
147 fixed_array->Size());
148 } else {
149 heap->object_stats_->RecordFixedArraySubTypeStats(fast_type,
150 fixed_array->Size());
151 }
152 }
153 }
154
155
156 void ObjectStatsVisitor::VisitBase(VisitorId id, Map* map, HeapObject* obj) {
157 Heap* heap = map->GetHeap();
158 int object_size = obj->Size();
159 heap->object_stats_->RecordObjectStats(map->instance_type(), object_size);
160 table_.GetVisitorById(id)(map, obj);
161 if (obj->IsJSObject()) {
162 JSObject* object = JSObject::cast(obj);
163 CountFixedArray(object->elements(), DICTIONARY_ELEMENTS_SUB_TYPE,
164 FAST_ELEMENTS_SUB_TYPE);
165 CountFixedArray(object->properties(), DICTIONARY_PROPERTIES_SUB_TYPE,
166 FAST_PROPERTIES_SUB_TYPE);
167 }
168 }
169
170
171 template <ObjectStatsVisitor::VisitorId id>
172 void ObjectStatsVisitor::Visit(Map* map, HeapObject* obj) {
173 VisitBase(id, map, obj);
174 }
175
176
177 template <>
178 void ObjectStatsVisitor::Visit<ObjectStatsVisitor::kVisitMap>(Map* map,
179 HeapObject* obj) {
180 Heap* heap = map->GetHeap();
181 Map* map_obj = Map::cast(obj);
182 DCHECK(map->instance_type() == MAP_TYPE);
183 DescriptorArray* array = map_obj->instance_descriptors();
184 if (map_obj->owns_descriptors() && array != heap->empty_descriptor_array()) {
185 int fixed_array_size = array->Size();
186 heap->object_stats_->RecordFixedArraySubTypeStats(DESCRIPTOR_ARRAY_SUB_TYPE,
187 fixed_array_size);
188 }
189 if (TransitionArray::IsFullTransitionArray(map_obj->raw_transitions())) {
190 int fixed_array_size =
191 TransitionArray::cast(map_obj->raw_transitions())->Size();
192 heap->object_stats_->RecordFixedArraySubTypeStats(TRANSITION_ARRAY_SUB_TYPE,
193 fixed_array_size);
194 }
195 if (map_obj->has_code_cache()) {
196 CodeCache* cache = CodeCache::cast(map_obj->code_cache());
197 heap->object_stats_->RecordFixedArraySubTypeStats(
198 MAP_CODE_CACHE_SUB_TYPE, cache->default_cache()->Size());
199 if (!cache->normal_type_cache()->IsUndefined()) {
200 heap->object_stats_->RecordFixedArraySubTypeStats(
201 MAP_CODE_CACHE_SUB_TYPE,
202 FixedArray::cast(cache->normal_type_cache())->Size());
203 }
204 }
205 VisitBase(kVisitMap, map, obj);
206 }
207
208
209 template <>
210 void ObjectStatsVisitor::Visit<ObjectStatsVisitor::kVisitCode>(
211 Map* map, HeapObject* obj) {
212 Heap* heap = map->GetHeap();
213 int object_size = obj->Size();
214 DCHECK(map->instance_type() == CODE_TYPE);
215 Code* code_obj = Code::cast(obj);
216 heap->object_stats_->RecordCodeSubTypeStats(code_obj->kind(),
217 code_obj->GetAge(), object_size);
218 VisitBase(kVisitCode, map, obj);
219 }
220
221
222 template <>
223 void ObjectStatsVisitor::Visit<ObjectStatsVisitor::kVisitSharedFunctionInfo>(
224 Map* map, HeapObject* obj) {
225 Heap* heap = map->GetHeap();
226 SharedFunctionInfo* sfi = SharedFunctionInfo::cast(obj);
227 if (sfi->scope_info() != heap->empty_fixed_array()) {
228 heap->object_stats_->RecordFixedArraySubTypeStats(
229 SCOPE_INFO_SUB_TYPE, FixedArray::cast(sfi->scope_info())->Size());
230 }
231 VisitBase(kVisitSharedFunctionInfo, map, obj);
232 }
233
234
235 template <>
236 void ObjectStatsVisitor::Visit<ObjectStatsVisitor::kVisitFixedArray>(
237 Map* map, HeapObject* obj) {
238 Heap* heap = map->GetHeap();
239 FixedArray* fixed_array = FixedArray::cast(obj);
240 if (fixed_array == heap->string_table()) {
241 heap->object_stats_->RecordFixedArraySubTypeStats(STRING_TABLE_SUB_TYPE,
242 fixed_array->Size());
243 }
244 VisitBase(kVisitFixedArray, map, obj);
245 }
246
247
248 void ObjectStatsVisitor::Initialize(VisitorDispatchTable<Callback>* original) {
249 // Copy the original visitor table to make call-through possible. After we
250 // preserved a copy locally, we patch the original table to call us.
251 table_.CopyFrom(original);
252 #define COUNT_FUNCTION(id) original->Register(kVisit##id, Visit<kVisit##id>);
253 VISITOR_ID_LIST(COUNT_FUNCTION)
254 #undef COUNT_FUNCTION
255 }
256
137 } // namespace internal 257 } // namespace internal
138 } // namespace v8 258 } // namespace v8
OLDNEW
« no previous file with comments | « src/heap/object-stats.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698