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

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

Issue 2176393003: [heap] ObjectStats: Account for headers when computing HashTable overhead (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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 | « no previous file | 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/macro-assembler.h" 10 #include "src/macro-assembler.h"
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 } 267 }
268 } 268 }
269 } 269 }
270 270
271 template <class HashTable> 271 template <class HashTable>
272 void ObjectStatsCollector::RecordHashTableHelper(HeapObject* parent, 272 void ObjectStatsCollector::RecordHashTableHelper(HeapObject* parent,
273 HashTable* array, 273 HashTable* array,
274 int subtype) { 274 int subtype) {
275 int used = array->NumberOfElements() * HashTable::kEntrySize; 275 int used = array->NumberOfElements() * HashTable::kEntrySize;
276 CHECK_GE(array->Size(), used); 276 CHECK_GE(array->Size(), used);
277 size_t overhead = array->Size() - used; 277 size_t overhead = array->Size() - used -
278 HashTable::kElementsStartIndex * kPointerSize -
279 FixedArray::kHeaderSize;
278 RecordFixedArrayHelper(parent, array, subtype, overhead); 280 RecordFixedArrayHelper(parent, array, subtype, overhead);
279 } 281 }
280 282
281 void ObjectStatsCollector::RecordJSObjectDetails(JSObject* object) { 283 void ObjectStatsCollector::RecordJSObjectDetails(JSObject* object) {
282 size_t overhead = 0; 284 size_t overhead = 0;
283 FixedArrayBase* elements = object->elements(); 285 FixedArrayBase* elements = object->elements();
284 if (CanRecordFixedArray(heap_, elements) && !IsCowArray(heap_, elements)) { 286 if (CanRecordFixedArray(heap_, elements) && !IsCowArray(heap_, elements)) {
285 if (elements->IsDictionary() && SameLiveness(object, elements)) { 287 if (elements->IsDictionary() && SameLiveness(object, elements)) {
286 SeededNumberDictionary* dict = SeededNumberDictionary::cast(elements); 288 SeededNumberDictionary* dict = SeededNumberDictionary::cast(elements);
287 RecordHashTableHelper(object, dict, DICTIONARY_ELEMENTS_SUB_TYPE); 289 RecordHashTableHelper(object, dict, DICTIONARY_ELEMENTS_SUB_TYPE);
288 } else { 290 } else {
289 if (IsFastHoleyElementsKind(object->GetElementsKind())) { 291 if (IsFastHoleyElementsKind(object->GetElementsKind())) {
290 int used = object->GetFastElementsUsage() * kPointerSize; 292 int used = object->GetFastElementsUsage() * kPointerSize;
291 if (object->GetElementsKind() == FAST_HOLEY_DOUBLE_ELEMENTS) used *= 2; 293 if (object->GetElementsKind() == FAST_HOLEY_DOUBLE_ELEMENTS) used *= 2;
292 CHECK_GE(elements->Size(), used); 294 CHECK_GE(elements->Size(), used);
293 overhead = elements->Size() - used; 295 overhead = elements->Size() - used - FixedArray::kHeaderSize;
294 } 296 }
295 stats_->RecordFixedArraySubTypeStats(elements, FAST_ELEMENTS_SUB_TYPE, 297 stats_->RecordFixedArraySubTypeStats(elements, FAST_ELEMENTS_SUB_TYPE,
296 elements->Size(), overhead); 298 elements->Size(), overhead);
297 } 299 }
298 } 300 }
299 301
300 overhead = 0; 302 overhead = 0;
301 FixedArrayBase* properties = object->properties(); 303 FixedArrayBase* properties = object->properties();
302 if (CanRecordFixedArray(heap_, properties) && 304 if (CanRecordFixedArray(heap_, properties) &&
303 SameLiveness(object, properties) && !IsCowArray(heap_, properties)) { 305 SameLiveness(object, properties) && !IsCowArray(heap_, properties)) {
(...skipping 11 matching lines...) Expand all
315 JSWeakCollection* obj) { 317 JSWeakCollection* obj) {
316 if (obj->table()->IsHashTable()) { 318 if (obj->table()->IsHashTable()) {
317 ObjectHashTable* table = ObjectHashTable::cast(obj->table()); 319 ObjectHashTable* table = ObjectHashTable::cast(obj->table());
318 int used = table->NumberOfElements() * ObjectHashTable::kEntrySize; 320 int used = table->NumberOfElements() * ObjectHashTable::kEntrySize;
319 size_t overhead = table->Size() - used; 321 size_t overhead = table->Size() - used;
320 RecordFixedArrayHelper(obj, table, JS_WEAK_COLLECTION_SUB_TYPE, overhead); 322 RecordFixedArrayHelper(obj, table, JS_WEAK_COLLECTION_SUB_TYPE, overhead);
321 } 323 }
322 } 324 }
323 325
324 void ObjectStatsCollector::RecordJSCollectionDetails(JSObject* obj) { 326 void ObjectStatsCollector::RecordJSCollectionDetails(JSObject* obj) {
327 // The JS versions use a different HashTable implementation that cannot use
328 // the regular helper. Since overall impact is usually small just record
329 // without overhead.
325 if (obj->IsJSMap()) { 330 if (obj->IsJSMap()) {
326 RecordHashTableHelper(nullptr, 331 RecordFixedArrayHelper(nullptr, FixedArray::cast(JSMap::cast(obj)->table()),
327 OrderedHashMap::cast(JSMap::cast(obj)->table()), 332 JS_COLLECTION_SUB_TYPE, 0);
328 JS_COLLECTION_SUB_TYPE);
329 } 333 }
330 if (obj->IsJSSet()) { 334 if (obj->IsJSSet()) {
331 RecordHashTableHelper(nullptr, 335 RecordFixedArrayHelper(nullptr, FixedArray::cast(JSSet::cast(obj)->table()),
332 OrderedHashSet::cast(JSSet::cast(obj)->table()), 336 JS_COLLECTION_SUB_TYPE, 0);
333 JS_COLLECTION_SUB_TYPE);
334 } 337 }
335 } 338 }
336 339
337 void ObjectStatsCollector::RecordScriptDetails(Script* obj) { 340 void ObjectStatsCollector::RecordScriptDetails(Script* obj) {
338 Object* infos = WeakFixedArray::cast(obj->shared_function_infos()); 341 Object* infos = WeakFixedArray::cast(obj->shared_function_infos());
339 if (infos->IsWeakFixedArray()) 342 if (infos->IsWeakFixedArray())
340 RecordFixedArrayHelper(obj, WeakFixedArray::cast(infos), 343 RecordFixedArrayHelper(obj, WeakFixedArray::cast(infos),
341 SHARED_FUNCTION_INFOS_SUB_TYPE, 0); 344 SHARED_FUNCTION_INFOS_SUB_TYPE, 0);
342 } 345 }
343 346
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 } 461 }
459 if (array->IsNativeContext()) { 462 if (array->IsNativeContext()) {
460 Context* native_ctx = Context::cast(array); 463 Context* native_ctx = Context::cast(array);
461 RecordHashTableHelper(array, native_ctx->template_instantiations_cache(), 464 RecordHashTableHelper(array, native_ctx->template_instantiations_cache(),
462 TEMPLATE_INSTANTIATIONS_CACHE_SUB_TYPE); 465 TEMPLATE_INSTANTIATIONS_CACHE_SUB_TYPE);
463 } 466 }
464 } 467 }
465 468
466 } // namespace internal 469 } // namespace internal
467 } // namespace v8 470 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698