| 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 #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 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 parent, FixedArray::cast(array->get(i)), subtype); | 265 parent, FixedArray::cast(array->get(i)), subtype); |
| 266 } | 266 } |
| 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 * kPointerSize; |
| 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 - | 278 HashTable::kElementsStartIndex * kPointerSize - |
| 279 FixedArray::kHeaderSize; | 279 FixedArray::kHeaderSize; |
| 280 RecordFixedArrayHelper(parent, array, subtype, overhead); | 280 RecordFixedArrayHelper(parent, array, subtype, overhead); |
| 281 } | 281 } |
| 282 | 282 |
| 283 void ObjectStatsCollector::RecordJSObjectDetails(JSObject* object) { | 283 void ObjectStatsCollector::RecordJSObjectDetails(JSObject* object) { |
| 284 size_t overhead = 0; | 284 size_t overhead = 0; |
| 285 FixedArrayBase* elements = object->elements(); | 285 FixedArrayBase* elements = object->elements(); |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 } | 404 } |
| 405 | 405 |
| 406 void ObjectStatsCollector::RecordSharedFunctionInfoDetails( | 406 void ObjectStatsCollector::RecordSharedFunctionInfoDetails( |
| 407 SharedFunctionInfo* sfi) { | 407 SharedFunctionInfo* sfi) { |
| 408 FixedArray* scope_info = sfi->scope_info(); | 408 FixedArray* scope_info = sfi->scope_info(); |
| 409 RecordFixedArrayHelper(sfi, scope_info, SCOPE_INFO_SUB_TYPE, 0); | 409 RecordFixedArrayHelper(sfi, scope_info, SCOPE_INFO_SUB_TYPE, 0); |
| 410 TypeFeedbackMetadata* feedback_metadata = sfi->feedback_metadata(); | 410 TypeFeedbackMetadata* feedback_metadata = sfi->feedback_metadata(); |
| 411 if (!feedback_metadata->is_empty()) { | 411 if (!feedback_metadata->is_empty()) { |
| 412 RecordFixedArrayHelper(sfi, feedback_metadata, | 412 RecordFixedArrayHelper(sfi, feedback_metadata, |
| 413 TYPE_FEEDBACK_METADATA_SUB_TYPE, 0); | 413 TYPE_FEEDBACK_METADATA_SUB_TYPE, 0); |
| 414 UnseededNumberDictionary* names = UnseededNumberDictionary::cast( | 414 Object* names = |
| 415 feedback_metadata->get(TypeFeedbackMetadata::kNamesTableIndex)); | 415 feedback_metadata->get(TypeFeedbackMetadata::kNamesTableIndex); |
| 416 RecordHashTableHelper(sfi, names, TYPE_FEEDBACK_METADATA_SUB_TYPE); | 416 if (!names->IsSmi()) { |
| 417 UnseededNumberDictionary* names = UnseededNumberDictionary::cast( |
| 418 feedback_metadata->get(TypeFeedbackMetadata::kNamesTableIndex)); |
| 419 RecordHashTableHelper(sfi, names, TYPE_FEEDBACK_METADATA_SUB_TYPE); |
| 420 } |
| 417 } | 421 } |
| 418 | 422 |
| 419 if (!sfi->OptimizedCodeMapIsCleared()) { | 423 if (!sfi->OptimizedCodeMapIsCleared()) { |
| 420 FixedArray* optimized_code_map = sfi->optimized_code_map(); | 424 FixedArray* optimized_code_map = sfi->optimized_code_map(); |
| 421 RecordFixedArrayHelper(sfi, optimized_code_map, OPTIMIZED_CODE_MAP_SUB_TYPE, | 425 RecordFixedArrayHelper(sfi, optimized_code_map, OPTIMIZED_CODE_MAP_SUB_TYPE, |
| 422 0); | 426 0); |
| 423 // Optimized code map should be small, so skip accounting. | 427 // Optimized code map should be small, so skip accounting. |
| 424 int len = optimized_code_map->length(); | 428 int len = optimized_code_map->length(); |
| 425 for (int i = SharedFunctionInfo::kEntriesStart; i < len; | 429 for (int i = SharedFunctionInfo::kEntriesStart; i < len; |
| 426 i += SharedFunctionInfo::kEntryLength) { | 430 i += SharedFunctionInfo::kEntryLength) { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 } | 465 } |
| 462 if (array->IsNativeContext()) { | 466 if (array->IsNativeContext()) { |
| 463 Context* native_ctx = Context::cast(array); | 467 Context* native_ctx = Context::cast(array); |
| 464 RecordHashTableHelper(array, native_ctx->template_instantiations_cache(), | 468 RecordHashTableHelper(array, native_ctx->template_instantiations_cache(), |
| 465 TEMPLATE_INSTANTIATIONS_CACHE_SUB_TYPE); | 469 TEMPLATE_INSTANTIATIONS_CACHE_SUB_TYPE); |
| 466 } | 470 } |
| 467 } | 471 } |
| 468 | 472 |
| 469 } // namespace internal | 473 } // namespace internal |
| 470 } // namespace v8 | 474 } // namespace v8 |
| OLD | NEW |