| 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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 | 44 |
| 45 | 45 |
| 46 // static | 46 // static |
| 47 TypeFeedbackVector* TypeFeedbackVector::cast(Object* obj) { | 47 TypeFeedbackVector* TypeFeedbackVector::cast(Object* obj) { |
| 48 DCHECK(obj->IsTypeFeedbackVector()); | 48 DCHECK(obj->IsTypeFeedbackVector()); |
| 49 return reinterpret_cast<TypeFeedbackVector*>(obj); | 49 return reinterpret_cast<TypeFeedbackVector*>(obj); |
| 50 } | 50 } |
| 51 | 51 |
| 52 | 52 |
| 53 int TypeFeedbackMetadata::GetSlotSize(FeedbackVectorSlotKind kind) { | 53 int TypeFeedbackMetadata::GetSlotSize(FeedbackVectorSlotKind kind) { |
| 54 DCHECK_NE(FeedbackVectorSlotKind::INVALID, kind); | 54 switch (kind) { |
| 55 DCHECK_NE(FeedbackVectorSlotKind::KINDS_NUMBER, kind); | 55 case FeedbackVectorSlotKind::GENERAL: |
| 56 if (kind == FeedbackVectorSlotKind::GENERAL || | 56 case FeedbackVectorSlotKind::INTERPRETER_COMPARE_IC: |
| 57 kind == FeedbackVectorSlotKind::INTERPRETER_BINARYOP_IC || | 57 case FeedbackVectorSlotKind::INTERPRETER_BINARYOP_IC: |
| 58 kind == FeedbackVectorSlotKind::INTERPRETER_COMPARE_IC || | 58 case FeedbackVectorSlotKind::LITERAL: |
| 59 kind == FeedbackVectorSlotKind::LITERAL || | 59 case FeedbackVectorSlotKind::CREATE_CLOSURE: |
| 60 kind == FeedbackVectorSlotKind::CREATE_CLOSURE) { | 60 return 1; |
| 61 return 1; | 61 |
| 62 case FeedbackVectorSlotKind::CALL_IC: |
| 63 case FeedbackVectorSlotKind::LOAD_IC: |
| 64 case FeedbackVectorSlotKind::LOAD_GLOBAL_IC: |
| 65 case FeedbackVectorSlotKind::KEYED_LOAD_IC: |
| 66 case FeedbackVectorSlotKind::STORE_IC: |
| 67 case FeedbackVectorSlotKind::KEYED_STORE_IC: |
| 68 case FeedbackVectorSlotKind::STORE_DATA_PROPERTY_IN_LITERAL_IC: |
| 69 return 2; |
| 70 |
| 71 case FeedbackVectorSlotKind::INVALID: |
| 72 case FeedbackVectorSlotKind::KINDS_NUMBER: |
| 73 UNREACHABLE(); |
| 74 break; |
| 62 } | 75 } |
| 63 | 76 return 1; |
| 64 return 2; | |
| 65 } | 77 } |
| 66 | 78 |
| 67 bool TypeFeedbackVector::is_empty() const { | 79 bool TypeFeedbackVector::is_empty() const { |
| 68 return length() == kReservedIndexCount; | 80 return length() == kReservedIndexCount; |
| 69 } | 81 } |
| 70 | 82 |
| 71 int TypeFeedbackVector::slot_count() const { | 83 int TypeFeedbackVector::slot_count() const { |
| 72 return length() - kReservedIndexCount; | 84 return length() - kReservedIndexCount; |
| 73 } | 85 } |
| 74 | 86 |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 case FeedbackVectorSlotKind::STORE_DATA_PROPERTY_IN_LITERAL_IC: { | 179 case FeedbackVectorSlotKind::STORE_DATA_PROPERTY_IN_LITERAL_IC: { |
| 168 if (obj->IsWeakCell() || obj->IsFixedArray() || obj->IsString()) { | 180 if (obj->IsWeakCell() || obj->IsFixedArray() || obj->IsString()) { |
| 169 with++; | 181 with++; |
| 170 } else if (obj == megamorphic_sentinel) { | 182 } else if (obj == megamorphic_sentinel) { |
| 171 gen++; | 183 gen++; |
| 172 } | 184 } |
| 173 total++; | 185 total++; |
| 174 break; | 186 break; |
| 175 } | 187 } |
| 176 case FeedbackVectorSlotKind::INTERPRETER_BINARYOP_IC: | 188 case FeedbackVectorSlotKind::INTERPRETER_BINARYOP_IC: |
| 189 // If we are not running interpreted code, we need to ignore the special |
| 190 // IC slots for binaryop/compare used by the interpreter. |
| 191 // TODO(mvstanton): Remove code_is_interpreted when full code is retired |
| 192 // from service. |
| 193 if (code_is_interpreted) { |
| 194 int const feedback = Smi::cast(obj)->value(); |
| 195 BinaryOperationHint hint = BinaryOperationHintFromFeedback(feedback); |
| 196 if (hint == BinaryOperationHint::kAny) { |
| 197 gen++; |
| 198 } else if (hint != BinaryOperationHint::kNone) { |
| 199 with++; |
| 200 } |
| 201 total++; |
| 202 } |
| 203 break; |
| 177 case FeedbackVectorSlotKind::INTERPRETER_COMPARE_IC: { | 204 case FeedbackVectorSlotKind::INTERPRETER_COMPARE_IC: { |
| 178 // If we are not running interpreted code, we need to ignore the special | 205 // If we are not running interpreted code, we need to ignore the special |
| 179 // IC slots for binaryop/compare used by the interpreter. | 206 // IC slots for binaryop/compare used by the interpreter. |
| 180 // TODO(mvstanton): Remove code_is_interpreted when full code is retired | 207 // TODO(mvstanton): Remove code_is_interpreted when full code is retired |
| 181 // from service. | 208 // from service. |
| 182 if (code_is_interpreted) { | 209 if (code_is_interpreted) { |
| 183 int const feedback = Smi::cast(obj)->value(); | 210 int const feedback = Smi::cast(obj)->value(); |
| 184 if (kind == FeedbackVectorSlotKind::INTERPRETER_COMPARE_IC) { | 211 CompareOperationHint hint = |
| 185 CompareOperationHint hint = | 212 CompareOperationHintFromFeedback(feedback); |
| 186 CompareOperationHintFromFeedback(feedback); | 213 if (hint == CompareOperationHint::kAny) { |
| 187 if (hint == CompareOperationHint::kAny) { | 214 gen++; |
| 188 gen++; | 215 } else if (hint != CompareOperationHint::kNone) { |
| 189 } else if (hint != CompareOperationHint::kNone) { | 216 with++; |
| 190 with++; | |
| 191 } | |
| 192 } else { | |
| 193 DCHECK_EQ(FeedbackVectorSlotKind::INTERPRETER_BINARYOP_IC, kind); | |
| 194 BinaryOperationHint hint = | |
| 195 BinaryOperationHintFromFeedback(feedback); | |
| 196 if (hint == BinaryOperationHint::kAny) { | |
| 197 gen++; | |
| 198 } else if (hint != BinaryOperationHint::kNone) { | |
| 199 with++; | |
| 200 } | |
| 201 } | 217 } |
| 202 total++; | 218 total++; |
| 203 } | 219 } |
| 204 break; | 220 break; |
| 205 } | 221 } |
| 206 case FeedbackVectorSlotKind::CREATE_CLOSURE: | 222 case FeedbackVectorSlotKind::CREATE_CLOSURE: |
| 207 case FeedbackVectorSlotKind::GENERAL: | 223 case FeedbackVectorSlotKind::GENERAL: |
| 208 case FeedbackVectorSlotKind::LITERAL: | 224 case FeedbackVectorSlotKind::LITERAL: |
| 209 break; | 225 break; |
| 210 case FeedbackVectorSlotKind::INVALID: | 226 case FeedbackVectorSlotKind::INVALID: |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 int index = vector()->GetIndex(slot()) + 1; | 294 int index = vector()->GetIndex(slot()) + 1; |
| 279 vector()->set(index, feedback_extra, mode); | 295 vector()->set(index, feedback_extra, mode); |
| 280 } | 296 } |
| 281 | 297 |
| 282 | 298 |
| 283 Isolate* FeedbackNexus::GetIsolate() const { return vector()->GetIsolate(); } | 299 Isolate* FeedbackNexus::GetIsolate() const { return vector()->GetIsolate(); } |
| 284 } // namespace internal | 300 } // namespace internal |
| 285 } // namespace v8 | 301 } // namespace v8 |
| 286 | 302 |
| 287 #endif // V8_TYPE_FEEDBACK_VECTOR_INL_H_ | 303 #endif // V8_TYPE_FEEDBACK_VECTOR_INL_H_ |
| OLD | NEW |