OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 #ifndef V8_TYPE_FEEDBACK_VECTOR_INL_H_ | 5 #ifndef V8_TYPE_FEEDBACK_VECTOR_INL_H_ |
6 #define V8_TYPE_FEEDBACK_VECTOR_INL_H_ | 6 #define V8_TYPE_FEEDBACK_VECTOR_INL_H_ |
7 | 7 |
8 #include "src/globals.h" | 8 #include "src/globals.h" |
9 #include "src/type-feedback-vector.h" | 9 #include "src/type-feedback-vector.h" |
10 | 10 |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 default: | 152 default: |
153 return CompareOperationHint::kAny; | 153 return CompareOperationHint::kAny; |
154 } | 154 } |
155 UNREACHABLE(); | 155 UNREACHABLE(); |
156 return CompareOperationHint::kNone; | 156 return CompareOperationHint::kNone; |
157 } | 157 } |
158 | 158 |
159 void TypeFeedbackVector::ComputeCounts(int* with_type_info, int* generic, | 159 void TypeFeedbackVector::ComputeCounts(int* with_type_info, int* generic, |
160 int* vector_ic_count, | 160 int* vector_ic_count, |
161 bool code_is_interpreted) { | 161 bool code_is_interpreted) { |
162 Object* uninitialized_sentinel = | |
163 TypeFeedbackVector::RawUninitializedSentinel(GetIsolate()); | |
164 Object* megamorphic_sentinel = | 162 Object* megamorphic_sentinel = |
165 *TypeFeedbackVector::MegamorphicSentinel(GetIsolate()); | 163 *TypeFeedbackVector::MegamorphicSentinel(GetIsolate()); |
166 int with = 0; | 164 int with = 0; |
167 int gen = 0; | 165 int gen = 0; |
168 int total = 0; | 166 int total = 0; |
169 TypeFeedbackMetadataIterator iter(metadata()); | 167 TypeFeedbackMetadataIterator iter(metadata()); |
170 while (iter.HasNext()) { | 168 while (iter.HasNext()) { |
171 FeedbackVectorSlot slot = iter.Next(); | 169 FeedbackVectorSlot slot = iter.Next(); |
172 FeedbackVectorSlotKind kind = iter.kind(); | 170 FeedbackVectorSlotKind kind = iter.kind(); |
173 | 171 |
174 Object* obj = Get(slot); | 172 Object* const obj = Get(slot); |
175 if (kind == FeedbackVectorSlotKind::GENERAL) { | 173 switch (kind) { |
176 continue; | 174 case FeedbackVectorSlotKind::CALL_IC: |
177 } | 175 case FeedbackVectorSlotKind::LOAD_IC: |
178 total++; | 176 case FeedbackVectorSlotKind::LOAD_GLOBAL_IC: |
179 | 177 case FeedbackVectorSlotKind::KEYED_LOAD_IC: |
180 if (obj != uninitialized_sentinel) { | 178 case FeedbackVectorSlotKind::STORE_IC: |
181 if (kind == FeedbackVectorSlotKind::INTERPRETER_COMPARE_IC || | 179 case FeedbackVectorSlotKind::KEYED_STORE_IC: { |
182 kind == FeedbackVectorSlotKind::INTERPRETER_BINARYOP_IC) { | 180 if (obj->IsWeakCell() || obj->IsFixedArray() || obj->IsString()) { |
183 // If we are not running interpreted code, we need to ignore | 181 with++; |
184 // the special ic slots for binaryop/compare used by the | 182 } else if (obj == megamorphic_sentinel) { |
185 // interpreter. | 183 gen++; |
186 // TODO(mvstanton): Remove code_is_interpreted when full code | 184 } |
187 // is retired from service. | 185 total++; |
188 if (!code_is_interpreted) continue; | 186 break; |
189 | 187 } |
190 DCHECK(obj->IsSmi()); | 188 case FeedbackVectorSlotKind::INTERPRETER_BINARYOP_IC: |
191 int op_feedback = static_cast<int>(Smi::cast(obj)->value()); | 189 case FeedbackVectorSlotKind::INTERPRETER_COMPARE_IC: { |
192 if (kind == FeedbackVectorSlotKind::INTERPRETER_COMPARE_IC) { | 190 // If we are not running interpreted code, we need to ignore the special |
193 CompareOperationHint hint = | 191 // IC slots for binaryop/compare used by the interpreter. |
194 CompareOperationHintFromFeedback(op_feedback); | 192 // TODO(mvstanton): Remove code_is_interpreted when full code is retired |
195 if (hint == CompareOperationHint::kAny) { | 193 // from service. |
196 gen++; | 194 if (code_is_interpreted) { |
197 } else if (hint != CompareOperationHint::kNone) { | 195 int const feedback = Smi::cast(obj)->value(); |
198 with++; | 196 if (kind == FeedbackVectorSlotKind::INTERPRETER_COMPARE_IC) { |
| 197 CompareOperationHint hint = |
| 198 CompareOperationHintFromFeedback(feedback); |
| 199 if (hint == CompareOperationHint::kAny) { |
| 200 gen++; |
| 201 } else if (hint != CompareOperationHint::kNone) { |
| 202 with++; |
| 203 } |
| 204 } else { |
| 205 DCHECK_EQ(FeedbackVectorSlotKind::INTERPRETER_BINARYOP_IC, kind); |
| 206 BinaryOperationHint hint = |
| 207 BinaryOperationHintFromFeedback(feedback); |
| 208 if (hint == BinaryOperationHint::kAny) { |
| 209 gen++; |
| 210 } else if (hint != BinaryOperationHint::kNone) { |
| 211 with++; |
| 212 } |
199 } | 213 } |
200 } else { | 214 total++; |
201 DCHECK(kind == FeedbackVectorSlotKind::INTERPRETER_BINARYOP_IC); | |
202 BinaryOperationHint hint = | |
203 BinaryOperationHintFromFeedback(op_feedback); | |
204 if (hint == BinaryOperationHint::kAny) { | |
205 gen++; | |
206 } else if (hint != BinaryOperationHint::kNone) { | |
207 with++; | |
208 } | |
209 } | 215 } |
210 } else if (obj->IsWeakCell() || obj->IsFixedArray() || obj->IsString()) { | 216 break; |
211 with++; | |
212 } else if (obj == megamorphic_sentinel) { | |
213 gen++; | |
214 } | 217 } |
| 218 case FeedbackVectorSlotKind::GENERAL: |
| 219 break; |
| 220 case FeedbackVectorSlotKind::INVALID: |
| 221 case FeedbackVectorSlotKind::KINDS_NUMBER: |
| 222 UNREACHABLE(); |
| 223 break; |
215 } | 224 } |
216 } | 225 } |
217 | 226 |
218 *with_type_info = with; | 227 *with_type_info = with; |
219 *generic = gen; | 228 *generic = gen; |
220 *vector_ic_count = total; | 229 *vector_ic_count = total; |
221 } | 230 } |
222 | 231 |
223 Handle<Symbol> TypeFeedbackVector::UninitializedSentinel(Isolate* isolate) { | 232 Handle<Symbol> TypeFeedbackVector::UninitializedSentinel(Isolate* isolate) { |
224 return isolate->factory()->uninitialized_symbol(); | 233 return isolate->factory()->uninitialized_symbol(); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 int index = vector()->GetIndex(slot()) + 1; | 288 int index = vector()->GetIndex(slot()) + 1; |
280 vector()->set(index, feedback_extra, mode); | 289 vector()->set(index, feedback_extra, mode); |
281 } | 290 } |
282 | 291 |
283 | 292 |
284 Isolate* FeedbackNexus::GetIsolate() const { return vector()->GetIsolate(); } | 293 Isolate* FeedbackNexus::GetIsolate() const { return vector()->GetIsolate(); } |
285 } // namespace internal | 294 } // namespace internal |
286 } // namespace v8 | 295 } // namespace v8 |
287 | 296 |
288 #endif // V8_TYPE_FEEDBACK_VECTOR_INL_H_ | 297 #endif // V8_TYPE_FEEDBACK_VECTOR_INL_H_ |
OLD | NEW |