| 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_TYPE_FEEDBACK_VECTOR_H_ | 5 #ifndef V8_TYPE_FEEDBACK_VECTOR_H_ |
| 6 #define V8_TYPE_FEEDBACK_VECTOR_H_ | 6 #define V8_TYPE_FEEDBACK_VECTOR_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "src/checks.h" | 10 #include "src/checks.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 STORE_IC, | 26 STORE_IC, |
| 27 KEYED_STORE_IC, | 27 KEYED_STORE_IC, |
| 28 | 28 |
| 29 KINDS_NUMBER // Last value indicating number of kinds. | 29 KINDS_NUMBER // Last value indicating number of kinds. |
| 30 }; | 30 }; |
| 31 | 31 |
| 32 | 32 |
| 33 std::ostream& operator<<(std::ostream& os, FeedbackVectorSlotKind kind); | 33 std::ostream& operator<<(std::ostream& os, FeedbackVectorSlotKind kind); |
| 34 | 34 |
| 35 | 35 |
| 36 class FeedbackVectorSpec { | 36 class StaticFeedbackVectorSpec { |
| 37 public: | 37 public: |
| 38 FeedbackVectorSpec() : slots_(0), ic_slots_(0), ic_kinds_(NULL) {} | 38 StaticFeedbackVectorSpec() : slots_(0), ic_slots_(0), ic_kinds_(NULL) {} |
| 39 explicit FeedbackVectorSpec(int slots) | 39 StaticFeedbackVectorSpec(int slots, int ic_slots, |
| 40 : slots_(slots), ic_slots_(0), ic_kinds_(NULL) {} | 40 FeedbackVectorSlotKind* ic_slot_kinds) |
| 41 FeedbackVectorSpec(int slots, int ic_slots, | |
| 42 FeedbackVectorSlotKind* ic_slot_kinds) | |
| 43 : slots_(slots), ic_slots_(ic_slots), ic_kinds_(ic_slot_kinds) {} | 41 : slots_(slots), ic_slots_(ic_slots), ic_kinds_(ic_slot_kinds) {} |
| 44 | 42 |
| 45 int slots() const { return slots_; } | 43 int slots() const { return slots_; } |
| 46 | 44 |
| 47 int ic_slots() const { return ic_slots_; } | 45 int ic_slots() const { return ic_slots_; } |
| 48 | 46 |
| 49 FeedbackVectorSlotKind GetKind(int ic_slot) const { | 47 FeedbackVectorSlotKind GetKind(int ic_slot) const { |
| 50 DCHECK(ic_slots_ > 0 && ic_slot < ic_slots_); | 48 DCHECK(ic_slots_ > 0 && ic_slot < ic_slots_); |
| 51 return ic_kinds_[ic_slot]; | 49 return ic_kinds_[ic_slot]; |
| 52 } | 50 } |
| 53 | 51 |
| 54 private: | 52 private: |
| 55 int slots_; | 53 int slots_; |
| 56 int ic_slots_; | 54 int ic_slots_; |
| 57 FeedbackVectorSlotKind* ic_kinds_; | 55 FeedbackVectorSlotKind* ic_kinds_; |
| 58 }; | 56 }; |
| 59 | 57 |
| 60 | 58 |
| 61 class ZoneFeedbackVectorSpec { | 59 class FeedbackVectorSpec { |
| 62 public: | 60 public: |
| 63 explicit ZoneFeedbackVectorSpec(Zone* zone) | 61 explicit FeedbackVectorSpec(Zone* zone) |
| 64 : slots_(0), ic_slots_(0), ic_slot_kinds_(zone) {} | 62 : slots_(0), ic_slots_(0), ic_slot_kinds_(zone) {} |
| 65 | 63 |
| 66 ZoneFeedbackVectorSpec(Zone* zone, int slots, int ic_slots) | |
| 67 : slots_(slots), ic_slots_(ic_slots), ic_slot_kinds_(ic_slots, zone) {} | |
| 68 | |
| 69 int slots() const { return slots_; } | 64 int slots() const { return slots_; } |
| 70 void increase_slots(int count) { slots_ += count; } | 65 void increase_slots(int count) { |
| 66 DCHECK_LT(0, count); |
| 67 slots_ += count; |
| 68 } |
| 71 | 69 |
| 72 int ic_slots() const { return ic_slots_; } | 70 int ic_slots() const { return ic_slots_; } |
| 73 void increase_ic_slots(int count) { | 71 void increase_ic_slots(int count) { |
| 72 DCHECK_LT(0, count); |
| 74 ic_slots_ += count; | 73 ic_slots_ += count; |
| 75 ic_slot_kinds_.resize(ic_slots_); | 74 ic_slot_kinds_.resize(ic_slots_); |
| 76 } | 75 } |
| 77 | 76 |
| 78 void SetKind(int ic_slot, FeedbackVectorSlotKind kind) { | 77 FeedbackVectorICSlot AddSlot(FeedbackVectorSlotKind kind) { |
| 79 ic_slot_kinds_[ic_slot] = static_cast<unsigned char>(kind); | 78 int slot = ic_slots_; |
| 79 increase_ic_slots(1); |
| 80 ic_slot_kinds_[slot] = static_cast<unsigned char>(kind); |
| 81 return FeedbackVectorICSlot(slot); |
| 82 } |
| 83 |
| 84 FeedbackVectorICSlot AddSlots(FeedbackVectorSlotKind kind, int count) { |
| 85 int slot = ic_slots_; |
| 86 increase_ic_slots(count); |
| 87 for (int i = 0; i < count; i++) { |
| 88 ic_slot_kinds_[slot + i] = static_cast<unsigned char>(kind); |
| 89 } |
| 90 return FeedbackVectorICSlot(slot); |
| 91 } |
| 92 |
| 93 FeedbackVectorICSlot AddCallICSlot() { |
| 94 return AddSlot(FeedbackVectorSlotKind::CALL_IC); |
| 95 } |
| 96 |
| 97 FeedbackVectorICSlot AddLoadICSlot() { |
| 98 return AddSlot(FeedbackVectorSlotKind::LOAD_IC); |
| 99 } |
| 100 |
| 101 FeedbackVectorICSlot AddLoadICSlots(int count) { |
| 102 return AddSlots(FeedbackVectorSlotKind::LOAD_IC, count); |
| 103 } |
| 104 |
| 105 FeedbackVectorICSlot AddKeyedLoadICSlot() { |
| 106 return AddSlot(FeedbackVectorSlotKind::KEYED_LOAD_IC); |
| 107 } |
| 108 |
| 109 FeedbackVectorICSlot AddStoreICSlots(int count) { |
| 110 return AddSlots(FeedbackVectorSlotKind::STORE_IC, count); |
| 111 } |
| 112 |
| 113 FeedbackVectorSlot AddStubSlot() { |
| 114 int slot = slots_; |
| 115 increase_slots(1); |
| 116 return FeedbackVectorSlot(slot); |
| 117 } |
| 118 |
| 119 FeedbackVectorSlot AddStubSlots(int count) { |
| 120 int slot = slots_; |
| 121 increase_slots(count); |
| 122 return FeedbackVectorSlot(slot); |
| 80 } | 123 } |
| 81 | 124 |
| 82 FeedbackVectorSlotKind GetKind(int ic_slot) const { | 125 FeedbackVectorSlotKind GetKind(int ic_slot) const { |
| 83 return static_cast<FeedbackVectorSlotKind>(ic_slot_kinds_.at(ic_slot)); | 126 return static_cast<FeedbackVectorSlotKind>(ic_slot_kinds_.at(ic_slot)); |
| 84 } | 127 } |
| 85 | 128 |
| 86 private: | 129 private: |
| 87 int slots_; | 130 int slots_; |
| 88 int ic_slots_; | 131 int ic_slots_; |
| 89 ZoneVector<unsigned char> ic_slot_kinds_; | 132 ZoneVector<unsigned char> ic_slot_kinds_; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 113 | 156 |
| 114 static int elements_per_ic_slot() { return 2; } | 157 static int elements_per_ic_slot() { return 2; } |
| 115 | 158 |
| 116 inline int first_ic_slot_index() const; | 159 inline int first_ic_slot_index() const; |
| 117 inline int ic_with_type_info_count(); | 160 inline int ic_with_type_info_count(); |
| 118 inline void change_ic_with_type_info_count(int delta); | 161 inline void change_ic_with_type_info_count(int delta); |
| 119 inline int ic_generic_count(); | 162 inline int ic_generic_count(); |
| 120 inline void change_ic_generic_count(int delta); | 163 inline void change_ic_generic_count(int delta); |
| 121 inline int ic_metadata_length() const; | 164 inline int ic_metadata_length() const; |
| 122 | 165 |
| 123 bool SpecDiffersFrom(const ZoneFeedbackVectorSpec* other_spec) const; | 166 bool SpecDiffersFrom(const FeedbackVectorSpec* other_spec) const; |
| 124 | 167 |
| 125 inline int Slots() const; | 168 inline int Slots() const; |
| 126 inline int ICSlots() const; | 169 inline int ICSlots() const; |
| 127 | 170 |
| 128 // Conversion from a slot or ic slot to an integer index to the underlying | 171 // Conversion from a slot or ic slot to an integer index to the underlying |
| 129 // array. | 172 // array. |
| 130 inline int GetIndex(FeedbackVectorSlot slot) const; | 173 inline int GetIndex(FeedbackVectorSlot slot) const; |
| 131 inline int GetIndex(FeedbackVectorICSlot slot) const; | 174 inline int GetIndex(FeedbackVectorICSlot slot) const; |
| 132 | 175 |
| 133 template <typename Spec> | 176 template <typename Spec> |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 KeyedAccessStoreMode GetKeyedAccessStoreMode() const; | 494 KeyedAccessStoreMode GetKeyedAccessStoreMode() const; |
| 452 IcCheckType GetKeyType() const; | 495 IcCheckType GetKeyType() const; |
| 453 | 496 |
| 454 InlineCacheState StateFromFeedback() const override; | 497 InlineCacheState StateFromFeedback() const override; |
| 455 Name* FindFirstName() const override; | 498 Name* FindFirstName() const override; |
| 456 }; | 499 }; |
| 457 } | 500 } |
| 458 } // namespace v8::internal | 501 } // namespace v8::internal |
| 459 | 502 |
| 460 #endif // V8_TRANSITIONS_H_ | 503 #endif // V8_TRANSITIONS_H_ |
| OLD | NEW |