OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 | 58 |
59 static TypeInfo Unknown() { return TypeInfo(kUnknown); } | 59 static TypeInfo Unknown() { return TypeInfo(kUnknown); } |
60 // We know it's a primitive type. | 60 // We know it's a primitive type. |
61 static TypeInfo Primitive() { return TypeInfo(kPrimitive); } | 61 static TypeInfo Primitive() { return TypeInfo(kPrimitive); } |
62 // We know it's a number of some sort. | 62 // We know it's a number of some sort. |
63 static TypeInfo Number() { return TypeInfo(kNumber); } | 63 static TypeInfo Number() { return TypeInfo(kNumber); } |
64 // We know it's a signed 32 bit integer. | 64 // We know it's a signed 32 bit integer. |
65 static TypeInfo Integer32() { return TypeInfo(kInteger32); } | 65 static TypeInfo Integer32() { return TypeInfo(kInteger32); } |
66 // We know it's a Smi. | 66 // We know it's a Smi. |
67 static TypeInfo Smi() { return TypeInfo(kSmi); } | 67 static TypeInfo Smi() { return TypeInfo(kSmi); } |
68 // We know it's a Symbol. | |
69 static TypeInfo Symbol() { return TypeInfo(kSymbol); } | |
70 // We know it's a heap number. | 68 // We know it's a heap number. |
71 static TypeInfo Double() { return TypeInfo(kDouble); } | 69 static TypeInfo Double() { return TypeInfo(kDouble); } |
72 // We know it's a string. | 70 // We know it's a string. |
73 static TypeInfo String() { return TypeInfo(kString); } | 71 static TypeInfo String() { return TypeInfo(kString); } |
| 72 // We know it's an internalized string. |
| 73 static TypeInfo InternalizedString() { return TypeInfo(kInternalizedString); } |
74 // We know it's a non-primitive (object) type. | 74 // We know it's a non-primitive (object) type. |
75 static TypeInfo NonPrimitive() { return TypeInfo(kNonPrimitive); } | 75 static TypeInfo NonPrimitive() { return TypeInfo(kNonPrimitive); } |
76 // We haven't started collecting info yet. | 76 // We haven't started collecting info yet. |
77 static TypeInfo Uninitialized() { return TypeInfo(kUninitialized); } | 77 static TypeInfo Uninitialized() { return TypeInfo(kUninitialized); } |
78 | 78 |
79 int ToInt() { | 79 int ToInt() { |
80 return type_; | 80 return type_; |
81 } | 81 } |
82 | 82 |
83 static TypeInfo FromInt(int bit_representation) { | 83 static TypeInfo FromInt(int bit_representation) { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 inline bool IsNumber() { | 133 inline bool IsNumber() { |
134 ASSERT(type_ != kUninitialized); | 134 ASSERT(type_ != kUninitialized); |
135 return ((type_ & kNumber) == kNumber); | 135 return ((type_ & kNumber) == kNumber); |
136 } | 136 } |
137 | 137 |
138 inline bool IsSmi() { | 138 inline bool IsSmi() { |
139 ASSERT(type_ != kUninitialized); | 139 ASSERT(type_ != kUninitialized); |
140 return ((type_ & kSmi) == kSmi); | 140 return ((type_ & kSmi) == kSmi); |
141 } | 141 } |
142 | 142 |
143 inline bool IsSymbol() { | 143 inline bool IsInternalizedString() { |
144 ASSERT(type_ != kUninitialized); | 144 ASSERT(type_ != kUninitialized); |
145 return ((type_ & kSymbol) == kSymbol); | 145 return ((type_ & kInternalizedString) == kInternalizedString); |
146 } | 146 } |
147 | 147 |
148 inline bool IsNonSymbol() { | 148 inline bool IsNonInternalizedString() { |
149 ASSERT(type_ != kUninitialized); | 149 ASSERT(type_ != kUninitialized); |
150 return ((type_ & kSymbol) == kString); | 150 return ((type_ & kInternalizedString) == kString); |
151 } | 151 } |
152 | 152 |
153 inline bool IsInteger32() { | 153 inline bool IsInteger32() { |
154 ASSERT(type_ != kUninitialized); | 154 ASSERT(type_ != kUninitialized); |
155 return ((type_ & kInteger32) == kInteger32); | 155 return ((type_ & kInteger32) == kInteger32); |
156 } | 156 } |
157 | 157 |
158 inline bool IsDouble() { | 158 inline bool IsDouble() { |
159 ASSERT(type_ != kUninitialized); | 159 ASSERT(type_ != kUninitialized); |
160 return ((type_ & kDouble) == kDouble); | 160 return ((type_ & kDouble) == kDouble); |
(...skipping 13 matching lines...) Expand all Loading... |
174 return type_ == kUninitialized; | 174 return type_ == kUninitialized; |
175 } | 175 } |
176 | 176 |
177 const char* ToString() { | 177 const char* ToString() { |
178 switch (type_) { | 178 switch (type_) { |
179 case kUnknown: return "Unknown"; | 179 case kUnknown: return "Unknown"; |
180 case kPrimitive: return "Primitive"; | 180 case kPrimitive: return "Primitive"; |
181 case kNumber: return "Number"; | 181 case kNumber: return "Number"; |
182 case kInteger32: return "Integer32"; | 182 case kInteger32: return "Integer32"; |
183 case kSmi: return "Smi"; | 183 case kSmi: return "Smi"; |
184 case kSymbol: return "Symbol"; | 184 case kInternalizedString: return "InternalizedString"; |
185 case kDouble: return "Double"; | 185 case kDouble: return "Double"; |
186 case kString: return "String"; | 186 case kString: return "String"; |
187 case kNonPrimitive: return "Object"; | 187 case kNonPrimitive: return "Object"; |
188 case kUninitialized: return "Uninitialized"; | 188 case kUninitialized: return "Uninitialized"; |
189 } | 189 } |
190 UNREACHABLE(); | 190 UNREACHABLE(); |
191 return "Unreachable code"; | 191 return "Unreachable code"; |
192 } | 192 } |
193 | 193 |
194 private: | 194 private: |
195 enum Type { | 195 enum Type { |
196 kUnknown = 0, // 0000000 | 196 kUnknown = 0, // 0000000 |
197 kPrimitive = 0x10, // 0010000 | 197 kPrimitive = 0x10, // 0010000 |
198 kNumber = 0x11, // 0010001 | 198 kNumber = 0x11, // 0010001 |
199 kInteger32 = 0x13, // 0010011 | 199 kInteger32 = 0x13, // 0010011 |
200 kSmi = 0x17, // 0010111 | 200 kSmi = 0x17, // 0010111 |
201 kDouble = 0x19, // 0011001 | 201 kDouble = 0x19, // 0011001 |
202 kString = 0x30, // 0110000 | 202 kString = 0x30, // 0110000 |
203 kSymbol = 0x32, // 0110010 | 203 kInternalizedString = 0x32, // 0110010 |
204 kNonPrimitive = 0x40, // 1000000 | 204 kNonPrimitive = 0x40, // 1000000 |
205 kUninitialized = 0x7f // 1111111 | 205 kUninitialized = 0x7f // 1111111 |
206 }; | 206 }; |
207 | 207 |
208 explicit inline TypeInfo(Type t) : type_(t) { } | 208 explicit inline TypeInfo(Type t) : type_(t) { } |
209 | 209 |
210 Type type_; | 210 Type type_; |
211 }; | 211 }; |
212 | 212 |
213 | 213 |
214 enum StringStubFeedback { | 214 enum StringStubFeedback { |
215 DEFAULT_STRING_STUB = 0, | 215 DEFAULT_STRING_STUB = 0, |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 Isolate* isolate_; | 329 Isolate* isolate_; |
330 Handle<UnseededNumberDictionary> dictionary_; | 330 Handle<UnseededNumberDictionary> dictionary_; |
331 Zone* zone_; | 331 Zone* zone_; |
332 | 332 |
333 DISALLOW_COPY_AND_ASSIGN(TypeFeedbackOracle); | 333 DISALLOW_COPY_AND_ASSIGN(TypeFeedbackOracle); |
334 }; | 334 }; |
335 | 335 |
336 } } // namespace v8::internal | 336 } } // namespace v8::internal |
337 | 337 |
338 #endif // V8_TYPE_INFO_H_ | 338 #endif // V8_TYPE_INFO_H_ |
OLD | NEW |