| 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" |
| 11 #include "src/elements-kind.h" | 11 #include "src/elements-kind.h" |
| 12 #include "src/heap/heap.h" | 12 #include "src/heap/heap.h" |
| 13 #include "src/isolate.h" | 13 #include "src/isolate.h" |
| 14 #include "src/objects.h" | 14 #include "src/objects.h" |
| 15 #include "src/zone-containers.h" |
| 15 | 16 |
| 16 namespace v8 { | 17 namespace v8 { |
| 17 namespace internal { | 18 namespace internal { |
| 18 | 19 |
| 19 class FeedbackVectorSpec { | 20 class FeedbackVectorSpec { |
| 20 public: | 21 public: |
| 21 FeedbackVectorSpec() : slots_(0), ic_slots_(0) {} | 22 FeedbackVectorSpec() : slots_(0), has_ic_slot_(false) {} |
| 22 FeedbackVectorSpec(int slots, int ic_slots) | 23 explicit FeedbackVectorSpec(int slots) : slots_(slots), has_ic_slot_(false) {} |
| 23 : slots_(slots), ic_slots_(ic_slots) { | 24 FeedbackVectorSpec(int slots, Code::Kind ic_slot_kind) |
| 24 if (FLAG_vector_ics) ic_slot_kinds_.resize(ic_slots); | 25 : slots_(slots), has_ic_slot_(true), ic_kind_(ic_slot_kind) {} |
| 26 |
| 27 int slots() const { return slots_; } |
| 28 |
| 29 int ic_slots() const { return has_ic_slot_ ? 1 : 0; } |
| 30 |
| 31 Code::Kind GetKind(int ic_slot) const { |
| 32 DCHECK(FLAG_vector_ics && has_ic_slot_ && ic_slot == 0); |
| 33 return ic_kind_; |
| 25 } | 34 } |
| 26 | 35 |
| 36 private: |
| 37 int slots_; |
| 38 bool has_ic_slot_; |
| 39 Code::Kind ic_kind_; |
| 40 }; |
| 41 |
| 42 |
| 43 class ZoneFeedbackVectorSpec { |
| 44 public: |
| 45 explicit ZoneFeedbackVectorSpec(Zone* zone) |
| 46 : slots_(0), ic_slots_(0), ic_slot_kinds_(zone) {} |
| 47 |
| 48 ZoneFeedbackVectorSpec(Zone* zone, int slots, int ic_slots) |
| 49 : slots_(slots), |
| 50 ic_slots_(ic_slots), |
| 51 ic_slot_kinds_(FLAG_vector_ics ? ic_slots : 0, zone) {} |
| 52 |
| 27 int slots() const { return slots_; } | 53 int slots() const { return slots_; } |
| 28 void increase_slots(int count) { slots_ += count; } | 54 void increase_slots(int count) { slots_ += count; } |
| 29 | 55 |
| 30 int ic_slots() const { return ic_slots_; } | 56 int ic_slots() const { return ic_slots_; } |
| 31 void increase_ic_slots(int count) { | 57 void increase_ic_slots(int count) { |
| 32 ic_slots_ += count; | 58 ic_slots_ += count; |
| 33 if (FLAG_vector_ics) ic_slot_kinds_.resize(ic_slots_); | 59 if (FLAG_vector_ics) ic_slot_kinds_.resize(ic_slots_); |
| 34 } | 60 } |
| 35 | 61 |
| 36 void SetKind(int ic_slot, Code::Kind kind) { | 62 void SetKind(int ic_slot, Code::Kind kind) { |
| 37 DCHECK(FLAG_vector_ics); | 63 DCHECK(FLAG_vector_ics); |
| 38 ic_slot_kinds_[ic_slot] = kind; | 64 ic_slot_kinds_[ic_slot] = kind; |
| 39 } | 65 } |
| 40 | 66 |
| 41 Code::Kind GetKind(int ic_slot) const { | 67 Code::Kind GetKind(int ic_slot) const { |
| 42 DCHECK(FLAG_vector_ics); | 68 DCHECK(FLAG_vector_ics); |
| 43 return static_cast<Code::Kind>(ic_slot_kinds_.at(ic_slot)); | 69 return static_cast<Code::Kind>(ic_slot_kinds_.at(ic_slot)); |
| 44 } | 70 } |
| 45 | 71 |
| 46 private: | 72 private: |
| 47 int slots_; | 73 int slots_; |
| 48 int ic_slots_; | 74 int ic_slots_; |
| 49 std::vector<unsigned char> ic_slot_kinds_; | 75 ZoneVector<unsigned char> ic_slot_kinds_; |
| 50 }; | 76 }; |
| 51 | 77 |
| 52 | 78 |
| 53 // The shape of the TypeFeedbackVector is an array with: | 79 // The shape of the TypeFeedbackVector is an array with: |
| 54 // 0: first_ic_slot_index (== length() if no ic slots are present) | 80 // 0: first_ic_slot_index (== length() if no ic slots are present) |
| 55 // 1: ics_with_types | 81 // 1: ics_with_types |
| 56 // 2: ics_with_generic_info | 82 // 2: ics_with_generic_info |
| 57 // 3: type information for ic slots, if any | 83 // 3: type information for ic slots, if any |
| 58 // ... | 84 // ... |
| 59 // N: first feedback slot (N >= 3) | 85 // N: first feedback slot (N >= 3) |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 | 180 |
| 155 Object* Get(FeedbackVectorICSlot slot) const { return get(GetIndex(slot)); } | 181 Object* Get(FeedbackVectorICSlot slot) const { return get(GetIndex(slot)); } |
| 156 void Set(FeedbackVectorICSlot slot, Object* value, | 182 void Set(FeedbackVectorICSlot slot, Object* value, |
| 157 WriteBarrierMode mode = UPDATE_WRITE_BARRIER) { | 183 WriteBarrierMode mode = UPDATE_WRITE_BARRIER) { |
| 158 set(GetIndex(slot), value, mode); | 184 set(GetIndex(slot), value, mode); |
| 159 } | 185 } |
| 160 | 186 |
| 161 // IC slots need metadata to recognize the type of IC. | 187 // IC slots need metadata to recognize the type of IC. |
| 162 Code::Kind GetKind(FeedbackVectorICSlot slot) const; | 188 Code::Kind GetKind(FeedbackVectorICSlot slot) const; |
| 163 | 189 |
| 190 template <typename Spec> |
| 164 static Handle<TypeFeedbackVector> Allocate(Isolate* isolate, | 191 static Handle<TypeFeedbackVector> Allocate(Isolate* isolate, |
| 165 const FeedbackVectorSpec& spec); | 192 const Spec* spec); |
| 166 | 193 |
| 167 static Handle<TypeFeedbackVector> Copy(Isolate* isolate, | 194 static Handle<TypeFeedbackVector> Copy(Isolate* isolate, |
| 168 Handle<TypeFeedbackVector> vector); | 195 Handle<TypeFeedbackVector> vector); |
| 169 | 196 |
| 170 // Clears the vector slots and the vector ic slots. | 197 // Clears the vector slots and the vector ic slots. |
| 171 void ClearSlots(SharedFunctionInfo* shared); | 198 void ClearSlots(SharedFunctionInfo* shared); |
| 172 void ClearICSlots(SharedFunctionInfo* shared) { | 199 void ClearICSlots(SharedFunctionInfo* shared) { |
| 173 ClearICSlotsImpl(shared, true); | 200 ClearICSlotsImpl(shared, true); |
| 174 } | 201 } |
| 175 void ClearICSlotsAtGCTime(SharedFunctionInfo* shared) { | 202 void ClearICSlotsAtGCTime(SharedFunctionInfo* shared) { |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 369 void ConfigurePolymorphic(Handle<Name> name, MapHandleList* maps, | 396 void ConfigurePolymorphic(Handle<Name> name, MapHandleList* maps, |
| 370 CodeHandleList* handlers); | 397 CodeHandleList* handlers); |
| 371 | 398 |
| 372 InlineCacheState StateFromFeedback() const OVERRIDE; | 399 InlineCacheState StateFromFeedback() const OVERRIDE; |
| 373 Name* FindFirstName() const OVERRIDE; | 400 Name* FindFirstName() const OVERRIDE; |
| 374 }; | 401 }; |
| 375 } | 402 } |
| 376 } // namespace v8::internal | 403 } // namespace v8::internal |
| 377 | 404 |
| 378 #endif // V8_TRANSITIONS_H_ | 405 #endif // V8_TRANSITIONS_H_ |
| OLD | NEW |