OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 108 matching lines...) Loading... |
119 static Type* InternalizedString() { return from_bitset(kInternalizedString); } | 119 static Type* InternalizedString() { return from_bitset(kInternalizedString); } |
120 static Type* Symbol() { return from_bitset(kSymbol); } | 120 static Type* Symbol() { return from_bitset(kSymbol); } |
121 | 121 |
122 static Type* Receiver() { return from_bitset(kReceiver); } | 122 static Type* Receiver() { return from_bitset(kReceiver); } |
123 static Type* Object() { return from_bitset(kObject); } | 123 static Type* Object() { return from_bitset(kObject); } |
124 static Type* Undetectable() { return from_bitset(kUndetectable); } | 124 static Type* Undetectable() { return from_bitset(kUndetectable); } |
125 static Type* Array() { return from_bitset(kArray); } | 125 static Type* Array() { return from_bitset(kArray); } |
126 static Type* Function() { return from_bitset(kFunction); } | 126 static Type* Function() { return from_bitset(kFunction); } |
127 static Type* RegExp() { return from_bitset(kRegExp); } | 127 static Type* RegExp() { return from_bitset(kRegExp); } |
128 static Type* Proxy() { return from_bitset(kProxy); } | 128 static Type* Proxy() { return from_bitset(kProxy); } |
| 129 static Type* Internal() { return from_bitset(kInternal); } |
129 | 130 |
130 static Type* Class(Handle<Map> map) { return from_handle(map); } | 131 static Type* Class(Handle<Map> map) { return from_handle(map); } |
131 static Type* Constant(Handle<HeapObject> value) { | 132 static Type* Constant(Handle<HeapObject> value) { |
132 return Constant(value, value->GetIsolate()); | 133 return Constant(value, value->GetIsolate()); |
133 } | 134 } |
134 static Type* Constant(Handle<v8::internal::Object> value, Isolate* isolate) { | 135 static Type* Constant(Handle<v8::internal::Object> value, Isolate* isolate) { |
135 return from_handle(isolate->factory()->NewBox(value)); | 136 return from_handle(isolate->factory()->NewBox(value)); |
136 } | 137 } |
137 | 138 |
138 static Type* Union(Handle<Type> type1, Handle<Type> type2); | 139 static Type* Union(Handle<Type> type1, Handle<Type> type2); |
139 static Type* Intersect(Handle<Type> type1, Handle<Type> type2); | 140 static Type* Intersect(Handle<Type> type1, Handle<Type> type2); |
140 static Type* Optional(Handle<Type> type); // type \/ Undefined | 141 static Type* Optional(Handle<Type> type); // type \/ Undefined |
141 | 142 |
142 bool Is(Type* that); | 143 bool Is(Type* that) { return (this == that) ? true : IsSlowCase(that); } |
143 bool Is(Handle<Type> that) { return this->Is(*that); } | 144 bool Is(Handle<Type> that) { return this->Is(*that); } |
144 bool Maybe(Type* that); | 145 bool Maybe(Type* that); |
145 bool Maybe(Handle<Type> that) { return this->Maybe(*that); } | 146 bool Maybe(Handle<Type> that) { return this->Maybe(*that); } |
146 | 147 |
147 bool IsClass() { return is_class(); } | 148 bool IsClass() { return is_class(); } |
148 bool IsConstant() { return is_constant(); } | 149 bool IsConstant() { return is_constant(); } |
149 Handle<Map> AsClass() { return as_class(); } | 150 Handle<Map> AsClass() { return as_class(); } |
150 Handle<v8::internal::Object> AsConstant() { return as_constant(); } | 151 Handle<v8::internal::Object> AsConstant() { return as_constant(); } |
151 | 152 |
152 int NumClasses(); | 153 int NumClasses(); |
(...skipping 47 matching lines...) Loading... |
200 kDouble = 1 << 6, | 201 kDouble = 1 << 6, |
201 kSymbol = 1 << 7, | 202 kSymbol = 1 << 7, |
202 kInternalizedString = 1 << 8, | 203 kInternalizedString = 1 << 8, |
203 kOtherString = 1 << 9, | 204 kOtherString = 1 << 9, |
204 kUndetectable = 1 << 10, | 205 kUndetectable = 1 << 10, |
205 kArray = 1 << 11, | 206 kArray = 1 << 11, |
206 kFunction = 1 << 12, | 207 kFunction = 1 << 12, |
207 kRegExp = 1 << 13, | 208 kRegExp = 1 << 13, |
208 kOtherObject = 1 << 14, | 209 kOtherObject = 1 << 14, |
209 kProxy = 1 << 15, | 210 kProxy = 1 << 15, |
| 211 kInternal = 1 << 16, |
210 | 212 |
211 kOddball = kBoolean | kNull | kUndefined, | 213 kOddball = kBoolean | kNull | kUndefined, |
212 kSigned32 = kSmi | kOtherSigned32, | 214 kSigned32 = kSmi | kOtherSigned32, |
213 kNumber = kSigned32 | kUnsigned32 | kDouble, | 215 kNumber = kSigned32 | kUnsigned32 | kDouble, |
214 kString = kInternalizedString | kOtherString, | 216 kString = kInternalizedString | kOtherString, |
215 kUniqueName = kSymbol | kInternalizedString, | 217 kUniqueName = kSymbol | kInternalizedString, |
216 kName = kSymbol | kString, | 218 kName = kSymbol | kString, |
217 kNumberOrString = kNumber | kString, | 219 kNumberOrString = kNumber | kString, |
218 kObject = kUndetectable | kArray | kFunction | kRegExp | kOtherObject, | 220 kObject = kUndetectable | kArray | kFunction | kRegExp | kOtherObject, |
219 kReceiver = kObject | kProxy, | 221 kReceiver = kObject | kProxy, |
220 kAllocated = kDouble | kName | kReceiver, | 222 kAllocated = kDouble | kName | kReceiver, |
221 kAny = kOddball | kNumber | kAllocated, | 223 kAny = kOddball | kNumber | kAllocated | kInternal, |
222 kDetectable = kAllocated - kUndetectable, | 224 kDetectable = kAllocated - kUndetectable, |
223 kNone = 0 | 225 kNone = 0 |
224 }; | 226 }; |
225 | 227 |
226 bool is_bitset() { return this->IsSmi(); } | 228 bool is_bitset() { return this->IsSmi(); } |
227 bool is_class() { return this->IsMap(); } | 229 bool is_class() { return this->IsMap(); } |
228 bool is_constant() { return this->IsBox(); } | 230 bool is_constant() { return this->IsBox(); } |
229 bool is_union() { return this->IsFixedArray(); } | 231 bool is_union() { return this->IsFixedArray(); } |
230 | 232 |
| 233 bool IsSlowCase(Type* that); |
| 234 |
231 int as_bitset() { return Smi::cast(this)->value(); } | 235 int as_bitset() { return Smi::cast(this)->value(); } |
232 Handle<Map> as_class() { return Handle<Map>::cast(handle()); } | 236 Handle<Map> as_class() { return Handle<Map>::cast(handle()); } |
233 Handle<v8::internal::Object> as_constant() { | 237 Handle<v8::internal::Object> as_constant() { |
234 Handle<Box> box = Handle<Box>::cast(handle()); | 238 Handle<Box> box = Handle<Box>::cast(handle()); |
235 return v8::internal::handle(box->value(), box->GetIsolate()); | 239 return v8::internal::handle(box->value(), box->GetIsolate()); |
236 } | 240 } |
237 Handle<Unioned> as_union() { return Handle<Unioned>::cast(handle()); } | 241 Handle<Unioned> as_union() { return Handle<Unioned>::cast(handle()); } |
238 | 242 |
239 Handle<Type> handle() { return handle_via_isolate_of(this); } | 243 Handle<Type> handle() { return handle_via_isolate_of(this); } |
240 Handle<Type> handle_via_isolate_of(Type* type) { | 244 Handle<Type> handle_via_isolate_of(Type* type) { |
(...skipping 18 matching lines...) Loading... |
259 int GlbBitset(); // greatest lower bound that's a bitset | 263 int GlbBitset(); // greatest lower bound that's a bitset |
260 bool InUnion(Handle<Unioned> unioned, int current_size); | 264 bool InUnion(Handle<Unioned> unioned, int current_size); |
261 int ExtendUnion(Handle<Unioned> unioned, int current_size); | 265 int ExtendUnion(Handle<Unioned> unioned, int current_size); |
262 int ExtendIntersection( | 266 int ExtendIntersection( |
263 Handle<Unioned> unioned, Handle<Type> type, int current_size); | 267 Handle<Unioned> unioned, Handle<Type> type, int current_size); |
264 }; | 268 }; |
265 | 269 |
266 } } // namespace v8::internal | 270 } } // namespace v8::internal |
267 | 271 |
268 #endif // V8_TYPES_H_ | 272 #endif // V8_TYPES_H_ |
OLD | NEW |