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 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 CompilationCache* compilation_cache = heap_->isolate()->compilation_cache(); | 323 CompilationCache* compilation_cache = heap_->isolate()->compilation_cache(); |
324 CompilationCacheTableVisitor v(this); | 324 CompilationCacheTableVisitor v(this); |
325 compilation_cache->Iterate(&v); | 325 compilation_cache->Iterate(&v); |
326 } | 326 } |
327 | 327 |
328 static bool CanRecordFixedArray(Heap* heap, FixedArrayBase* array) { | 328 static bool CanRecordFixedArray(Heap* heap, FixedArrayBase* array) { |
329 return array->map()->instance_type() == FIXED_ARRAY_TYPE && | 329 return array->map()->instance_type() == FIXED_ARRAY_TYPE && |
330 array->map() != heap->fixed_double_array_map() && | 330 array->map() != heap->fixed_double_array_map() && |
331 array != heap->empty_fixed_array() && | 331 array != heap->empty_fixed_array() && |
332 array != heap->empty_byte_array() && | 332 array != heap->empty_byte_array() && |
333 array != heap->empty_literals_array() && | 333 array != heap->empty_type_feedback_vector() && |
334 array != heap->empty_sloppy_arguments_elements() && | 334 array != heap->empty_sloppy_arguments_elements() && |
335 array != heap->empty_slow_element_dictionary() && | 335 array != heap->empty_slow_element_dictionary() && |
336 array != heap->empty_descriptor_array() && | 336 array != heap->empty_descriptor_array() && |
337 array != heap->empty_properties_dictionary(); | 337 array != heap->empty_properties_dictionary(); |
338 } | 338 } |
339 | 339 |
340 static bool IsCowArray(Heap* heap, FixedArrayBase* array) { | 340 static bool IsCowArray(Heap* heap, FixedArrayBase* array) { |
341 return array->map() == heap->fixed_cow_array_map(); | 341 return array->map() == heap->fixed_cow_array_map(); |
342 } | 342 } |
343 | 343 |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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(); | 554 int len = optimized_code_map->length(); |
555 for (int i = SharedFunctionInfo::kEntriesStart; i < len; | 555 for (int i = SharedFunctionInfo::kEntriesStart; i < len; |
556 i += SharedFunctionInfo::kEntryLength) { | 556 i += SharedFunctionInfo::kEntryLength) { |
557 Object* slot = | 557 Object* slot = optimized_code_map->get( |
558 optimized_code_map->get(i + SharedFunctionInfo::kLiteralsOffset); | 558 i + SharedFunctionInfo::kFeedbackVectorOffset); |
559 LiteralsArray* literals = nullptr; | 559 TypeFeedbackVector* vector = nullptr; |
560 if (slot->IsWeakCell()) { | 560 if (slot->IsWeakCell()) { |
561 WeakCell* cell = WeakCell::cast(slot); | 561 WeakCell* cell = WeakCell::cast(slot); |
562 if (!cell->cleared()) { | 562 if (!cell->cleared()) { |
563 literals = LiteralsArray::cast(cell->value()); | 563 vector = TypeFeedbackVector::cast(cell->value()); |
564 } | 564 } |
565 } else { | 565 } else { |
566 literals = LiteralsArray::cast(slot); | 566 vector = TypeFeedbackVector::cast(slot); |
567 } | 567 } |
568 if (literals != nullptr) { | 568 if (vector != nullptr) { |
569 RecordFixedArrayHelper(sfi, literals, LITERALS_ARRAY_SUB_TYPE, 0); | 569 RecordFixedArrayHelper(sfi, vector, TYPE_FEEDBACK_VECTOR_SUB_TYPE, 0); |
570 RecordFixedArrayHelper(sfi, literals->feedback_vector(), | |
571 TYPE_FEEDBACK_VECTOR_SUB_TYPE, 0); | |
572 } | 570 } |
573 } | 571 } |
574 } | 572 } |
575 } | 573 } |
576 | 574 |
577 void ObjectStatsCollector::RecordJSFunctionDetails(JSFunction* function) { | 575 void ObjectStatsCollector::RecordJSFunctionDetails(JSFunction* function) { |
578 LiteralsArray* literals = function->literals(); | 576 TypeFeedbackVector* feedback_vector = function->feedback_vector(); |
579 RecordFixedArrayHelper(function, literals, LITERALS_ARRAY_SUB_TYPE, 0); | 577 RecordFixedArrayHelper(function, feedback_vector, |
580 RecordFixedArrayHelper(function, literals->feedback_vector(), | |
581 TYPE_FEEDBACK_VECTOR_SUB_TYPE, 0); | 578 TYPE_FEEDBACK_VECTOR_SUB_TYPE, 0); |
582 } | 579 } |
583 | 580 |
584 void ObjectStatsCollector::RecordFixedArrayDetails(FixedArray* array) { | 581 void ObjectStatsCollector::RecordFixedArrayDetails(FixedArray* array) { |
585 if (array->IsContext()) { | 582 if (array->IsContext()) { |
586 RecordFixedArrayHelper(nullptr, array, CONTEXT_SUB_TYPE, 0); | 583 RecordFixedArrayHelper(nullptr, array, CONTEXT_SUB_TYPE, 0); |
587 } | 584 } |
588 if (IsCowArray(heap_, array) && CanRecordFixedArray(heap_, array)) { | 585 if (IsCowArray(heap_, array) && CanRecordFixedArray(heap_, array)) { |
589 stats_->RecordFixedArraySubTypeStats(array, COPY_ON_WRITE_SUB_TYPE, | 586 stats_->RecordFixedArraySubTypeStats(array, COPY_ON_WRITE_SUB_TYPE, |
590 array->Size(), 0); | 587 array->Size(), 0); |
591 } | 588 } |
592 if (array->IsNativeContext()) { | 589 if (array->IsNativeContext()) { |
593 Context* native_ctx = Context::cast(array); | 590 Context* native_ctx = Context::cast(array); |
594 RecordHashTableHelper(array, | 591 RecordHashTableHelper(array, |
595 native_ctx->slow_template_instantiations_cache(), | 592 native_ctx->slow_template_instantiations_cache(), |
596 SLOW_TEMPLATE_INSTANTIATIONS_CACHE_SUB_TYPE); | 593 SLOW_TEMPLATE_INSTANTIATIONS_CACHE_SUB_TYPE); |
597 FixedArray* fast_cache = native_ctx->fast_template_instantiations_cache(); | 594 FixedArray* fast_cache = native_ctx->fast_template_instantiations_cache(); |
598 stats_->RecordFixedArraySubTypeStats( | 595 stats_->RecordFixedArraySubTypeStats( |
599 fast_cache, FAST_TEMPLATE_INSTANTIATIONS_CACHE_SUB_TYPE, | 596 fast_cache, FAST_TEMPLATE_INSTANTIATIONS_CACHE_SUB_TYPE, |
600 fast_cache->Size(), 0); | 597 fast_cache->Size(), 0); |
601 } | 598 } |
602 } | 599 } |
603 | 600 |
604 } // namespace internal | 601 } // namespace internal |
605 } // namespace v8 | 602 } // namespace v8 |
OLD | NEW |