| 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/type-feedback-vector.h" | 8 #include "src/type-feedback-vector.h" |
| 9 | 9 |
| 10 namespace v8 { | 10 namespace v8 { |
| 11 namespace internal { | 11 namespace internal { |
| 12 | 12 |
| 13 | 13 |
| 14 template <typename Derived> | 14 template <typename Derived> |
| 15 FeedbackVectorSlot FeedbackVectorSpecBase<Derived>::AddSlot( | 15 FeedbackVectorSlot FeedbackVectorSpecBase<Derived>::AddSlot( |
| 16 FeedbackVectorSlotKind kind) { | 16 FeedbackVectorSlotKind kind) { |
| 17 Derived* derived = static_cast<Derived*>(this); | 17 int slot = This()->slots(); |
| 18 | |
| 19 int slot = derived->slots(); | |
| 20 int entries_per_slot = TypeFeedbackMetadata::GetSlotSize(kind); | 18 int entries_per_slot = TypeFeedbackMetadata::GetSlotSize(kind); |
| 21 derived->append(kind); | 19 This()->append(kind); |
| 22 for (int i = 1; i < entries_per_slot; i++) { | 20 for (int i = 1; i < entries_per_slot; i++) { |
| 23 derived->append(FeedbackVectorSlotKind::INVALID); | 21 This()->append(FeedbackVectorSlotKind::INVALID); |
| 24 } | 22 } |
| 25 return FeedbackVectorSlot(slot); | 23 return FeedbackVectorSlot(slot); |
| 26 } | 24 } |
| 27 | 25 |
| 28 | 26 |
| 29 // static | 27 // static |
| 30 TypeFeedbackMetadata* TypeFeedbackMetadata::cast(Object* obj) { | 28 TypeFeedbackMetadata* TypeFeedbackMetadata::cast(Object* obj) { |
| 31 DCHECK(obj->IsTypeFeedbackVector()); | 29 DCHECK(obj->IsTypeFeedbackVector()); |
| 32 return reinterpret_cast<TypeFeedbackMetadata*>(obj); | 30 return reinterpret_cast<TypeFeedbackMetadata*>(obj); |
| 33 } | 31 } |
| (...skipping 16 matching lines...) Expand all Loading... |
| 50 return reinterpret_cast<TypeFeedbackVector*>(obj); | 48 return reinterpret_cast<TypeFeedbackVector*>(obj); |
| 51 } | 49 } |
| 52 | 50 |
| 53 | 51 |
| 54 int TypeFeedbackMetadata::GetSlotSize(FeedbackVectorSlotKind kind) { | 52 int TypeFeedbackMetadata::GetSlotSize(FeedbackVectorSlotKind kind) { |
| 55 DCHECK_NE(FeedbackVectorSlotKind::INVALID, kind); | 53 DCHECK_NE(FeedbackVectorSlotKind::INVALID, kind); |
| 56 DCHECK_NE(FeedbackVectorSlotKind::KINDS_NUMBER, kind); | 54 DCHECK_NE(FeedbackVectorSlotKind::KINDS_NUMBER, kind); |
| 57 return kind == FeedbackVectorSlotKind::GENERAL ? 1 : 2; | 55 return kind == FeedbackVectorSlotKind::GENERAL ? 1 : 2; |
| 58 } | 56 } |
| 59 | 57 |
| 58 bool TypeFeedbackMetadata::SlotRequiresName(FeedbackVectorSlotKind kind) { |
| 59 switch (kind) { |
| 60 case FeedbackVectorSlotKind::LOAD_GLOBAL_IC: |
| 61 return true; |
| 62 |
| 63 case FeedbackVectorSlotKind::CALL_IC: |
| 64 case FeedbackVectorSlotKind::LOAD_IC: |
| 65 case FeedbackVectorSlotKind::KEYED_LOAD_IC: |
| 66 case FeedbackVectorSlotKind::STORE_IC: |
| 67 case FeedbackVectorSlotKind::KEYED_STORE_IC: |
| 68 case FeedbackVectorSlotKind::GENERAL: |
| 69 case FeedbackVectorSlotKind::INVALID: |
| 70 return false; |
| 71 |
| 72 case FeedbackVectorSlotKind::KINDS_NUMBER: |
| 73 break; |
| 74 } |
| 75 UNREACHABLE(); |
| 76 return false; |
| 77 } |
| 60 | 78 |
| 61 bool TypeFeedbackVector::is_empty() const { | 79 bool TypeFeedbackVector::is_empty() const { |
| 62 if (length() == 0) return true; | 80 if (length() == 0) return true; |
| 63 DCHECK(length() > kReservedIndexCount); | 81 DCHECK(length() > kReservedIndexCount); |
| 64 return false; | 82 return false; |
| 65 } | 83 } |
| 66 | 84 |
| 67 | 85 |
| 68 int TypeFeedbackVector::slot_count() const { | 86 int TypeFeedbackVector::slot_count() const { |
| 69 if (length() == 0) return 0; | 87 if (length() == 0) return 0; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 | 151 |
| 134 Handle<Symbol> TypeFeedbackVector::PremonomorphicSentinel(Isolate* isolate) { | 152 Handle<Symbol> TypeFeedbackVector::PremonomorphicSentinel(Isolate* isolate) { |
| 135 return isolate->factory()->premonomorphic_symbol(); | 153 return isolate->factory()->premonomorphic_symbol(); |
| 136 } | 154 } |
| 137 | 155 |
| 138 Symbol* TypeFeedbackVector::RawUninitializedSentinel(Isolate* isolate) { | 156 Symbol* TypeFeedbackVector::RawUninitializedSentinel(Isolate* isolate) { |
| 139 return isolate->heap()->uninitialized_symbol(); | 157 return isolate->heap()->uninitialized_symbol(); |
| 140 } | 158 } |
| 141 | 159 |
| 142 bool TypeFeedbackMetadataIterator::HasNext() const { | 160 bool TypeFeedbackMetadataIterator::HasNext() const { |
| 143 return slot_.ToInt() < metadata()->slot_count(); | 161 return next_slot_.ToInt() < metadata()->slot_count(); |
| 144 } | 162 } |
| 145 | 163 |
| 146 FeedbackVectorSlot TypeFeedbackMetadataIterator::Next() { | 164 FeedbackVectorSlot TypeFeedbackMetadataIterator::Next() { |
| 147 DCHECK(HasNext()); | 165 DCHECK(HasNext()); |
| 148 FeedbackVectorSlot slot = slot_; | 166 cur_slot_ = next_slot_; |
| 149 slot_kind_ = metadata()->GetKind(slot); | 167 slot_kind_ = metadata()->GetKind(cur_slot_); |
| 150 slot_ = FeedbackVectorSlot(slot_.ToInt() + entry_size()); | 168 next_slot_ = FeedbackVectorSlot(next_slot_.ToInt() + entry_size()); |
| 151 return slot; | 169 return cur_slot_; |
| 152 } | 170 } |
| 153 | 171 |
| 154 int TypeFeedbackMetadataIterator::entry_size() const { | 172 int TypeFeedbackMetadataIterator::entry_size() const { |
| 155 return TypeFeedbackMetadata::GetSlotSize(kind()); | 173 return TypeFeedbackMetadata::GetSlotSize(kind()); |
| 156 } | 174 } |
| 157 | 175 |
| 158 Object* FeedbackNexus::GetFeedback() const { return vector()->Get(slot()); } | 176 Object* FeedbackNexus::GetFeedback() const { return vector()->Get(slot()); } |
| 159 | 177 |
| 160 | 178 |
| 161 Object* FeedbackNexus::GetFeedbackExtra() const { | 179 Object* FeedbackNexus::GetFeedbackExtra() const { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 182 int index = vector()->GetIndex(slot()) + 1; | 200 int index = vector()->GetIndex(slot()) + 1; |
| 183 vector()->set(index, feedback_extra, mode); | 201 vector()->set(index, feedback_extra, mode); |
| 184 } | 202 } |
| 185 | 203 |
| 186 | 204 |
| 187 Isolate* FeedbackNexus::GetIsolate() const { return vector()->GetIsolate(); } | 205 Isolate* FeedbackNexus::GetIsolate() const { return vector()->GetIsolate(); } |
| 188 } // namespace internal | 206 } // namespace internal |
| 189 } // namespace v8 | 207 } // namespace v8 |
| 190 | 208 |
| 191 #endif // V8_TYPE_FEEDBACK_VECTOR_INL_H_ | 209 #endif // V8_TYPE_FEEDBACK_VECTOR_INL_H_ |
| OLD | NEW |