| 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_COMPILER_TYPES_H_ | 5 #ifndef V8_COMPILER_TYPES_H_ |
| 6 #define V8_COMPILER_TYPES_H_ | 6 #define V8_COMPILER_TYPES_H_ |
| 7 | 7 |
| 8 #include "src/conversions.h" | 8 #include "src/conversions.h" |
| 9 #include "src/handles.h" | 9 #include "src/handles.h" |
| 10 #include "src/objects.h" | 10 #include "src/objects.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 // InternalizedString < String | 40 // InternalizedString < String |
| 41 // | 41 // |
| 42 // Receiver = Object \/ Proxy | 42 // Receiver = Object \/ Proxy |
| 43 // RegExp < Object | 43 // RegExp < Object |
| 44 // OtherUndetectable < Object | 44 // OtherUndetectable < Object |
| 45 // DetectableReceiver = Receiver - OtherUndetectable | 45 // DetectableReceiver = Receiver - OtherUndetectable |
| 46 // | 46 // |
| 47 // Constant(x) < T iff instance_type(map(x)) < T | 47 // Constant(x) < T iff instance_type(map(x)) < T |
| 48 // | 48 // |
| 49 // | 49 // |
| 50 // REPRESENTATIONAL DIMENSION |
| 51 // |
| 52 // For the representation axis, the following holds: |
| 53 // |
| 54 // None <= R |
| 55 // R <= Any |
| 56 // |
| 57 // UntaggedInt = UntaggedInt1 \/ UntaggedInt8 \/ |
| 58 // UntaggedInt16 \/ UntaggedInt32 |
| 59 // UntaggedFloat = UntaggedFloat32 \/ UntaggedFloat64 |
| 60 // UntaggedNumber = UntaggedInt \/ UntaggedFloat |
| 61 // Untagged = UntaggedNumber \/ UntaggedPtr |
| 62 // Tagged = TaggedInt \/ TaggedPtr |
| 63 // |
| 64 // Subtyping relates the two dimensions, for example: |
| 65 // |
| 66 // Number <= Tagged \/ UntaggedNumber |
| 67 // Object <= TaggedPtr \/ UntaggedPtr |
| 68 // |
| 69 // That holds because the semantic type constructors defined by the API create |
| 70 // types that allow for all possible representations, and dually, the ones for |
| 71 // representation types initially include all semantic ranges. Representations |
| 72 // can then e.g. be narrowed for a given semantic type using intersection: |
| 73 // |
| 74 // SignedSmall /\ TaggedInt (a 'smi') |
| 75 // Number /\ TaggedPtr (a heap number) |
| 76 // |
| 77 // |
| 50 // RANGE TYPES | 78 // RANGE TYPES |
| 51 // | 79 // |
| 52 // A range type represents a continuous integer interval by its minimum and | 80 // A range type represents a continuous integer interval by its minimum and |
| 53 // maximum value. Either value may be an infinity, in which case that infinity | 81 // maximum value. Either value may be an infinity, in which case that infinity |
| 54 // itself is also included in the range. A range never contains NaN or -0. | 82 // itself is also included in the range. A range never contains NaN or -0. |
| 55 // | 83 // |
| 56 // If a value v happens to be an integer n, then Constant(v) is considered a | 84 // If a value v happens to be an integer n, then Constant(v) is considered a |
| 57 // subtype of Range(n, n) (and therefore also a subtype of any larger range). | 85 // subtype of Range(n, n) (and therefore also a subtype of any larger range). |
| 58 // In order to avoid large unions, however, it is usually a good idea to use | 86 // In order to avoid large unions, however, it is usually a good idea to use |
| 59 // Range rather than Constant. | 87 // Range rather than Constant. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 90 // See test/cctest/test-types.cc for a comprehensive executable specification, | 118 // See test/cctest/test-types.cc for a comprehensive executable specification, |
| 91 // especially with respect to the properties of the more exotic 'temporal' | 119 // especially with respect to the properties of the more exotic 'temporal' |
| 92 // constructors and predicates (those prefixed 'Now'). | 120 // constructors and predicates (those prefixed 'Now'). |
| 93 // | 121 // |
| 94 // | 122 // |
| 95 // IMPLEMENTATION | 123 // IMPLEMENTATION |
| 96 // | 124 // |
| 97 // Internally, all 'primitive' types, and their unions, are represented as | 125 // Internally, all 'primitive' types, and their unions, are represented as |
| 98 // bitsets. Bit 0 is reserved for tagging. Only structured types require | 126 // bitsets. Bit 0 is reserved for tagging. Only structured types require |
| 99 // allocation. | 127 // allocation. |
| 128 // Note that the bitset representation is closed under both Union and Intersect. |
| 100 | 129 |
| 101 // ----------------------------------------------------------------------------- | 130 // ----------------------------------------------------------------------------- |
| 102 // Values for bitset types | 131 // Values for bitset types |
| 103 | 132 |
| 104 // clang-format off | 133 // clang-format off |
| 105 | 134 |
| 106 #define MASK_BITSET_TYPE_LIST(V) \ | 135 #define MASK_BITSET_TYPE_LIST(V) \ |
| 107 V(Semantic, 0xfffffffeu) | 136 V(Representation, 0xffc00000u) \ |
| 137 V(Semantic, 0x003ffffeu) |
| 108 | 138 |
| 139 #define REPRESENTATION(k) ((k) & BitsetType::kRepresentation) |
| 109 #define SEMANTIC(k) ((k) & BitsetType::kSemantic) | 140 #define SEMANTIC(k) ((k) & BitsetType::kSemantic) |
| 110 | 141 |
| 142 #define REPRESENTATION_BITSET_TYPE_LIST(V) \ |
| 143 V(None, 0) \ |
| 144 V(UntaggedBit, 1u << 22 | kSemantic) \ |
| 145 V(UntaggedIntegral8, 1u << 23 | kSemantic) \ |
| 146 V(UntaggedIntegral16, 1u << 24 | kSemantic) \ |
| 147 V(UntaggedIntegral32, 1u << 25 | kSemantic) \ |
| 148 V(UntaggedFloat32, 1u << 26 | kSemantic) \ |
| 149 V(UntaggedFloat64, 1u << 27 | kSemantic) \ |
| 150 V(UntaggedSimd128, 1u << 28 | kSemantic) \ |
| 151 V(UntaggedPointer, 1u << 29 | kSemantic) \ |
| 152 V(TaggedSigned, 1u << 30 | kSemantic) \ |
| 153 V(TaggedPointer, 1u << 31 | kSemantic) \ |
| 154 \ |
| 155 V(UntaggedIntegral, kUntaggedBit | kUntaggedIntegral8 | \ |
| 156 kUntaggedIntegral16 | kUntaggedIntegral32) \ |
| 157 V(UntaggedFloat, kUntaggedFloat32 | kUntaggedFloat64) \ |
| 158 V(UntaggedNumber, kUntaggedIntegral | kUntaggedFloat) \ |
| 159 V(Untagged, kUntaggedNumber | kUntaggedPointer) \ |
| 160 V(Tagged, kTaggedSigned | kTaggedPointer) |
| 161 |
| 111 #define INTERNAL_BITSET_TYPE_LIST(V) \ | 162 #define INTERNAL_BITSET_TYPE_LIST(V) \ |
| 112 V(OtherUnsigned31, 1u << 1) \ | 163 V(OtherUnsigned31, 1u << 1 | REPRESENTATION(kTagged | kUntaggedNumber)) \ |
| 113 V(OtherUnsigned32, 1u << 2) \ | 164 V(OtherUnsigned32, 1u << 2 | REPRESENTATION(kTagged | kUntaggedNumber)) \ |
| 114 V(OtherSigned32, 1u << 3) \ | 165 V(OtherSigned32, 1u << 3 | REPRESENTATION(kTagged | kUntaggedNumber)) \ |
| 115 V(OtherNumber, 1u << 4) \ | 166 V(OtherNumber, 1u << 4 | REPRESENTATION(kTagged | kUntaggedNumber)) |
| 116 | 167 |
| 117 #define SEMANTIC_BITSET_TYPE_LIST(V) \ | 168 #define SEMANTIC_BITSET_TYPE_LIST(V) \ |
| 118 V(None, 0u) \ | 169 V(Negative31, 1u << 5 | REPRESENTATION(kTagged | kUntaggedNumber)) \ |
| 119 V(Negative31, 1u << 5) \ | 170 V(Null, 1u << 6 | REPRESENTATION(kTaggedPointer)) \ |
| 120 V(Null, 1u << 6) \ | 171 V(Undefined, 1u << 7 | REPRESENTATION(kTaggedPointer)) \ |
| 121 V(Undefined, 1u << 7) \ | 172 V(Boolean, 1u << 8 | REPRESENTATION(kTaggedPointer)) \ |
| 122 V(Boolean, 1u << 8) \ | 173 V(Unsigned30, 1u << 9 | REPRESENTATION(kTagged | kUntaggedNumber)) \ |
| 123 V(Unsigned30, 1u << 9) \ | 174 V(MinusZero, 1u << 10 | REPRESENTATION(kTagged | kUntaggedNumber)) \ |
| 124 V(MinusZero, 1u << 10) \ | 175 V(NaN, 1u << 11 | REPRESENTATION(kTagged | kUntaggedNumber)) \ |
| 125 V(NaN, 1u << 11) \ | 176 V(Symbol, 1u << 12 | REPRESENTATION(kTaggedPointer)) \ |
| 126 V(Symbol, 1u << 12) \ | 177 V(InternalizedString, 1u << 13 | REPRESENTATION(kTaggedPointer)) \ |
| 127 V(InternalizedString, 1u << 13) \ | 178 V(OtherString, 1u << 14 | REPRESENTATION(kTaggedPointer)) \ |
| 128 V(OtherString, 1u << 14) \ | 179 V(Simd, 1u << 15 | REPRESENTATION(kTaggedPointer)) \ |
| 129 V(Simd, 1u << 15) \ | 180 V(OtherObject, 1u << 17 | REPRESENTATION(kTaggedPointer)) \ |
| 130 V(OtherObject, 1u << 17) \ | 181 V(OtherUndetectable, 1u << 16 | REPRESENTATION(kTaggedPointer)) \ |
| 131 V(OtherUndetectable, 1u << 16) \ | 182 V(Proxy, 1u << 18 | REPRESENTATION(kTaggedPointer)) \ |
| 132 V(Proxy, 1u << 18) \ | 183 V(Function, 1u << 19 | REPRESENTATION(kTaggedPointer)) \ |
| 133 V(Function, 1u << 19) \ | 184 V(Hole, 1u << 20 | REPRESENTATION(kTaggedPointer)) \ |
| 134 V(Hole, 1u << 20) \ | 185 V(OtherInternal, 1u << 21 | REPRESENTATION(kTagged | kUntagged)) \ |
| 135 V(OtherInternal, 1u << 21) \ | |
| 136 \ | 186 \ |
| 137 V(Signed31, kUnsigned30 | kNegative31) \ | 187 V(Signed31, kUnsigned30 | kNegative31) \ |
| 138 V(Signed32, kSigned31 | kOtherUnsigned31 | kOtherSigned32) \ | 188 V(Signed32, kSigned31 | kOtherUnsigned31 | kOtherSigned32) \ |
| 139 V(Signed32OrMinusZero, kSigned32 | kMinusZero) \ | 189 V(Signed32OrMinusZero, kSigned32 | kMinusZero) \ |
| 140 V(Signed32OrMinusZeroOrNaN, kSigned32 | kMinusZero | kNaN) \ | 190 V(Signed32OrMinusZeroOrNaN, kSigned32 | kMinusZero | kNaN) \ |
| 141 V(Negative32, kNegative31 | kOtherSigned32) \ | 191 V(Negative32, kNegative31 | kOtherSigned32) \ |
| 142 V(Unsigned31, kUnsigned30 | kOtherUnsigned31) \ | 192 V(Unsigned31, kUnsigned30 | kOtherUnsigned31) \ |
| 143 V(Unsigned32, kUnsigned30 | kOtherUnsigned31 | \ | 193 V(Unsigned32, kUnsigned30 | kOtherUnsigned31 | \ |
| 144 kOtherUnsigned32) \ | 194 kOtherUnsigned32) \ |
| 145 V(Unsigned32OrMinusZero, kUnsigned32 | kMinusZero) \ | 195 V(Unsigned32OrMinusZero, kUnsigned32 | kMinusZero) \ |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 * -2^31 -2^30 0 2^30 2^31 2^32 | 236 * -2^31 -2^30 0 2^30 2^31 2^32 |
| 187 * | 237 * |
| 188 * E.g., OtherUnsigned32 (OU32) covers all integers from 2^31 to 2^32-1. | 238 * E.g., OtherUnsigned32 (OU32) covers all integers from 2^31 to 2^32-1. |
| 189 * | 239 * |
| 190 * Some of the atomic numerical bitsets are internal only (see | 240 * Some of the atomic numerical bitsets are internal only (see |
| 191 * INTERNAL_BITSET_TYPE_LIST). To a types user, they should only occur in | 241 * INTERNAL_BITSET_TYPE_LIST). To a types user, they should only occur in |
| 192 * union with certain other bitsets. For instance, OtherNumber should only | 242 * union with certain other bitsets. For instance, OtherNumber should only |
| 193 * occur as part of PlainNumber. | 243 * occur as part of PlainNumber. |
| 194 */ | 244 */ |
| 195 | 245 |
| 196 #define PROPER_BITSET_TYPE_LIST(V) SEMANTIC_BITSET_TYPE_LIST(V) | 246 #define PROPER_BITSET_TYPE_LIST(V) \ |
| 247 REPRESENTATION_BITSET_TYPE_LIST(V) \ |
| 248 SEMANTIC_BITSET_TYPE_LIST(V) |
| 197 | 249 |
| 198 #define BITSET_TYPE_LIST(V) \ | 250 #define BITSET_TYPE_LIST(V) \ |
| 199 MASK_BITSET_TYPE_LIST(V) \ | 251 MASK_BITSET_TYPE_LIST(V) \ |
| 200 INTERNAL_BITSET_TYPE_LIST(V) \ | 252 REPRESENTATION_BITSET_TYPE_LIST(V) \ |
| 253 INTERNAL_BITSET_TYPE_LIST(V) \ |
| 201 SEMANTIC_BITSET_TYPE_LIST(V) | 254 SEMANTIC_BITSET_TYPE_LIST(V) |
| 202 | 255 |
| 203 class Type; | 256 class Type; |
| 204 | 257 |
| 205 // ----------------------------------------------------------------------------- | 258 // ----------------------------------------------------------------------------- |
| 206 // Bitset types (internal). | 259 // Bitset types (internal). |
| 207 | 260 |
| 208 class BitsetType { | 261 class BitsetType { |
| 209 public: | 262 public: |
| 210 typedef uint32_t bitset; // Internal | 263 typedef uint32_t bitset; // Internal |
| 211 | 264 |
| 212 enum : uint32_t { | 265 enum : uint32_t { |
| 213 #define DECLARE_TYPE(type, value) k##type = (value), | 266 #define DECLARE_TYPE(type, value) k##type = (value), |
| 214 BITSET_TYPE_LIST(DECLARE_TYPE) | 267 BITSET_TYPE_LIST(DECLARE_TYPE) |
| 215 #undef DECLARE_TYPE | 268 #undef DECLARE_TYPE |
| 216 kUnusedEOL = 0 | 269 kUnusedEOL = 0 |
| 217 }; | 270 }; |
| 218 | 271 |
| 219 static bitset SignedSmall(); | 272 static bitset SignedSmall(); |
| 220 static bitset UnsignedSmall(); | 273 static bitset UnsignedSmall(); |
| 221 | 274 |
| 222 bitset Bitset() { | 275 bitset Bitset() { |
| 223 return static_cast<bitset>(reinterpret_cast<uintptr_t>(this) ^ 1u); | 276 return static_cast<bitset>(reinterpret_cast<uintptr_t>(this) ^ 1u); |
| 224 } | 277 } |
| 225 | 278 |
| 226 static bool IsInhabited(bitset bits) { return SemanticIsInhabited(bits); } | 279 static bool IsInhabited(bitset bits) { |
| 280 return SEMANTIC(bits) != kNone && REPRESENTATION(bits) != kNone; |
| 281 } |
| 227 | 282 |
| 228 static bool SemanticIsInhabited(bitset bits) { | 283 static bool SemanticIsInhabited(bitset bits) { |
| 229 return SEMANTIC(bits) != kNone; | 284 return SEMANTIC(bits) != kNone; |
| 230 } | 285 } |
| 231 | 286 |
| 232 static bool Is(bitset bits1, bitset bits2) { | 287 static bool Is(bitset bits1, bitset bits2) { |
| 233 return (bits1 | bits2) == bits2; | 288 return (bits1 | bits2) == bits2; |
| 234 } | 289 } |
| 235 | 290 |
| 236 static double Min(bitset); | 291 static double Min(bitset); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 | 382 |
| 328 ConstantType(BitsetType::bitset bitset, i::Handle<i::Object> object) | 383 ConstantType(BitsetType::bitset bitset, i::Handle<i::Object> object) |
| 329 : TypeBase(kConstant), bitset_(bitset), object_(object) {} | 384 : TypeBase(kConstant), bitset_(bitset), object_(object) {} |
| 330 | 385 |
| 331 BitsetType::bitset Lub() { return bitset_; } | 386 BitsetType::bitset Lub() { return bitset_; } |
| 332 | 387 |
| 333 BitsetType::bitset bitset_; | 388 BitsetType::bitset bitset_; |
| 334 Handle<i::Object> object_; | 389 Handle<i::Object> object_; |
| 335 }; | 390 }; |
| 336 // TODO(neis): Also cache value if numerical. | 391 // TODO(neis): Also cache value if numerical. |
| 392 // TODO(neis): Allow restricting the representation. |
| 337 | 393 |
| 338 // ----------------------------------------------------------------------------- | 394 // ----------------------------------------------------------------------------- |
| 339 // Range types. | 395 // Range types. |
| 340 | 396 |
| 341 class RangeType : public TypeBase { | 397 class RangeType : public TypeBase { |
| 342 public: | 398 public: |
| 343 struct Limits { | 399 struct Limits { |
| 344 double min; | 400 double min; |
| 345 double max; | 401 double max; |
| 346 Limits(double min, double max) : min(min), max(max) {} | 402 Limits(double min, double max) : min(min), max(max) {} |
| 347 explicit Limits(RangeType* range) : min(range->Min()), max(range->Max()) {} | 403 explicit Limits(RangeType* range) : min(range->Min()), max(range->Max()) {} |
| 348 bool IsEmpty(); | 404 bool IsEmpty(); |
| 349 static Limits Empty() { return Limits(1, 0); } | 405 static Limits Empty() { return Limits(1, 0); } |
| 350 static Limits Intersect(Limits lhs, Limits rhs); | 406 static Limits Intersect(Limits lhs, Limits rhs); |
| 351 static Limits Union(Limits lhs, Limits rhs); | 407 static Limits Union(Limits lhs, Limits rhs); |
| 352 }; | 408 }; |
| 353 | 409 |
| 354 double Min() { return limits_.min; } | 410 double Min() { return limits_.min; } |
| 355 double Max() { return limits_.max; } | 411 double Max() { return limits_.max; } |
| 356 | 412 |
| 357 private: | 413 private: |
| 358 friend class Type; | 414 friend class Type; |
| 359 friend class BitsetType; | 415 friend class BitsetType; |
| 360 friend class UnionType; | 416 friend class UnionType; |
| 361 | 417 |
| 362 static Type* New(double min, double max, Zone* zone) { | 418 static Type* New(double min, double max, BitsetType::bitset representation, |
| 363 return New(Limits(min, max), zone); | 419 Zone* zone) { |
| 420 return New(Limits(min, max), representation, zone); |
| 364 } | 421 } |
| 365 | 422 |
| 366 static bool IsInteger(double x) { | 423 static bool IsInteger(double x) { |
| 367 return nearbyint(x) == x && !i::IsMinusZero(x); // Allows for infinities. | 424 return nearbyint(x) == x && !i::IsMinusZero(x); // Allows for infinities. |
| 368 } | 425 } |
| 369 | 426 |
| 370 static Type* New(Limits lim, Zone* zone) { | 427 static Type* New(Limits lim, BitsetType::bitset representation, Zone* zone) { |
| 371 DCHECK(IsInteger(lim.min) && IsInteger(lim.max)); | 428 DCHECK(IsInteger(lim.min) && IsInteger(lim.max)); |
| 372 DCHECK(lim.min <= lim.max); | 429 DCHECK(lim.min <= lim.max); |
| 373 BitsetType::bitset bits = SEMANTIC(BitsetType::Lub(lim.min, lim.max)); | 430 DCHECK(REPRESENTATION(representation) == representation); |
| 431 BitsetType::bitset bits = |
| 432 SEMANTIC(BitsetType::Lub(lim.min, lim.max)) | representation; |
| 374 | 433 |
| 375 return AsType(new (zone->New(sizeof(RangeType))) RangeType(bits, lim)); | 434 return AsType(new (zone->New(sizeof(RangeType))) RangeType(bits, lim)); |
| 376 } | 435 } |
| 377 | 436 |
| 378 static RangeType* cast(Type* type) { | 437 static RangeType* cast(Type* type) { |
| 379 DCHECK(IsKind(type, kRange)); | 438 DCHECK(IsKind(type, kRange)); |
| 380 return static_cast<RangeType*>(FromType(type)); | 439 return static_cast<RangeType*>(FromType(type)); |
| 381 } | 440 } |
| 382 | 441 |
| 383 RangeType(BitsetType::bitset bitset, Limits limits) | 442 RangeType(BitsetType::bitset bitset, Limits limits) |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 return BitsetType::New(BitsetType::SignedSmall()); | 549 return BitsetType::New(BitsetType::SignedSmall()); |
| 491 } | 550 } |
| 492 static Type* UnsignedSmall() { | 551 static Type* UnsignedSmall() { |
| 493 return BitsetType::New(BitsetType::UnsignedSmall()); | 552 return BitsetType::New(BitsetType::UnsignedSmall()); |
| 494 } | 553 } |
| 495 | 554 |
| 496 static Type* Constant(i::Handle<i::Object> value, Zone* zone) { | 555 static Type* Constant(i::Handle<i::Object> value, Zone* zone) { |
| 497 return ConstantType::New(value, zone); | 556 return ConstantType::New(value, zone); |
| 498 } | 557 } |
| 499 static Type* Range(double min, double max, Zone* zone) { | 558 static Type* Range(double min, double max, Zone* zone) { |
| 500 return RangeType::New(min, max, zone); | 559 return RangeType::New(min, max, REPRESENTATION(BitsetType::kTagged | |
| 560 BitsetType::kUntaggedNumber), |
| 561 zone); |
| 501 } | 562 } |
| 502 static Type* Tuple(Type* first, Type* second, Type* third, Zone* zone) { | 563 static Type* Tuple(Type* first, Type* second, Type* third, Zone* zone) { |
| 503 Type* tuple = TupleType::New(3, zone); | 564 Type* tuple = TupleType::New(3, zone); |
| 504 tuple->AsTuple()->InitElement(0, first); | 565 tuple->AsTuple()->InitElement(0, first); |
| 505 tuple->AsTuple()->InitElement(1, second); | 566 tuple->AsTuple()->InitElement(1, second); |
| 506 tuple->AsTuple()->InitElement(2, third); | 567 tuple->AsTuple()->InitElement(2, third); |
| 507 return tuple; | 568 return tuple; |
| 508 } | 569 } |
| 509 | 570 |
| 510 static Type* Union(Type* type1, Type* type2, Zone* zone); | 571 static Type* Union(Type* type1, Type* type2, Zone* zone); |
| 511 static Type* Intersect(Type* type1, Type* type2, Zone* zone); | 572 static Type* Intersect(Type* type1, Type* type2, Zone* zone); |
| 512 | 573 |
| 513 static Type* Of(double value, Zone* zone) { | 574 static Type* Of(double value, Zone* zone) { |
| 514 return BitsetType::New(BitsetType::ExpandInternals(BitsetType::Lub(value))); | 575 return BitsetType::New(BitsetType::ExpandInternals(BitsetType::Lub(value))); |
| 515 } | 576 } |
| 516 static Type* Of(i::Object* value, Zone* zone) { | 577 static Type* Of(i::Object* value, Zone* zone) { |
| 517 return BitsetType::New(BitsetType::ExpandInternals(BitsetType::Lub(value))); | 578 return BitsetType::New(BitsetType::ExpandInternals(BitsetType::Lub(value))); |
| 518 } | 579 } |
| 519 static Type* Of(i::Handle<i::Object> value, Zone* zone) { | 580 static Type* Of(i::Handle<i::Object> value, Zone* zone) { |
| 520 return Of(*value, zone); | 581 return Of(*value, zone); |
| 521 } | 582 } |
| 522 | 583 |
| 523 static Type* For(i::Map* map) { | 584 static Type* For(i::Map* map) { |
| 524 return BitsetType::New(BitsetType::ExpandInternals(BitsetType::Lub(map))); | 585 return BitsetType::New(BitsetType::ExpandInternals(BitsetType::Lub(map))); |
| 525 } | 586 } |
| 526 static Type* For(i::Handle<i::Map> map) { return For(*map); } | 587 static Type* For(i::Handle<i::Map> map) { return For(*map); } |
| 527 | 588 |
| 528 // Extraction of components. | 589 // Extraction of components. |
| 590 static Type* Representation(Type* t, Zone* zone); |
| 529 static Type* Semantic(Type* t, Zone* zone); | 591 static Type* Semantic(Type* t, Zone* zone); |
| 530 | 592 |
| 531 // Predicates. | 593 // Predicates. |
| 532 bool IsInhabited() { return BitsetType::IsInhabited(this->BitsetLub()); } | 594 bool IsInhabited() { return BitsetType::IsInhabited(this->BitsetLub()); } |
| 533 | 595 |
| 534 bool Is(Type* that) { return this == that || this->SlowIs(that); } | 596 bool Is(Type* that) { return this == that || this->SlowIs(that); } |
| 535 bool Maybe(Type* that); | 597 bool Maybe(Type* that); |
| 536 bool Equals(Type* that) { return this->Is(that) && that->Is(this); } | 598 bool Equals(Type* that) { return this->Is(that) && that->Is(this); } |
| 537 | 599 |
| 538 // Equivalent to Constant(val)->Is(this), but avoiding allocation. | 600 // Equivalent to Constant(val)->Is(this), but avoiding allocation. |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 int index_; | 648 int index_; |
| 587 }; | 649 }; |
| 588 | 650 |
| 589 Iterator<i::Object> Constants() { | 651 Iterator<i::Object> Constants() { |
| 590 if (this->IsBitset()) return Iterator<i::Object>(); | 652 if (this->IsBitset()) return Iterator<i::Object>(); |
| 591 return Iterator<i::Object>(this); | 653 return Iterator<i::Object>(this); |
| 592 } | 654 } |
| 593 | 655 |
| 594 // Printing. | 656 // Printing. |
| 595 | 657 |
| 596 void PrintTo(std::ostream& os); | 658 enum PrintDimension { BOTH_DIMS, SEMANTIC_DIM, REPRESENTATION_DIM }; |
| 659 |
| 660 void PrintTo(std::ostream& os, PrintDimension dim = BOTH_DIMS); // NOLINT |
| 597 | 661 |
| 598 #ifdef DEBUG | 662 #ifdef DEBUG |
| 599 void Print(); | 663 void Print(); |
| 600 #endif | 664 #endif |
| 601 | 665 |
| 602 // Helpers for testing. | 666 // Helpers for testing. |
| 603 bool IsBitsetForTesting() { return IsBitset(); } | 667 bool IsBitsetForTesting() { return IsBitset(); } |
| 604 bool IsUnionForTesting() { return IsUnion(); } | 668 bool IsUnionForTesting() { return IsUnion(); } |
| 605 bitset AsBitsetForTesting() { return AsBitset(); } | 669 bitset AsBitsetForTesting() { return AsBitset(); } |
| 606 UnionType* AsUnionForTesting() { return AsUnion(); } | 670 UnionType* AsUnionForTesting() { return AsUnion(); } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 619 bool IsAny() { return this == Any(); } | 683 bool IsAny() { return this == Any(); } |
| 620 bool IsBitset() { return BitsetType::IsBitset(this); } | 684 bool IsBitset() { return BitsetType::IsBitset(this); } |
| 621 bool IsUnion() { return IsKind(TypeBase::kUnion); } | 685 bool IsUnion() { return IsKind(TypeBase::kUnion); } |
| 622 | 686 |
| 623 bitset AsBitset() { | 687 bitset AsBitset() { |
| 624 DCHECK(this->IsBitset()); | 688 DCHECK(this->IsBitset()); |
| 625 return reinterpret_cast<BitsetType*>(this)->Bitset(); | 689 return reinterpret_cast<BitsetType*>(this)->Bitset(); |
| 626 } | 690 } |
| 627 UnionType* AsUnion() { return UnionType::cast(this); } | 691 UnionType* AsUnion() { return UnionType::cast(this); } |
| 628 | 692 |
| 693 bitset Representation(); |
| 694 |
| 629 // Auxiliary functions. | 695 // Auxiliary functions. |
| 630 bool SemanticMaybe(Type* that); | 696 bool SemanticMaybe(Type* that); |
| 631 | 697 |
| 632 bitset BitsetGlb() { return BitsetType::Glb(this); } | 698 bitset BitsetGlb() { return BitsetType::Glb(this); } |
| 633 bitset BitsetLub() { return BitsetType::Lub(this); } | 699 bitset BitsetLub() { return BitsetType::Lub(this); } |
| 634 | 700 |
| 635 bool SlowIs(Type* that); | 701 bool SlowIs(Type* that); |
| 636 bool SemanticIs(Type* that); | 702 bool SemanticIs(Type* that); |
| 637 | 703 |
| 638 static bool Overlap(RangeType* lhs, RangeType* rhs); | 704 static bool Overlap(RangeType* lhs, RangeType* rhs); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 653 RangeType::Limits* limits, Zone* zone); | 719 RangeType::Limits* limits, Zone* zone); |
| 654 static Type* NormalizeUnion(Type* unioned, int size, Zone* zone); | 720 static Type* NormalizeUnion(Type* unioned, int size, Zone* zone); |
| 655 static Type* NormalizeRangeAndBitset(Type* range, bitset* bits, Zone* zone); | 721 static Type* NormalizeRangeAndBitset(Type* range, bitset* bits, Zone* zone); |
| 656 }; | 722 }; |
| 657 | 723 |
| 658 } // namespace compiler | 724 } // namespace compiler |
| 659 } // namespace internal | 725 } // namespace internal |
| 660 } // namespace v8 | 726 } // namespace v8 |
| 661 | 727 |
| 662 #endif // V8_COMPILER_TYPES_H_ | 728 #endif // V8_COMPILER_TYPES_H_ |
| OLD | NEW |