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

Side by Side Diff: src/type-feedback-vector.cc

Issue 2337123003: [turbofan] Collect invocation counts and compute relative call frequencies. (Closed)
Patch Set: Address feedback. Created 4 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/type-feedback-vector.h ('k') | src/type-feedback-vector-inl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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/type-feedback-vector.h" 5 #include "src/type-feedback-vector.h"
6 6
7 #include "src/code-stubs.h" 7 #include "src/code-stubs.h"
8 #include "src/ic/ic.h" 8 #include "src/ic/ic.h"
9 #include "src/ic/ic-state.h" 9 #include "src/ic/ic-state.h"
10 #include "src/objects.h" 10 #include "src/objects.h"
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 } 223 }
224 224
225 // static 225 // static
226 Handle<TypeFeedbackVector> TypeFeedbackVector::New( 226 Handle<TypeFeedbackVector> TypeFeedbackVector::New(
227 Isolate* isolate, Handle<TypeFeedbackMetadata> metadata) { 227 Isolate* isolate, Handle<TypeFeedbackMetadata> metadata) {
228 Factory* factory = isolate->factory(); 228 Factory* factory = isolate->factory();
229 229
230 const int slot_count = metadata->slot_count(); 230 const int slot_count = metadata->slot_count();
231 const int length = slot_count + kReservedIndexCount; 231 const int length = slot_count + kReservedIndexCount;
232 if (length == kReservedIndexCount) { 232 if (length == kReservedIndexCount) {
233 return Handle<TypeFeedbackVector>::cast(factory->empty_fixed_array()); 233 return Handle<TypeFeedbackVector>::cast(
234 factory->empty_type_feedback_vector());
234 } 235 }
235 236
236 Handle<FixedArray> array = factory->NewFixedArray(length, TENURED); 237 Handle<FixedArray> array = factory->NewFixedArray(length, TENURED);
237 array->set(kMetadataIndex, *metadata); 238 array->set(kMetadataIndex, *metadata);
239 array->set(kInvocationCountIndex, Smi::FromInt(0));
238 240
239 DisallowHeapAllocation no_gc; 241 DisallowHeapAllocation no_gc;
240 242
241 // Ensure we can skip the write barrier 243 // Ensure we can skip the write barrier
242 Handle<Object> uninitialized_sentinel = UninitializedSentinel(isolate); 244 Handle<Object> uninitialized_sentinel = UninitializedSentinel(isolate);
243 DCHECK_EQ(*factory->uninitialized_symbol(), *uninitialized_sentinel); 245 DCHECK_EQ(*factory->uninitialized_symbol(), *uninitialized_sentinel);
244 for (int i = 0; i < slot_count;) { 246 for (int i = 0; i < slot_count;) {
245 FeedbackVectorSlot slot(i); 247 FeedbackVectorSlot slot(i);
246 FeedbackVectorSlotKind kind = metadata->GetKind(slot); 248 FeedbackVectorSlotKind kind = metadata->GetKind(slot);
247 int index = TypeFeedbackVector::GetIndex(slot); 249 int index = TypeFeedbackVector::GetIndex(slot);
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
621 } 623 }
622 624
623 625
624 int CallICNexus::ExtractCallCount() { 626 int CallICNexus::ExtractCallCount() {
625 Object* call_count = GetFeedbackExtra(); 627 Object* call_count = GetFeedbackExtra();
626 CHECK(call_count->IsSmi()); 628 CHECK(call_count->IsSmi());
627 int value = Smi::cast(call_count)->value(); 629 int value = Smi::cast(call_count)->value();
628 return value; 630 return value;
629 } 631 }
630 632
633 float CallICNexus::ComputeCallFrequency() {
634 double const invocation_count = vector()->invocation_count();
635 double const call_count = ExtractCallCount();
636 return static_cast<float>(call_count / invocation_count);
637 }
638
631 void CallICNexus::Clear(Code* host) { CallIC::Clear(GetIsolate(), host, this); } 639 void CallICNexus::Clear(Code* host) { CallIC::Clear(GetIsolate(), host, this); }
632 640
633 void CallICNexus::ConfigureUninitialized() { 641 void CallICNexus::ConfigureUninitialized() {
634 Isolate* isolate = GetIsolate(); 642 Isolate* isolate = GetIsolate();
635 SetFeedback(*TypeFeedbackVector::UninitializedSentinel(isolate), 643 SetFeedback(*TypeFeedbackVector::UninitializedSentinel(isolate),
636 SKIP_WRITE_BARRIER); 644 SKIP_WRITE_BARRIER);
637 SetFeedbackExtra(Smi::FromInt(0), SKIP_WRITE_BARRIER); 645 SetFeedbackExtra(Smi::FromInt(0), SKIP_WRITE_BARRIER);
638 } 646 }
639 647
640 void CallICNexus::ConfigureMonomorphicArray() { 648 void CallICNexus::ConfigureMonomorphicArray() {
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
1024 1032
1025 IcCheckType KeyedStoreICNexus::GetKeyType() const { 1033 IcCheckType KeyedStoreICNexus::GetKeyType() const {
1026 Object* feedback = GetFeedback(); 1034 Object* feedback = GetFeedback();
1027 if (feedback == *TypeFeedbackVector::MegamorphicSentinel(GetIsolate())) { 1035 if (feedback == *TypeFeedbackVector::MegamorphicSentinel(GetIsolate())) {
1028 return static_cast<IcCheckType>(Smi::cast(GetFeedbackExtra())->value()); 1036 return static_cast<IcCheckType>(Smi::cast(GetFeedbackExtra())->value());
1029 } 1037 }
1030 return IsPropertyNameFeedback(feedback) ? PROPERTY : ELEMENT; 1038 return IsPropertyNameFeedback(feedback) ? PROPERTY : ELEMENT;
1031 } 1039 }
1032 } // namespace internal 1040 } // namespace internal
1033 } // namespace v8 1041 } // namespace v8
OLDNEW
« no previous file with comments | « src/type-feedback-vector.h ('k') | src/type-feedback-vector-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698