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/compilation-cache.h" | 7 #include "src/compilation-cache.h" |
8 #include "src/counters.h" | 8 #include "src/counters.h" |
9 #include "src/heap/heap-inl.h" | 9 #include "src/heap/heap-inl.h" |
10 #include "src/isolate.h" | 10 #include "src/isolate.h" |
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
544 if (!feedback_metadata->is_empty()) { | 544 if (!feedback_metadata->is_empty()) { |
545 RecordFixedArrayHelper(sfi, feedback_metadata, | 545 RecordFixedArrayHelper(sfi, feedback_metadata, |
546 TYPE_FEEDBACK_METADATA_SUB_TYPE, 0); | 546 TYPE_FEEDBACK_METADATA_SUB_TYPE, 0); |
547 } | 547 } |
548 | 548 |
549 if (!sfi->OptimizedCodeMapIsCleared()) { | 549 if (!sfi->OptimizedCodeMapIsCleared()) { |
550 FixedArray* optimized_code_map = sfi->optimized_code_map(); | 550 FixedArray* optimized_code_map = sfi->optimized_code_map(); |
551 RecordFixedArrayHelper(sfi, optimized_code_map, OPTIMIZED_CODE_MAP_SUB_TYPE, | 551 RecordFixedArrayHelper(sfi, optimized_code_map, OPTIMIZED_CODE_MAP_SUB_TYPE, |
552 0); | 552 0); |
553 // Optimized code map should be small, so skip accounting. | 553 // Optimized code map should be small, so skip accounting. |
554 int len = optimized_code_map->length(); | |
555 for (int i = SharedFunctionInfo::kEntriesStart; i < len; | |
556 i += SharedFunctionInfo::kEntryLength) { | |
557 Object* slot = optimized_code_map->get( | |
558 i + SharedFunctionInfo::kFeedbackVectorOffset); | |
559 TypeFeedbackVector* vector = nullptr; | |
560 if (slot->IsWeakCell()) { | |
561 WeakCell* cell = WeakCell::cast(slot); | |
562 if (!cell->cleared()) { | |
563 vector = TypeFeedbackVector::cast(cell->value()); | |
564 } | |
565 } else { | |
566 vector = TypeFeedbackVector::cast(slot); | |
567 } | |
568 if (vector != nullptr) { | |
569 RecordFixedArrayHelper(sfi, vector, TYPE_FEEDBACK_VECTOR_SUB_TYPE, 0); | |
570 } | |
571 } | |
572 } | 554 } |
573 } | 555 } |
574 | 556 |
575 void ObjectStatsCollector::RecordJSFunctionDetails(JSFunction* function) { | 557 void ObjectStatsCollector::RecordJSFunctionDetails(JSFunction* function) { |
576 TypeFeedbackVector* feedback_vector = function->feedback_vector(); | 558 if (function->feedback_vector_cell()->value()->IsTypeFeedbackVector()) { |
577 RecordFixedArrayHelper(function, feedback_vector, | 559 TypeFeedbackVector* feedback_vector = function->feedback_vector(); |
578 TYPE_FEEDBACK_VECTOR_SUB_TYPE, 0); | 560 RecordFixedArrayHelper(function, feedback_vector, |
| 561 TYPE_FEEDBACK_VECTOR_SUB_TYPE, 0); |
| 562 } |
579 } | 563 } |
580 | 564 |
581 void ObjectStatsCollector::RecordFixedArrayDetails(FixedArray* array) { | 565 void ObjectStatsCollector::RecordFixedArrayDetails(FixedArray* array) { |
582 if (array->IsContext()) { | 566 if (array->IsContext()) { |
583 RecordFixedArrayHelper(nullptr, array, CONTEXT_SUB_TYPE, 0); | 567 RecordFixedArrayHelper(nullptr, array, CONTEXT_SUB_TYPE, 0); |
584 } | 568 } |
585 if (IsCowArray(heap_, array) && CanRecordFixedArray(heap_, array)) { | 569 if (IsCowArray(heap_, array) && CanRecordFixedArray(heap_, array)) { |
586 stats_->RecordFixedArraySubTypeStats(array, COPY_ON_WRITE_SUB_TYPE, | 570 stats_->RecordFixedArraySubTypeStats(array, COPY_ON_WRITE_SUB_TYPE, |
587 array->Size(), 0); | 571 array->Size(), 0); |
588 } | 572 } |
589 if (array->IsNativeContext()) { | 573 if (array->IsNativeContext()) { |
590 Context* native_ctx = Context::cast(array); | 574 Context* native_ctx = Context::cast(array); |
591 RecordHashTableHelper(array, | 575 RecordHashTableHelper(array, |
592 native_ctx->slow_template_instantiations_cache(), | 576 native_ctx->slow_template_instantiations_cache(), |
593 SLOW_TEMPLATE_INSTANTIATIONS_CACHE_SUB_TYPE); | 577 SLOW_TEMPLATE_INSTANTIATIONS_CACHE_SUB_TYPE); |
594 FixedArray* fast_cache = native_ctx->fast_template_instantiations_cache(); | 578 FixedArray* fast_cache = native_ctx->fast_template_instantiations_cache(); |
595 stats_->RecordFixedArraySubTypeStats( | 579 stats_->RecordFixedArraySubTypeStats( |
596 fast_cache, FAST_TEMPLATE_INSTANTIATIONS_CACHE_SUB_TYPE, | 580 fast_cache, FAST_TEMPLATE_INSTANTIATIONS_CACHE_SUB_TYPE, |
597 fast_cache->Size(), 0); | 581 fast_cache->Size(), 0); |
598 } | 582 } |
599 } | 583 } |
600 | 584 |
601 } // namespace internal | 585 } // namespace internal |
602 } // namespace v8 | 586 } // namespace v8 |
OLD | NEW |