OLD | NEW |
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 18 matching lines...) Expand all Loading... |
29 void TypeFeedbackVector::SetKind(FeedbackVectorICSlot slot, | 29 void TypeFeedbackVector::SetKind(FeedbackVectorICSlot slot, |
30 FeedbackVectorSlotKind kind) { | 30 FeedbackVectorSlotKind kind) { |
31 int index = VectorICComputer::index(kReservedIndexCount, slot.ToInt()); | 31 int index = VectorICComputer::index(kReservedIndexCount, slot.ToInt()); |
32 int data = Smi::cast(get(index))->value(); | 32 int data = Smi::cast(get(index))->value(); |
33 int new_data = VectorICComputer::encode(data, slot.ToInt(), kind); | 33 int new_data = VectorICComputer::encode(data, slot.ToInt(), kind); |
34 set(index, Smi::FromInt(new_data)); | 34 set(index, Smi::FromInt(new_data)); |
35 } | 35 } |
36 | 36 |
37 | 37 |
38 template Handle<TypeFeedbackVector> TypeFeedbackVector::Allocate( | 38 template Handle<TypeFeedbackVector> TypeFeedbackVector::Allocate( |
| 39 Isolate* isolate, const StaticFeedbackVectorSpec* spec); |
| 40 template Handle<TypeFeedbackVector> TypeFeedbackVector::Allocate( |
39 Isolate* isolate, const FeedbackVectorSpec* spec); | 41 Isolate* isolate, const FeedbackVectorSpec* spec); |
40 template Handle<TypeFeedbackVector> TypeFeedbackVector::Allocate( | |
41 Isolate* isolate, const ZoneFeedbackVectorSpec* spec); | |
42 | 42 |
43 | 43 |
44 // static | 44 // static |
45 template <typename Spec> | 45 template <typename Spec> |
46 Handle<TypeFeedbackVector> TypeFeedbackVector::Allocate(Isolate* isolate, | 46 Handle<TypeFeedbackVector> TypeFeedbackVector::Allocate(Isolate* isolate, |
47 const Spec* spec) { | 47 const Spec* spec) { |
48 const int slot_count = spec->slots(); | 48 const int slot_count = spec->slots(); |
49 const int ic_slot_count = spec->ic_slots(); | 49 const int ic_slot_count = spec->ic_slots(); |
50 const int index_count = VectorICComputer::word_count(ic_slot_count); | 50 const int index_count = VectorICComputer::word_count(ic_slot_count); |
51 const int length = slot_count + (ic_slot_count * elements_per_ic_slot()) + | 51 const int length = slot_count + (ic_slot_count * elements_per_ic_slot()) + |
(...skipping 25 matching lines...) Expand all Loading... |
77 } | 77 } |
78 | 78 |
79 Handle<TypeFeedbackVector> vector = Handle<TypeFeedbackVector>::cast(array); | 79 Handle<TypeFeedbackVector> vector = Handle<TypeFeedbackVector>::cast(array); |
80 for (int i = 0; i < ic_slot_count; i++) { | 80 for (int i = 0; i < ic_slot_count; i++) { |
81 vector->SetKind(FeedbackVectorICSlot(i), spec->GetKind(i)); | 81 vector->SetKind(FeedbackVectorICSlot(i), spec->GetKind(i)); |
82 } | 82 } |
83 return vector; | 83 return vector; |
84 } | 84 } |
85 | 85 |
86 | 86 |
87 template int TypeFeedbackVector::GetIndexFromSpec(const ZoneFeedbackVectorSpec*, | 87 template int TypeFeedbackVector::GetIndexFromSpec(const FeedbackVectorSpec*, |
88 FeedbackVectorICSlot); | 88 FeedbackVectorICSlot); |
89 template int TypeFeedbackVector::GetIndexFromSpec(const ZoneFeedbackVectorSpec*, | 89 template int TypeFeedbackVector::GetIndexFromSpec(const FeedbackVectorSpec*, |
90 FeedbackVectorSlot); | 90 FeedbackVectorSlot); |
91 | 91 |
92 | 92 |
93 // static | 93 // static |
94 template <typename Spec> | 94 template <typename Spec> |
95 int TypeFeedbackVector::GetIndexFromSpec(const Spec* spec, | 95 int TypeFeedbackVector::GetIndexFromSpec(const Spec* spec, |
96 FeedbackVectorSlot slot) { | 96 FeedbackVectorSlot slot) { |
97 const int ic_slot_count = spec->ic_slots(); | 97 const int ic_slot_count = spec->ic_slots(); |
98 const int index_count = VectorICComputer::word_count(ic_slot_count); | 98 const int index_count = VectorICComputer::word_count(ic_slot_count); |
99 return kReservedIndexCount + index_count + slot.ToInt(); | 99 return kReservedIndexCount + index_count + slot.ToInt(); |
(...skipping 16 matching lines...) Expand all Loading... |
116 int TypeFeedbackVector::PushAppliedArgumentsIndex() { | 116 int TypeFeedbackVector::PushAppliedArgumentsIndex() { |
117 const int index_count = VectorICComputer::word_count(1); | 117 const int index_count = VectorICComputer::word_count(1); |
118 return kReservedIndexCount + index_count; | 118 return kReservedIndexCount + index_count; |
119 } | 119 } |
120 | 120 |
121 | 121 |
122 // static | 122 // static |
123 Handle<TypeFeedbackVector> TypeFeedbackVector::CreatePushAppliedArgumentsVector( | 123 Handle<TypeFeedbackVector> TypeFeedbackVector::CreatePushAppliedArgumentsVector( |
124 Isolate* isolate) { | 124 Isolate* isolate) { |
125 FeedbackVectorSlotKind kinds[] = {FeedbackVectorSlotKind::KEYED_LOAD_IC}; | 125 FeedbackVectorSlotKind kinds[] = {FeedbackVectorSlotKind::KEYED_LOAD_IC}; |
126 FeedbackVectorSpec spec(0, 1, kinds); | 126 StaticFeedbackVectorSpec spec(0, 1, kinds); |
127 Handle<TypeFeedbackVector> feedback_vector = | 127 Handle<TypeFeedbackVector> feedback_vector = |
128 isolate->factory()->NewTypeFeedbackVector(&spec); | 128 isolate->factory()->NewTypeFeedbackVector(&spec); |
129 DCHECK(PushAppliedArgumentsIndex() == | 129 DCHECK(PushAppliedArgumentsIndex() == |
130 feedback_vector->GetIndex(FeedbackVectorICSlot(0))); | 130 feedback_vector->GetIndex(FeedbackVectorICSlot(0))); |
131 return feedback_vector; | 131 return feedback_vector; |
132 } | 132 } |
133 | 133 |
134 | 134 |
135 // static | 135 // static |
136 Handle<TypeFeedbackVector> TypeFeedbackVector::Copy( | 136 Handle<TypeFeedbackVector> TypeFeedbackVector::Copy( |
137 Isolate* isolate, Handle<TypeFeedbackVector> vector) { | 137 Isolate* isolate, Handle<TypeFeedbackVector> vector) { |
138 Handle<TypeFeedbackVector> result; | 138 Handle<TypeFeedbackVector> result; |
139 result = Handle<TypeFeedbackVector>::cast( | 139 result = Handle<TypeFeedbackVector>::cast( |
140 isolate->factory()->CopyFixedArray(Handle<FixedArray>::cast(vector))); | 140 isolate->factory()->CopyFixedArray(Handle<FixedArray>::cast(vector))); |
141 return result; | 141 return result; |
142 } | 142 } |
143 | 143 |
144 | 144 |
145 bool TypeFeedbackVector::SpecDiffersFrom( | 145 bool TypeFeedbackVector::SpecDiffersFrom( |
146 const ZoneFeedbackVectorSpec* other_spec) const { | 146 const FeedbackVectorSpec* other_spec) const { |
147 if (other_spec->slots() != Slots() || other_spec->ic_slots() != ICSlots()) { | 147 if (other_spec->slots() != Slots() || other_spec->ic_slots() != ICSlots()) { |
148 return true; | 148 return true; |
149 } | 149 } |
150 | 150 |
151 int ic_slots = ICSlots(); | 151 int ic_slots = ICSlots(); |
152 for (int i = 0; i < ic_slots; i++) { | 152 for (int i = 0; i < ic_slots; i++) { |
153 if (GetKind(FeedbackVectorICSlot(i)) != other_spec->GetKind(i)) { | 153 if (GetKind(FeedbackVectorICSlot(i)) != other_spec->GetKind(i)) { |
154 return true; | 154 return true; |
155 } | 155 } |
156 } | 156 } |
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
831 return mode; | 831 return mode; |
832 } | 832 } |
833 | 833 |
834 | 834 |
835 IcCheckType KeyedStoreICNexus::GetKeyType() const { | 835 IcCheckType KeyedStoreICNexus::GetKeyType() const { |
836 // The structure of the vector slots tells us the type. | 836 // The structure of the vector slots tells us the type. |
837 return GetFeedback()->IsName() ? PROPERTY : ELEMENT; | 837 return GetFeedback()->IsName() ? PROPERTY : ELEMENT; |
838 } | 838 } |
839 } // namespace internal | 839 } // namespace internal |
840 } // namespace v8 | 840 } // namespace v8 |
OLD | NEW |