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