| 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_TYPES_H_ | 5 #ifndef V8_TYPES_H_ |
| 6 #define V8_TYPES_H_ | 6 #define V8_TYPES_H_ |
| 7 | 7 |
| 8 #include "src/conversions.h" | 8 #include "src/conversions.h" |
| 9 #include "src/factory.h" | 9 #include "src/factory.h" |
| 10 #include "src/handles.h" | 10 #include "src/handles.h" |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 V(String, kInternalizedString | kOtherString) \ | 212 V(String, kInternalizedString | kOtherString) \ |
| 213 V(UniqueName, kSymbol | kInternalizedString) \ | 213 V(UniqueName, kSymbol | kInternalizedString) \ |
| 214 V(Name, kSymbol | kString) \ | 214 V(Name, kSymbol | kString) \ |
| 215 V(NumberOrString, kNumber | kString) \ | 215 V(NumberOrString, kNumber | kString) \ |
| 216 V(Primitive, kNumber | kName | kBoolean | kNull | kUndefined) \ | 216 V(Primitive, kNumber | kName | kBoolean | kNull | kUndefined) \ |
| 217 V(DetectableObject, kArray | kFunction | kRegExp | kOtherObject) \ | 217 V(DetectableObject, kArray | kFunction | kRegExp | kOtherObject) \ |
| 218 V(DetectableReceiver, kDetectableObject | kProxy) \ | 218 V(DetectableReceiver, kDetectableObject | kProxy) \ |
| 219 V(Detectable, kDetectableReceiver | kNumber | kName) \ | 219 V(Detectable, kDetectableReceiver | kNumber | kName) \ |
| 220 V(Object, kDetectableObject | kUndetectable) \ | 220 V(Object, kDetectableObject | kUndetectable) \ |
| 221 V(Receiver, kObject | kProxy) \ | 221 V(Receiver, kObject | kProxy) \ |
| 222 V(NonNumber, kBoolean | kName | kNull | kReceiver | \ | 222 V(Unique, kBoolean | kUniqueName | kNull | kUndefined | \ |
| 223 kUndefined | kInternal) \ | 223 kReceiver) \ |
| 224 V(NonNumber, kUnique | kString | kInternal) \ |
| 224 V(Any, 0xfffffffeu) | 225 V(Any, 0xfffffffeu) |
| 225 | 226 |
| 226 /* | 227 /* |
| 227 * The following diagrams show how integers (in the mathematical sense) are | 228 * The following diagrams show how integers (in the mathematical sense) are |
| 228 * divided among the different atomic numerical types. | 229 * divided among the different atomic numerical types. |
| 229 * | 230 * |
| 230 * If SmiValuesAre31Bits(): | 231 * If SmiValuesAre31Bits(): |
| 231 * | 232 * |
| 232 * ON OS32 OSS US OU31 OU32 ON | 233 * ON OS32 OSS US OU31 OU32 ON |
| 233 * ______[_______[_______[_______[_______[_______[_______ | 234 * ______[_______[_______[_______[_______[_______[_______ |
| (...skipping 21 matching lines...) Expand all Loading... |
| 255 | 256 |
| 256 // ----------------------------------------------------------------------------- | 257 // ----------------------------------------------------------------------------- |
| 257 // The abstract Type class, parameterized over the low-level representation. | 258 // The abstract Type class, parameterized over the low-level representation. |
| 258 | 259 |
| 259 // struct Config { | 260 // struct Config { |
| 260 // typedef TypeImpl<Config> Type; | 261 // typedef TypeImpl<Config> Type; |
| 261 // typedef Base; | 262 // typedef Base; |
| 262 // typedef Struct; | 263 // typedef Struct; |
| 263 // typedef Region; | 264 // typedef Region; |
| 264 // template<class> struct Handle { typedef type; } // No template typedefs... | 265 // template<class> struct Handle { typedef type; } // No template typedefs... |
| 266 // template<class T> static Handle<T>::type null_handle(); |
| 265 // template<class T> static Handle<T>::type handle(T* t); // !is_bitset(t) | 267 // template<class T> static Handle<T>::type handle(T* t); // !is_bitset(t) |
| 266 // template<class T> static Handle<T>::type cast(Handle<Type>::type); | 268 // template<class T> static Handle<T>::type cast(Handle<Type>::type); |
| 267 // static bool is_bitset(Type*); | 269 // static bool is_bitset(Type*); |
| 268 // static bool is_class(Type*); | 270 // static bool is_class(Type*); |
| 269 // static bool is_struct(Type*, int tag); | 271 // static bool is_struct(Type*, int tag); |
| 270 // static bitset as_bitset(Type*); | 272 // static bitset as_bitset(Type*); |
| 271 // static i::Handle<i::Map> as_class(Type*); | 273 // static i::Handle<i::Map> as_class(Type*); |
| 272 // static Handle<Struct>::type as_struct(Type*); | 274 // static Handle<Struct>::type as_struct(Type*); |
| 273 // static Type* from_bitset(bitset); | 275 // static Type* from_bitset(bitset); |
| 274 // static Handle<Type>::type from_bitset(bitset, Region*); | 276 // static Handle<Type>::type from_bitset(bitset, Region*); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 TypeHandle param2, Region* region) { | 367 TypeHandle param2, Region* region) { |
| 366 FunctionHandle function = Function(result, Any(region), 3, region); | 368 FunctionHandle function = Function(result, Any(region), 3, region); |
| 367 function->InitParameter(0, param0); | 369 function->InitParameter(0, param0); |
| 368 function->InitParameter(1, param1); | 370 function->InitParameter(1, param1); |
| 369 function->InitParameter(2, param2); | 371 function->InitParameter(2, param2); |
| 370 return function; | 372 return function; |
| 371 } | 373 } |
| 372 | 374 |
| 373 static TypeHandle Union(TypeHandle type1, TypeHandle type2, Region* reg); | 375 static TypeHandle Union(TypeHandle type1, TypeHandle type2, Region* reg); |
| 374 static TypeHandle Intersect(TypeHandle type1, TypeHandle type2, Region* reg); | 376 static TypeHandle Intersect(TypeHandle type1, TypeHandle type2, Region* reg); |
| 377 static TypeImpl* Union(TypeImpl* type1, TypeImpl* type2) { |
| 378 return BitsetType::New(type1->AsBitset() | type2->AsBitset()); |
| 379 } |
| 380 static TypeImpl* Intersect(TypeImpl* type1, TypeImpl* type2) { |
| 381 return BitsetType::New(type1->AsBitset() & type2->AsBitset()); |
| 382 } |
| 375 | 383 |
| 376 static TypeHandle Of(double value, Region* region) { | 384 static TypeHandle Of(double value, Region* region) { |
| 377 return Config::from_bitset(BitsetType::Lub(value), region); | 385 return Config::from_bitset(BitsetType::Lub(value), region); |
| 378 } | 386 } |
| 379 static TypeHandle Of(i::Object* value, Region* region) { | 387 static TypeHandle Of(i::Object* value, Region* region) { |
| 380 return Config::from_bitset(BitsetType::Lub(value), region); | 388 return Config::from_bitset(BitsetType::Lub(value), region); |
| 381 } | 389 } |
| 382 static TypeHandle Of(i::Handle<i::Object> value, Region* region) { | 390 static TypeHandle Of(i::Handle<i::Object> value, Region* region) { |
| 383 return Of(*value, region); | 391 return Of(*value, region); |
| 384 } | 392 } |
| (...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 902 // Zone-allocated types; they are either (odd) integers to represent bitsets, or | 910 // Zone-allocated types; they are either (odd) integers to represent bitsets, or |
| 903 // (even) pointers to structures for everything else. | 911 // (even) pointers to structures for everything else. |
| 904 | 912 |
| 905 struct ZoneTypeConfig { | 913 struct ZoneTypeConfig { |
| 906 typedef TypeImpl<ZoneTypeConfig> Type; | 914 typedef TypeImpl<ZoneTypeConfig> Type; |
| 907 class Base {}; | 915 class Base {}; |
| 908 typedef void* Struct; | 916 typedef void* Struct; |
| 909 typedef i::Zone Region; | 917 typedef i::Zone Region; |
| 910 template<class T> struct Handle { typedef T* type; }; | 918 template<class T> struct Handle { typedef T* type; }; |
| 911 | 919 |
| 920 template<class T> static inline T* null_handle(); |
| 912 template<class T> static inline T* handle(T* type); | 921 template<class T> static inline T* handle(T* type); |
| 913 template<class T> static inline T* cast(Type* type); | 922 template<class T> static inline T* cast(Type* type); |
| 914 | 923 |
| 915 static inline bool is_bitset(Type* type); | 924 static inline bool is_bitset(Type* type); |
| 916 static inline bool is_class(Type* type); | 925 static inline bool is_class(Type* type); |
| 917 static inline bool is_struct(Type* type, int tag); | 926 static inline bool is_struct(Type* type, int tag); |
| 918 | 927 |
| 919 static inline Type::bitset as_bitset(Type* type); | 928 static inline Type::bitset as_bitset(Type* type); |
| 920 static inline i::Handle<i::Map> as_class(Type* type); | 929 static inline i::Handle<i::Map> as_class(Type* type); |
| 921 static inline Struct* as_struct(Type* type); | 930 static inline Struct* as_struct(Type* type); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 944 // Heap-allocated types; either smis for bitsets, maps for classes, boxes for | 953 // Heap-allocated types; either smis for bitsets, maps for classes, boxes for |
| 945 // constants, or fixed arrays for unions. | 954 // constants, or fixed arrays for unions. |
| 946 | 955 |
| 947 struct HeapTypeConfig { | 956 struct HeapTypeConfig { |
| 948 typedef TypeImpl<HeapTypeConfig> Type; | 957 typedef TypeImpl<HeapTypeConfig> Type; |
| 949 typedef i::Object Base; | 958 typedef i::Object Base; |
| 950 typedef i::FixedArray Struct; | 959 typedef i::FixedArray Struct; |
| 951 typedef i::Isolate Region; | 960 typedef i::Isolate Region; |
| 952 template<class T> struct Handle { typedef i::Handle<T> type; }; | 961 template<class T> struct Handle { typedef i::Handle<T> type; }; |
| 953 | 962 |
| 963 template<class T> static inline i::Handle<T> null_handle(); |
| 954 template<class T> static inline i::Handle<T> handle(T* type); | 964 template<class T> static inline i::Handle<T> handle(T* type); |
| 955 template<class T> static inline i::Handle<T> cast(i::Handle<Type> type); | 965 template<class T> static inline i::Handle<T> cast(i::Handle<Type> type); |
| 956 | 966 |
| 957 static inline bool is_bitset(Type* type); | 967 static inline bool is_bitset(Type* type); |
| 958 static inline bool is_class(Type* type); | 968 static inline bool is_class(Type* type); |
| 959 static inline bool is_struct(Type* type, int tag); | 969 static inline bool is_struct(Type* type, int tag); |
| 960 | 970 |
| 961 static inline Type::bitset as_bitset(Type* type); | 971 static inline Type::bitset as_bitset(Type* type); |
| 962 static inline i::Handle<i::Map> as_class(Type* type); | 972 static inline i::Handle<i::Map> as_class(Type* type); |
| 963 static inline i::Handle<Struct> as_struct(Type* type); | 973 static inline i::Handle<Struct> as_struct(Type* type); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 992 | 1002 |
| 993 template<class Config> | 1003 template<class Config> |
| 994 struct BoundsImpl { | 1004 struct BoundsImpl { |
| 995 typedef TypeImpl<Config> Type; | 1005 typedef TypeImpl<Config> Type; |
| 996 typedef typename Type::TypeHandle TypeHandle; | 1006 typedef typename Type::TypeHandle TypeHandle; |
| 997 typedef typename Type::Region Region; | 1007 typedef typename Type::Region Region; |
| 998 | 1008 |
| 999 TypeHandle lower; | 1009 TypeHandle lower; |
| 1000 TypeHandle upper; | 1010 TypeHandle upper; |
| 1001 | 1011 |
| 1002 BoundsImpl() {} | 1012 BoundsImpl() : // Make sure accessing uninitialized bounds crashes big-time. |
| 1013 lower(Config::template null_handle<Type>()), |
| 1014 upper(Config::template null_handle<Type>()) {} |
| 1003 explicit BoundsImpl(TypeHandle t) : lower(t), upper(t) {} | 1015 explicit BoundsImpl(TypeHandle t) : lower(t), upper(t) {} |
| 1004 BoundsImpl(TypeHandle l, TypeHandle u) : lower(l), upper(u) { | 1016 BoundsImpl(TypeHandle l, TypeHandle u) : lower(l), upper(u) { |
| 1005 DCHECK(lower->Is(upper)); | 1017 DCHECK(lower->Is(upper)); |
| 1006 } | 1018 } |
| 1007 | 1019 |
| 1008 // Unrestricted bounds. | 1020 // Unrestricted bounds. |
| 1009 static BoundsImpl Unbounded(Region* region) { | 1021 static BoundsImpl Unbounded(Region* region) { |
| 1010 return BoundsImpl(Type::None(region), Type::Any(region)); | 1022 return BoundsImpl(Type::None(region), Type::Any(region)); |
| 1011 } | 1023 } |
| 1012 | 1024 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1041 bool Narrows(BoundsImpl that) { | 1053 bool Narrows(BoundsImpl that) { |
| 1042 return that.lower->Is(this->lower) && this->upper->Is(that.upper); | 1054 return that.lower->Is(this->lower) && this->upper->Is(that.upper); |
| 1043 } | 1055 } |
| 1044 }; | 1056 }; |
| 1045 | 1057 |
| 1046 typedef BoundsImpl<ZoneTypeConfig> Bounds; | 1058 typedef BoundsImpl<ZoneTypeConfig> Bounds; |
| 1047 | 1059 |
| 1048 } } // namespace v8::internal | 1060 } } // namespace v8::internal |
| 1049 | 1061 |
| 1050 #endif // V8_TYPES_H_ | 1062 #endif // V8_TYPES_H_ |
| OLD | NEW |