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

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

Issue 2325083003: Record call counts also for megamorphic calls. (Closed)
Patch Set: Address test failure. 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/x64/code-stubs-x64.cc » ('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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 int entry_size = TypeFeedbackMetadata::GetSlotSize(kind); 248 int entry_size = TypeFeedbackMetadata::GetSlotSize(kind);
249 249
250 Object* value; 250 Object* value;
251 if (kind == FeedbackVectorSlotKind::LOAD_GLOBAL_IC) { 251 if (kind == FeedbackVectorSlotKind::LOAD_GLOBAL_IC) {
252 value = *factory->empty_weak_cell(); 252 value = *factory->empty_weak_cell();
253 } else { 253 } else {
254 value = *uninitialized_sentinel; 254 value = *uninitialized_sentinel;
255 } 255 }
256 array->set(index, value, SKIP_WRITE_BARRIER); 256 array->set(index, value, SKIP_WRITE_BARRIER);
257 for (int j = 1; j < entry_size; j++) { 257 for (int j = 1; j < entry_size; j++) {
258 array->set(index + j, *uninitialized_sentinel, SKIP_WRITE_BARRIER); 258 array->set(index + j, kind == FeedbackVectorSlotKind::CALL_IC
Benedikt Meurer 2016/09/13 10:34:58 Nit: Hoist the value selection out of the loop.
259 ? Smi::FromInt(0)
260 : *uninitialized_sentinel,
261 SKIP_WRITE_BARRIER);
259 } 262 }
260 i += entry_size; 263 i += entry_size;
261 } 264 }
262 return Handle<TypeFeedbackVector>::cast(array); 265 return Handle<TypeFeedbackVector>::cast(array);
263 } 266 }
264 267
265 268
266 // static 269 // static
267 int TypeFeedbackVector::GetIndexFromSpec(const FeedbackVectorSpec* spec, 270 int TypeFeedbackVector::GetIndexFromSpec(const FeedbackVectorSpec* spec,
268 FeedbackVectorSlot slot) { 271 FeedbackVectorSlot slot) {
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 return MONOMORPHIC; 616 return MONOMORPHIC;
614 } 617 }
615 618
616 CHECK(feedback == *TypeFeedbackVector::UninitializedSentinel(isolate)); 619 CHECK(feedback == *TypeFeedbackVector::UninitializedSentinel(isolate));
617 return UNINITIALIZED; 620 return UNINITIALIZED;
618 } 621 }
619 622
620 623
621 int CallICNexus::ExtractCallCount() { 624 int CallICNexus::ExtractCallCount() {
622 Object* call_count = GetFeedbackExtra(); 625 Object* call_count = GetFeedbackExtra();
623 if (call_count->IsSmi()) { 626 CHECK(call_count->IsSmi());
624 int value = Smi::cast(call_count)->value(); 627 int value = Smi::cast(call_count)->value();
625 return value; 628 return value;
626 }
627 return -1;
628 } 629 }
629 630
630
631 void CallICNexus::Clear(Code* host) { CallIC::Clear(GetIsolate(), host, this); } 631 void CallICNexus::Clear(Code* host) { CallIC::Clear(GetIsolate(), host, this); }
632 632
633 void CallICNexus::ConfigureUninitialized() {
634 Isolate* isolate = GetIsolate();
635 SetFeedback(*TypeFeedbackVector::UninitializedSentinel(isolate),
636 SKIP_WRITE_BARRIER);
637 SetFeedbackExtra(Smi::FromInt(0), SKIP_WRITE_BARRIER);
638 }
633 639
634 void CallICNexus::ConfigureMonomorphicArray() { 640 void CallICNexus::ConfigureMonomorphicArray() {
635 Object* feedback = GetFeedback(); 641 Object* feedback = GetFeedback();
636 if (!feedback->IsAllocationSite()) { 642 if (!feedback->IsAllocationSite()) {
637 Handle<AllocationSite> new_site = 643 Handle<AllocationSite> new_site =
638 GetIsolate()->factory()->NewAllocationSite(); 644 GetIsolate()->factory()->NewAllocationSite();
639 SetFeedback(*new_site); 645 SetFeedback(*new_site);
640 } 646 }
641 SetFeedbackExtra(Smi::FromInt(1), SKIP_WRITE_BARRIER); 647 SetFeedbackExtra(Smi::FromInt(1), SKIP_WRITE_BARRIER);
642 } 648 }
643 649
644 650
645 void CallICNexus::ConfigureMonomorphic(Handle<JSFunction> function) { 651 void CallICNexus::ConfigureMonomorphic(Handle<JSFunction> function) {
646 Handle<WeakCell> new_cell = GetIsolate()->factory()->NewWeakCell(function); 652 Handle<WeakCell> new_cell = GetIsolate()->factory()->NewWeakCell(function);
647 SetFeedback(*new_cell); 653 SetFeedback(*new_cell);
648 SetFeedbackExtra(Smi::FromInt(1), SKIP_WRITE_BARRIER); 654 SetFeedbackExtra(Smi::FromInt(1), SKIP_WRITE_BARRIER);
649 } 655 }
650 656
651 657
652 void CallICNexus::ConfigureMegamorphic() { 658 void CallICNexus::ConfigureMegamorphic() {
653 FeedbackNexus::ConfigureMegamorphic(); 659 SetFeedback(*TypeFeedbackVector::MegamorphicSentinel(GetIsolate()),
660 SKIP_WRITE_BARRIER);
661 Smi* count = Smi::cast(GetFeedbackExtra());
662 int new_count = count->value() + 1;
663 SetFeedbackExtra(Smi::FromInt(new_count), SKIP_WRITE_BARRIER);
654 } 664 }
655 665
656
657 void CallICNexus::ConfigureMegamorphic(int call_count) { 666 void CallICNexus::ConfigureMegamorphic(int call_count) {
658 SetFeedback(*TypeFeedbackVector::MegamorphicSentinel(GetIsolate()), 667 SetFeedback(*TypeFeedbackVector::MegamorphicSentinel(GetIsolate()),
659 SKIP_WRITE_BARRIER); 668 SKIP_WRITE_BARRIER);
660 SetFeedbackExtra(Smi::FromInt(call_count), SKIP_WRITE_BARRIER); 669 SetFeedbackExtra(Smi::FromInt(call_count), SKIP_WRITE_BARRIER);
661 } 670 }
662 671
663 void LoadICNexus::ConfigureMonomorphic(Handle<Map> receiver_map, 672 void LoadICNexus::ConfigureMonomorphic(Handle<Map> receiver_map,
664 Handle<Object> handler) { 673 Handle<Object> handler) {
665 Handle<WeakCell> cell = Map::WeakCellForMap(receiver_map); 674 Handle<WeakCell> cell = Map::WeakCellForMap(receiver_map);
666 SetFeedback(*cell); 675 SetFeedback(*cell);
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
1015 1024
1016 IcCheckType KeyedStoreICNexus::GetKeyType() const { 1025 IcCheckType KeyedStoreICNexus::GetKeyType() const {
1017 Object* feedback = GetFeedback(); 1026 Object* feedback = GetFeedback();
1018 if (feedback == *TypeFeedbackVector::MegamorphicSentinel(GetIsolate())) { 1027 if (feedback == *TypeFeedbackVector::MegamorphicSentinel(GetIsolate())) {
1019 return static_cast<IcCheckType>(Smi::cast(GetFeedbackExtra())->value()); 1028 return static_cast<IcCheckType>(Smi::cast(GetFeedbackExtra())->value());
1020 } 1029 }
1021 return IsPropertyNameFeedback(feedback) ? PROPERTY : ELEMENT; 1030 return IsPropertyNameFeedback(feedback) ? PROPERTY : ELEMENT;
1022 } 1031 }
1023 } // namespace internal 1032 } // namespace internal
1024 } // namespace v8 1033 } // namespace v8
OLDNEW
« no previous file with comments | « src/type-feedback-vector.h ('k') | src/x64/code-stubs-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698