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 "src/checks.h" | 8 #include "src/checks.h" |
9 #include "src/elements-kind.h" | 9 #include "src/elements-kind.h" |
10 #include "src/heap/heap.h" | 10 #include "src/heap/heap.h" |
11 #include "src/isolate.h" | 11 #include "src/isolate.h" |
12 #include "src/objects.h" | 12 #include "src/objects.h" |
13 | 13 |
14 namespace v8 { | 14 namespace v8 { |
15 namespace internal { | 15 namespace internal { |
16 | 16 |
17 // The shape of the TypeFeedbackVector is an array with: | |
18 // 0: first_ic_slot_index (-1 if no ic slots present) | |
19 // 1: ics_with_types | |
20 // 2: ics_with_generic_info | |
21 // 3: first feedback slot | |
22 // ... | |
23 // [<first_ic_slot_index>: feedback slot] | |
24 // ...to length() - 1 | |
25 // | |
17 class TypeFeedbackVector : public FixedArray { | 26 class TypeFeedbackVector : public FixedArray { |
18 public: | 27 public: |
19 // Casting. | 28 // Casting. |
20 static TypeFeedbackVector* cast(Object* obj) { | 29 static TypeFeedbackVector* cast(Object* obj) { |
21 DCHECK(obj->IsTypeFeedbackVector()); | 30 DCHECK(obj->IsTypeFeedbackVector()); |
22 return reinterpret_cast<TypeFeedbackVector*>(obj); | 31 return reinterpret_cast<TypeFeedbackVector*>(obj); |
23 } | 32 } |
24 | 33 |
34 // In a TypeFeedbackVector for ICs, the first two indexes are reserved | |
ulan
2014/10/15 10:17:06
Comment seems out-of-date.
mvstanton
2014/10/16 10:54:15
Thanks. I removed it, as it seems pretty clear fro
| |
35 // for keeping track of type info in the overall function. | |
36 static const int kReservedIndexCount = 3; | |
37 static const int kFirstICSlotIndex = 0; | |
38 static const int kWithTypesIndex = 1; | |
39 static const int kGenericCountIndex = 2; | |
40 | |
41 inline int first_ic_slot_index() { | |
42 DCHECK(length() >= kReservedIndexCount); | |
43 return Smi::cast(get(kFirstICSlotIndex))->value(); | |
44 } | |
45 inline int ic_with_type_info_count(); | |
46 inline void change_ic_with_type_info_count(int delta); | |
47 | |
48 inline int ic_generic_count(); | |
49 inline void change_ic_generic_count(int delta); | |
50 | |
51 inline int Slots(); | |
52 inline int ICSlots(); | |
53 | |
54 // Conversion from a slot or ic slot to an integer index to the underlying | |
55 // array. | |
56 inline int GetIndex(FeedbackVectorSlot slot); | |
57 inline int GetIndex(FeedbackVectorICSlot slot); | |
58 | |
59 // Conversion from an integer index to either a slot or an ic slot. The caller | |
60 // should know what kind she expects. | |
61 inline FeedbackVectorSlot ToSlot(int index); | |
62 inline FeedbackVectorICSlot ToICSlot(int index); | |
63 | |
64 inline Object* Get(FeedbackVectorSlot slot); | |
65 inline void Set(FeedbackVectorSlot slot, Object* value, | |
66 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); | |
67 | |
68 inline Object* Get(FeedbackVectorICSlot slot); | |
69 inline void Set(FeedbackVectorICSlot slot, Object* value, | |
70 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); | |
71 | |
72 static Handle<TypeFeedbackVector> Allocate(Isolate* isolate, int slot_count, | |
73 int ic_slot_count); | |
74 | |
25 static Handle<TypeFeedbackVector> Copy(Isolate* isolate, | 75 static Handle<TypeFeedbackVector> Copy(Isolate* isolate, |
26 Handle<TypeFeedbackVector> vector); | 76 Handle<TypeFeedbackVector> vector); |
27 | 77 |
78 // Clears vector slots, and leaves vector ic slots alone. | |
79 void ClearSlots(); | |
80 | |
28 // The object that indicates an uninitialized cache. | 81 // The object that indicates an uninitialized cache. |
29 static inline Handle<Object> UninitializedSentinel(Isolate* isolate); | 82 static inline Handle<Object> UninitializedSentinel(Isolate* isolate); |
30 | 83 |
31 // The object that indicates a megamorphic state. | 84 // The object that indicates a megamorphic state. |
32 static inline Handle<Object> MegamorphicSentinel(Isolate* isolate); | 85 static inline Handle<Object> MegamorphicSentinel(Isolate* isolate); |
33 | 86 |
34 // The object that indicates a premonomorphic state. | 87 // The object that indicates a premonomorphic state. |
35 static inline Handle<Object> PremonomorphicSentinel(Isolate* isolate); | 88 static inline Handle<Object> PremonomorphicSentinel(Isolate* isolate); |
36 | 89 |
37 // The object that indicates a generic state. | 90 // The object that indicates a generic state. |
38 static inline Handle<Object> GenericSentinel(Isolate* isolate); | 91 static inline Handle<Object> GenericSentinel(Isolate* isolate); |
39 | 92 |
40 // The object that indicates a monomorphic state of Array with | 93 // The object that indicates a monomorphic state of Array with |
41 // ElementsKind | 94 // ElementsKind |
42 static inline Handle<Object> MonomorphicArraySentinel( | 95 static inline Handle<Object> MonomorphicArraySentinel( |
43 Isolate* isolate, ElementsKind elements_kind); | 96 Isolate* isolate, ElementsKind elements_kind); |
44 | 97 |
45 // A raw version of the uninitialized sentinel that's safe to read during | 98 // A raw version of the uninitialized sentinel that's safe to read during |
46 // garbage collection (e.g., for patching the cache). | 99 // garbage collection (e.g., for patching the cache). |
47 static inline Object* RawUninitializedSentinel(Heap* heap); | 100 static inline Object* RawUninitializedSentinel(Heap* heap); |
48 | 101 |
49 private: | 102 private: |
50 DISALLOW_IMPLICIT_CONSTRUCTORS(TypeFeedbackVector); | 103 DISALLOW_IMPLICIT_CONSTRUCTORS(TypeFeedbackVector); |
51 }; | 104 }; |
52 } | 105 } |
53 } // namespace v8::internal | 106 } // namespace v8::internal |
54 | 107 |
55 #endif // V8_TRANSITIONS_H_ | 108 #endif // V8_TRANSITIONS_H_ |
OLD | NEW |