| 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 #ifndef V8_FEEDBACK_VECTOR_H_ | 5 #ifndef V8_FEEDBACK_VECTOR_H_ |
| 6 #define V8_FEEDBACK_VECTOR_H_ | 6 #define V8_FEEDBACK_VECTOR_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "src/base/logging.h" | 10 #include "src/base/logging.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 kLoadKeyed, | 29 kLoadKeyed, |
| 30 kStoreNamedSloppy, | 30 kStoreNamedSloppy, |
| 31 kStoreNamedStrict, | 31 kStoreNamedStrict, |
| 32 kStoreOwnNamed, | 32 kStoreOwnNamed, |
| 33 kStoreKeyedSloppy, | 33 kStoreKeyedSloppy, |
| 34 kStoreKeyedStrict, | 34 kStoreKeyedStrict, |
| 35 kBinaryOp, | 35 kBinaryOp, |
| 36 kCompareOp, | 36 kCompareOp, |
| 37 kToBoolean, | 37 kToBoolean, |
| 38 kStoreDataPropertyInLiteral, | 38 kStoreDataPropertyInLiteral, |
| 39 kTypeProfile, | |
| 40 kCreateClosure, | 39 kCreateClosure, |
| 41 kLiteral, | 40 kLiteral, |
| 42 // This is a general purpose slot that occupies one feedback vector element. | 41 // This is a general purpose slot that occupies one feedback vector element. |
| 43 kGeneral, | 42 kGeneral, |
| 44 | 43 |
| 45 kKindsNumber // Last value indicating number of kinds. | 44 kKindsNumber // Last value indicating number of kinds. |
| 46 }; | 45 }; |
| 47 | 46 |
| 48 inline bool IsCallICKind(FeedbackSlotKind kind) { | 47 inline bool IsCallICKind(FeedbackSlotKind kind) { |
| 49 return kind == FeedbackSlotKind::kCall; | 48 return kind == FeedbackSlotKind::kCall; |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 } | 143 } |
| 145 | 144 |
| 146 FeedbackSlot AddGeneralSlot() { return AddSlot(FeedbackSlotKind::kGeneral); } | 145 FeedbackSlot AddGeneralSlot() { return AddSlot(FeedbackSlotKind::kGeneral); } |
| 147 | 146 |
| 148 FeedbackSlot AddLiteralSlot() { return AddSlot(FeedbackSlotKind::kLiteral); } | 147 FeedbackSlot AddLiteralSlot() { return AddSlot(FeedbackSlotKind::kLiteral); } |
| 149 | 148 |
| 150 FeedbackSlot AddStoreDataPropertyInLiteralICSlot() { | 149 FeedbackSlot AddStoreDataPropertyInLiteralICSlot() { |
| 151 return AddSlot(FeedbackSlotKind::kStoreDataPropertyInLiteral); | 150 return AddSlot(FeedbackSlotKind::kStoreDataPropertyInLiteral); |
| 152 } | 151 } |
| 153 | 152 |
| 154 FeedbackSlot AddTypeProfileSlot() { | |
| 155 DCHECK(FLAG_type_profile); | |
| 156 return AddSlot(FeedbackSlotKind::kTypeProfile); | |
| 157 } | |
| 158 | |
| 159 #ifdef OBJECT_PRINT | 153 #ifdef OBJECT_PRINT |
| 160 // For gdb debugging. | 154 // For gdb debugging. |
| 161 void Print(); | 155 void Print(); |
| 162 #endif // OBJECT_PRINT | 156 #endif // OBJECT_PRINT |
| 163 | 157 |
| 164 DECLARE_PRINTER(FeedbackVectorSpec) | 158 DECLARE_PRINTER(FeedbackVectorSpec) |
| 165 | 159 |
| 166 private: | 160 private: |
| 167 inline FeedbackSlot AddSlot(FeedbackSlotKind kind); | 161 inline FeedbackSlot AddSlot(FeedbackSlotKind kind); |
| 168 | 162 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 | 243 |
| 250 #ifdef OBJECT_PRINT | 244 #ifdef OBJECT_PRINT |
| 251 // For gdb debugging. | 245 // For gdb debugging. |
| 252 void Print(); | 246 void Print(); |
| 253 #endif // OBJECT_PRINT | 247 #endif // OBJECT_PRINT |
| 254 | 248 |
| 255 DECLARE_PRINTER(FeedbackMetadata) | 249 DECLARE_PRINTER(FeedbackMetadata) |
| 256 | 250 |
| 257 static const char* Kind2String(FeedbackSlotKind kind); | 251 static const char* Kind2String(FeedbackSlotKind kind); |
| 258 | 252 |
| 259 bool HasTypeProfileSlot(); | |
| 260 | |
| 261 private: | 253 private: |
| 262 static const int kFeedbackSlotKindBits = 5; | 254 static const int kFeedbackSlotKindBits = 5; |
| 263 STATIC_ASSERT(static_cast<int>(FeedbackSlotKind::kKindsNumber) < | 255 STATIC_ASSERT(static_cast<int>(FeedbackSlotKind::kKindsNumber) < |
| 264 (1 << kFeedbackSlotKindBits)); | 256 (1 << kFeedbackSlotKindBits)); |
| 265 | 257 |
| 266 void SetKind(FeedbackSlot slot, FeedbackSlotKind kind); | 258 void SetKind(FeedbackSlot slot, FeedbackSlotKind kind); |
| 267 | 259 |
| 268 typedef BitSetComputer<FeedbackSlotKind, kFeedbackSlotKindBits, kSmiValueSize, | 260 typedef BitSetComputer<FeedbackSlotKind, kFeedbackSlotKindBits, kSmiValueSize, |
| 269 uint32_t> | 261 uint32_t> |
| 270 VectorICComputer; | 262 VectorICComputer; |
| (...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 743 : FeedbackNexus(vector, slot) { | 735 : FeedbackNexus(vector, slot) { |
| 744 DCHECK_EQ(FeedbackSlotKind::kStoreDataPropertyInLiteral, | 736 DCHECK_EQ(FeedbackSlotKind::kStoreDataPropertyInLiteral, |
| 745 vector->GetKind(slot)); | 737 vector->GetKind(slot)); |
| 746 } | 738 } |
| 747 | 739 |
| 748 void ConfigureMonomorphic(Handle<Name> name, Handle<Map> receiver_map); | 740 void ConfigureMonomorphic(Handle<Name> name, Handle<Map> receiver_map); |
| 749 | 741 |
| 750 InlineCacheState StateFromFeedback() const override; | 742 InlineCacheState StateFromFeedback() const override; |
| 751 }; | 743 }; |
| 752 | 744 |
| 753 // For each assignment, store the type of the value in the collection of types | |
| 754 // in the feedback vector. | |
| 755 class CollectTypeProfileNexus : public FeedbackNexus { | |
| 756 public: | |
| 757 CollectTypeProfileNexus(Handle<FeedbackVector> vector, FeedbackSlot slot) | |
| 758 : FeedbackNexus(vector, slot) { | |
| 759 DCHECK_EQ(FeedbackSlotKind::kTypeProfile, vector->GetKind(slot)); | |
| 760 } | |
| 761 CollectTypeProfileNexus(FeedbackVector* vector, FeedbackSlot slot) | |
| 762 : FeedbackNexus(vector, slot) { | |
| 763 DCHECK_EQ(FeedbackSlotKind::kTypeProfile, vector->GetKind(slot)); | |
| 764 } | |
| 765 | |
| 766 // Add a type to the list of types. | |
| 767 void Collect(Handle<Name> type); | |
| 768 | |
| 769 // Dump the types to stdout. | |
| 770 // TODO(franzih): pass this information to the debugger protocol instead of | |
| 771 // stdout. | |
| 772 void Print() const; | |
| 773 | |
| 774 InlineCacheState StateFromFeedback() const override; | |
| 775 }; | |
| 776 | |
| 777 inline BinaryOperationHint BinaryOperationHintFromFeedback(int type_feedback); | 745 inline BinaryOperationHint BinaryOperationHintFromFeedback(int type_feedback); |
| 778 inline CompareOperationHint CompareOperationHintFromFeedback(int type_feedback); | 746 inline CompareOperationHint CompareOperationHintFromFeedback(int type_feedback); |
| 779 | 747 |
| 780 } // namespace internal | 748 } // namespace internal |
| 781 } // namespace v8 | 749 } // namespace v8 |
| 782 | 750 |
| 783 #endif // V8_FEEDBACK_VECTOR_H_ | 751 #endif // V8_FEEDBACK_VECTOR_H_ |
| OLD | NEW |