| 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, |
| 39 kCreateClosure, | 40 kCreateClosure, |
| 40 kLiteral, | 41 kLiteral, |
| 41 // This is a general purpose slot that occupies one feedback vector element. | 42 // This is a general purpose slot that occupies one feedback vector element. |
| 42 kGeneral, | 43 kGeneral, |
| 43 | 44 |
| 44 kKindsNumber // Last value indicating number of kinds. | 45 kKindsNumber // Last value indicating number of kinds. |
| 45 }; | 46 }; |
| 46 | 47 |
| 47 inline bool IsCallICKind(FeedbackSlotKind kind) { | 48 inline bool IsCallICKind(FeedbackSlotKind kind) { |
| 48 return kind == FeedbackSlotKind::kCall; | 49 return kind == FeedbackSlotKind::kCall; |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 } | 144 } |
| 144 | 145 |
| 145 FeedbackSlot AddGeneralSlot() { return AddSlot(FeedbackSlotKind::kGeneral); } | 146 FeedbackSlot AddGeneralSlot() { return AddSlot(FeedbackSlotKind::kGeneral); } |
| 146 | 147 |
| 147 FeedbackSlot AddLiteralSlot() { return AddSlot(FeedbackSlotKind::kLiteral); } | 148 FeedbackSlot AddLiteralSlot() { return AddSlot(FeedbackSlotKind::kLiteral); } |
| 148 | 149 |
| 149 FeedbackSlot AddStoreDataPropertyInLiteralICSlot() { | 150 FeedbackSlot AddStoreDataPropertyInLiteralICSlot() { |
| 150 return AddSlot(FeedbackSlotKind::kStoreDataPropertyInLiteral); | 151 return AddSlot(FeedbackSlotKind::kStoreDataPropertyInLiteral); |
| 151 } | 152 } |
| 152 | 153 |
| 154 FeedbackSlot AddTypeProfileSlot() { |
| 155 DCHECK(FLAG_type_profile); |
| 156 return AddSlot(FeedbackSlotKind::kTypeProfile); |
| 157 } |
| 158 |
| 153 #ifdef OBJECT_PRINT | 159 #ifdef OBJECT_PRINT |
| 154 // For gdb debugging. | 160 // For gdb debugging. |
| 155 void Print(); | 161 void Print(); |
| 156 #endif // OBJECT_PRINT | 162 #endif // OBJECT_PRINT |
| 157 | 163 |
| 158 DECLARE_PRINTER(FeedbackVectorSpec) | 164 DECLARE_PRINTER(FeedbackVectorSpec) |
| 159 | 165 |
| 160 private: | 166 private: |
| 161 inline FeedbackSlot AddSlot(FeedbackSlotKind kind); | 167 inline FeedbackSlot AddSlot(FeedbackSlotKind kind); |
| 162 | 168 |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 | 249 |
| 244 #ifdef OBJECT_PRINT | 250 #ifdef OBJECT_PRINT |
| 245 // For gdb debugging. | 251 // For gdb debugging. |
| 246 void Print(); | 252 void Print(); |
| 247 #endif // OBJECT_PRINT | 253 #endif // OBJECT_PRINT |
| 248 | 254 |
| 249 DECLARE_PRINTER(FeedbackMetadata) | 255 DECLARE_PRINTER(FeedbackMetadata) |
| 250 | 256 |
| 251 static const char* Kind2String(FeedbackSlotKind kind); | 257 static const char* Kind2String(FeedbackSlotKind kind); |
| 252 | 258 |
| 259 bool HasTypeProfileSlot(); |
| 260 |
| 253 private: | 261 private: |
| 254 static const int kFeedbackSlotKindBits = 5; | 262 static const int kFeedbackSlotKindBits = 5; |
| 255 STATIC_ASSERT(static_cast<int>(FeedbackSlotKind::kKindsNumber) < | 263 STATIC_ASSERT(static_cast<int>(FeedbackSlotKind::kKindsNumber) < |
| 256 (1 << kFeedbackSlotKindBits)); | 264 (1 << kFeedbackSlotKindBits)); |
| 257 | 265 |
| 258 void SetKind(FeedbackSlot slot, FeedbackSlotKind kind); | 266 void SetKind(FeedbackSlot slot, FeedbackSlotKind kind); |
| 259 | 267 |
| 260 typedef BitSetComputer<FeedbackSlotKind, kFeedbackSlotKindBits, kSmiValueSize, | 268 typedef BitSetComputer<FeedbackSlotKind, kFeedbackSlotKindBits, kSmiValueSize, |
| 261 uint32_t> | 269 uint32_t> |
| 262 VectorICComputer; | 270 VectorICComputer; |
| (...skipping 472 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 735 : FeedbackNexus(vector, slot) { | 743 : FeedbackNexus(vector, slot) { |
| 736 DCHECK_EQ(FeedbackSlotKind::kStoreDataPropertyInLiteral, | 744 DCHECK_EQ(FeedbackSlotKind::kStoreDataPropertyInLiteral, |
| 737 vector->GetKind(slot)); | 745 vector->GetKind(slot)); |
| 738 } | 746 } |
| 739 | 747 |
| 740 void ConfigureMonomorphic(Handle<Name> name, Handle<Map> receiver_map); | 748 void ConfigureMonomorphic(Handle<Name> name, Handle<Map> receiver_map); |
| 741 | 749 |
| 742 InlineCacheState StateFromFeedback() const override; | 750 InlineCacheState StateFromFeedback() const override; |
| 743 }; | 751 }; |
| 744 | 752 |
| 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 |
| 745 inline BinaryOperationHint BinaryOperationHintFromFeedback(int type_feedback); | 777 inline BinaryOperationHint BinaryOperationHintFromFeedback(int type_feedback); |
| 746 inline CompareOperationHint CompareOperationHintFromFeedback(int type_feedback); | 778 inline CompareOperationHint CompareOperationHintFromFeedback(int type_feedback); |
| 747 | 779 |
| 748 } // namespace internal | 780 } // namespace internal |
| 749 } // namespace v8 | 781 } // namespace v8 |
| 750 | 782 |
| 751 #endif // V8_FEEDBACK_VECTOR_H_ | 783 #endif // V8_FEEDBACK_VECTOR_H_ |
| OLD | NEW |