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_INFO_H_ | 5 #ifndef V8_TYPE_INFO_H_ |
6 #define V8_TYPE_INFO_H_ | 6 #define V8_TYPE_INFO_H_ |
7 | 7 |
8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
9 #include "src/contexts.h" | 9 #include "src/contexts.h" |
10 #include "src/globals.h" | 10 #include "src/globals.h" |
11 #include "src/token.h" | 11 #include "src/token.h" |
12 #include "src/types.h" | 12 #include "src/types.h" |
13 #include "src/zone.h" | 13 #include "src/zone.h" |
14 | 14 |
15 namespace v8 { | 15 namespace v8 { |
16 namespace internal { | 16 namespace internal { |
17 | 17 |
18 // Forward declarations. | 18 // Forward declarations. |
19 class SmallMapList; | 19 class SmallMapList; |
20 | 20 |
21 | 21 |
22 class TypeFeedbackOracle: public ZoneObject { | 22 class TypeFeedbackOracle: public ZoneObject { |
23 public: | 23 public: |
24 TypeFeedbackOracle(Isolate* isolate, Zone* zone, Handle<Code> code, | 24 TypeFeedbackOracle(Isolate* isolate, Zone* zone, Handle<Code> code, |
25 Handle<TypeFeedbackVector> feedback_vector, | 25 Handle<TypeFeedbackVector> feedback_vector, |
26 Handle<Context> native_context); | 26 Handle<Context> native_context); |
27 | 27 |
28 InlineCacheState LoadInlineCacheState(TypeFeedbackId id); | |
29 InlineCacheState LoadInlineCacheState(FeedbackVectorSlot slot); | 28 InlineCacheState LoadInlineCacheState(FeedbackVectorSlot slot); |
30 bool StoreIsUninitialized(TypeFeedbackId id); | |
31 bool StoreIsUninitialized(FeedbackVectorSlot slot); | 29 bool StoreIsUninitialized(FeedbackVectorSlot slot); |
32 bool CallIsUninitialized(FeedbackVectorSlot slot); | 30 bool CallIsUninitialized(FeedbackVectorSlot slot); |
33 bool CallIsMonomorphic(FeedbackVectorSlot slot); | 31 bool CallIsMonomorphic(FeedbackVectorSlot slot); |
34 bool KeyedArrayCallIsHoley(TypeFeedbackId id); | |
35 bool CallNewIsMonomorphic(FeedbackVectorSlot slot); | 32 bool CallNewIsMonomorphic(FeedbackVectorSlot slot); |
36 | 33 |
37 // TODO(1571) We can't use ForInStatement::ForInType as the return value due | 34 // TODO(1571) We can't use ForInStatement::ForInType as the return value due |
38 // to various cycles in our headers. | 35 // to various cycles in our headers. |
39 // TODO(rossberg): once all oracle access is removed from ast.cc, it should | 36 // TODO(rossberg): once all oracle access is removed from ast.cc, it should |
40 // be possible. | 37 // be possible. |
41 byte ForInType(FeedbackVectorSlot feedback_vector_slot); | 38 byte ForInType(FeedbackVectorSlot feedback_vector_slot); |
42 | 39 |
43 void GetStoreModeAndKeyType(TypeFeedbackId id, | |
44 KeyedAccessStoreMode* store_mode, | |
45 IcCheckType* key_type); | |
46 void GetStoreModeAndKeyType(FeedbackVectorSlot slot, | 40 void GetStoreModeAndKeyType(FeedbackVectorSlot slot, |
47 KeyedAccessStoreMode* store_mode, | 41 KeyedAccessStoreMode* store_mode, |
48 IcCheckType* key_type); | 42 IcCheckType* key_type); |
49 | 43 |
50 void PropertyReceiverTypes(FeedbackVectorSlot slot, Handle<Name> name, | 44 void PropertyReceiverTypes(FeedbackVectorSlot slot, Handle<Name> name, |
51 SmallMapList* receiver_types); | 45 SmallMapList* receiver_types); |
52 void KeyedPropertyReceiverTypes(FeedbackVectorSlot slot, | 46 void KeyedPropertyReceiverTypes(FeedbackVectorSlot slot, |
53 SmallMapList* receiver_types, bool* is_string, | 47 SmallMapList* receiver_types, bool* is_string, |
54 IcCheckType* key_type); | 48 IcCheckType* key_type); |
55 void AssignmentReceiverTypes(TypeFeedbackId id, Handle<Name> name, | |
56 SmallMapList* receiver_types); | |
57 void AssignmentReceiverTypes(FeedbackVectorSlot slot, Handle<Name> name, | 49 void AssignmentReceiverTypes(FeedbackVectorSlot slot, Handle<Name> name, |
58 SmallMapList* receiver_types); | 50 SmallMapList* receiver_types); |
59 void KeyedAssignmentReceiverTypes(TypeFeedbackId id, | |
60 SmallMapList* receiver_types, | |
61 KeyedAccessStoreMode* store_mode, | |
62 IcCheckType* key_type); | |
63 void KeyedAssignmentReceiverTypes(FeedbackVectorSlot slot, | 51 void KeyedAssignmentReceiverTypes(FeedbackVectorSlot slot, |
64 SmallMapList* receiver_types, | 52 SmallMapList* receiver_types, |
65 KeyedAccessStoreMode* store_mode, | 53 KeyedAccessStoreMode* store_mode, |
66 IcCheckType* key_type); | 54 IcCheckType* key_type); |
67 void CountReceiverTypes(TypeFeedbackId id, | |
68 SmallMapList* receiver_types); | |
69 void CountReceiverTypes(FeedbackVectorSlot slot, | 55 void CountReceiverTypes(FeedbackVectorSlot slot, |
70 SmallMapList* receiver_types); | 56 SmallMapList* receiver_types); |
71 | 57 |
72 void CollectReceiverTypes(FeedbackVectorSlot slot, SmallMapList* types); | 58 void CollectReceiverTypes(FeedbackVectorSlot slot, SmallMapList* types); |
73 void CollectReceiverTypes(TypeFeedbackId id, | |
74 SmallMapList* types); | |
75 template <class T> | 59 template <class T> |
76 void CollectReceiverTypes(T* obj, SmallMapList* types); | 60 void CollectReceiverTypes(T* obj, SmallMapList* types); |
77 | 61 |
78 static bool IsRelevantFeedback(Map* map, Context* native_context) { | 62 static bool IsRelevantFeedback(Map* map, Context* native_context) { |
79 Object* constructor = map->GetConstructor(); | 63 Object* constructor = map->GetConstructor(); |
80 return !constructor->IsJSFunction() || | 64 return !constructor->IsJSFunction() || |
81 JSFunction::cast(constructor)->context()->native_context() == | 65 JSFunction::cast(constructor)->context()->native_context() == |
82 native_context; | 66 native_context; |
83 } | 67 } |
84 | 68 |
85 Handle<JSFunction> GetCallTarget(FeedbackVectorSlot slot); | 69 Handle<JSFunction> GetCallTarget(FeedbackVectorSlot slot); |
86 Handle<AllocationSite> GetCallAllocationSite(FeedbackVectorSlot slot); | 70 Handle<AllocationSite> GetCallAllocationSite(FeedbackVectorSlot slot); |
87 Handle<JSFunction> GetCallNewTarget(FeedbackVectorSlot slot); | 71 Handle<JSFunction> GetCallNewTarget(FeedbackVectorSlot slot); |
88 Handle<AllocationSite> GetCallNewAllocationSite(FeedbackVectorSlot slot); | 72 Handle<AllocationSite> GetCallNewAllocationSite(FeedbackVectorSlot slot); |
89 | 73 |
90 bool LoadIsBuiltin(TypeFeedbackId id, Builtins::Name builtin_id); | |
91 | |
92 // TODO(1571) We can't use ToBooleanStub::Types as the return value because | 74 // TODO(1571) We can't use ToBooleanStub::Types as the return value because |
93 // of various cycles in our headers. Death to tons of implementations in | 75 // of various cycles in our headers. Death to tons of implementations in |
94 // headers!! :-P | 76 // headers!! :-P |
95 uint16_t ToBooleanTypes(TypeFeedbackId id); | 77 uint16_t ToBooleanTypes(TypeFeedbackId id); |
96 | 78 |
97 // Get type information for arithmetic operations and compares. | 79 // Get type information for arithmetic operations and compares. |
98 void BinaryType(TypeFeedbackId id, | 80 void BinaryType(TypeFeedbackId id, |
99 Type** left, | 81 Type** left, |
100 Type** right, | 82 Type** right, |
101 Type** result, | 83 Type** result, |
102 Maybe<int>* fixed_right_arg, | 84 Maybe<int>* fixed_right_arg, |
103 Handle<AllocationSite>* allocation_site, | 85 Handle<AllocationSite>* allocation_site, |
104 Token::Value operation); | 86 Token::Value operation); |
105 | 87 |
106 void CompareType(TypeFeedbackId id, | 88 void CompareType(TypeFeedbackId id, |
107 Type** left, | 89 Type** left, |
108 Type** right, | 90 Type** right, |
109 Type** combined); | 91 Type** combined); |
110 | 92 |
111 Type* CountType(TypeFeedbackId id); | 93 Type* CountType(TypeFeedbackId id); |
112 | 94 |
113 Zone* zone() const { return zone_; } | 95 Zone* zone() const { return zone_; } |
114 Isolate* isolate() const { return isolate_; } | 96 Isolate* isolate() const { return isolate_; } |
115 | 97 |
116 private: | 98 private: |
117 void CollectReceiverTypes(FeedbackVectorSlot slot, Handle<Name> name, | 99 void CollectReceiverTypes(FeedbackVectorSlot slot, Handle<Name> name, |
118 Code::Flags flags, SmallMapList* types); | 100 Code::Flags flags, SmallMapList* types); |
119 void CollectReceiverTypes(TypeFeedbackId id, Handle<Name> name, | |
120 Code::Flags flags, SmallMapList* types); | |
121 template <class T> | 101 template <class T> |
122 void CollectReceiverTypes(T* obj, Handle<Name> name, Code::Flags flags, | 102 void CollectReceiverTypes(T* obj, Handle<Name> name, Code::Flags flags, |
123 SmallMapList* types); | 103 SmallMapList* types); |
124 | 104 |
125 // Returns true if there is at least one string map and if | 105 // Returns true if there is at least one string map and if |
126 // all maps are string maps. | 106 // all maps are string maps. |
127 bool HasOnlyStringMaps(SmallMapList* receiver_types); | 107 bool HasOnlyStringMaps(SmallMapList* receiver_types); |
128 | 108 |
129 void SetInfo(TypeFeedbackId id, Object* target); | 109 void SetInfo(TypeFeedbackId id, Object* target); |
130 | 110 |
(...skipping 20 matching lines...) Expand all Loading... |
151 Handle<UnseededNumberDictionary> dictionary_; | 131 Handle<UnseededNumberDictionary> dictionary_; |
152 Handle<TypeFeedbackVector> feedback_vector_; | 132 Handle<TypeFeedbackVector> feedback_vector_; |
153 | 133 |
154 DISALLOW_COPY_AND_ASSIGN(TypeFeedbackOracle); | 134 DISALLOW_COPY_AND_ASSIGN(TypeFeedbackOracle); |
155 }; | 135 }; |
156 | 136 |
157 } // namespace internal | 137 } // namespace internal |
158 } // namespace v8 | 138 } // namespace v8 |
159 | 139 |
160 #endif // V8_TYPE_INFO_H_ | 140 #endif // V8_TYPE_INFO_H_ |
OLD | NEW |