5 #ifndef V8_COMPILER_TYPE_CACHE_H_ 6 #define V8_COMPILER_TYPE_CACHE_H_ 8 #include "src/compiler/types.h" 10 #include "src/objects/code.h" 11 #include "src/objects/js-array-buffer.h" 12 #include "src/objects/string.h" 27 TypeCache() : zone_(&allocator, ZONE_NAME) {}
29 Type const kInt8 = CreateRange<int8_t>();
30 Type const kUint8 = CreateRange<uint8_t>();
31 Type const kUint8Clamped = kUint8;
32 Type const kUint8OrMinusZeroOrNaN =
33 Type::Union(kUint8, Type::MinusZeroOrNaN(), zone());
34 Type const kInt16 = CreateRange<int16_t>();
35 Type const kUint16 = CreateRange<uint16_t>();
36 Type const kInt32 = Type::Signed32();
37 Type const kUint32 = Type::Unsigned32();
38 Type const kInt64 = CreateRange<int64_t>();
39 Type const kUint64 = CreateRange<uint64_t>();
40 Type const kFloat32 = Type::Number();
41 Type const kFloat64 = Type::Number();
42 Type const kBigInt64 = Type::BigInt();
43 Type const kBigUint64 = Type::BigInt();
45 Type const kHoleySmi = Type::Union(Type::SignedSmall(), Type::Hole(), zone());
47 Type const kSingletonZero = CreateRange(0.0, 0.0);
48 Type const kSingletonOne = CreateRange(1.0, 1.0);
49 Type const kSingletonTen = CreateRange(10.0, 10.0);
50 Type const kSingletonMinusOne = CreateRange(-1.0, -1.0);
51 Type const kZeroOrMinusZero =
52 Type::Union(kSingletonZero, Type::MinusZero(), zone());
53 Type const kZeroOrUndefined =
54 Type::Union(kSingletonZero, Type::Undefined(), zone());
55 Type const kTenOrUndefined =
56 Type::Union(kSingletonTen, Type::Undefined(), zone());
57 Type const kMinusOneOrZero = CreateRange(-1.0, 0.0);
58 Type const kMinusOneToOneOrMinusZeroOrNaN = Type::Union(
59 Type::Union(CreateRange(-1.0, 1.0), Type::MinusZero(), zone()),
61 Type const kZeroOrOne = CreateRange(0.0, 1.0);
62 Type const kZeroOrOneOrNaN = Type::Union(kZeroOrOne, Type::NaN(), zone());
63 Type const kZeroToThirtyOne = CreateRange(0.0, 31.0);
64 Type const kZeroToThirtyTwo = CreateRange(0.0, 32.0);
66 Type::Union(kSingletonZero, Type::MinusZeroOrNaN(), zone());
67 Type const kInteger = CreateRange(-V8_INFINITY, V8_INFINITY);
68 Type const kIntegerOrMinusZero =
69 Type::Union(kInteger, Type::MinusZero(), zone());
70 Type const kIntegerOrMinusZeroOrNaN =
71 Type::Union(kIntegerOrMinusZero, Type::NaN(), zone());
72 Type const kPositiveInteger = CreateRange(0.0, V8_INFINITY);
73 Type const kPositiveIntegerOrMinusZero =
74 Type::Union(kPositiveInteger, Type::MinusZero(), zone());
75 Type const kPositiveIntegerOrNaN =
76 Type::Union(kPositiveInteger, Type::NaN(), zone());
77 Type const kPositiveIntegerOrMinusZeroOrNaN =
78 Type::Union(kPositiveIntegerOrMinusZero, Type::NaN(), zone());
80 Type const kAdditiveSafeInteger =
81 CreateRange(-4503599627370496.0, 4503599627370496.0);
82 Type const kSafeInteger = CreateRange(-kMaxSafeInteger, kMaxSafeInteger);
83 Type const kAdditiveSafeIntegerOrMinusZero =
84 Type::Union(kAdditiveSafeInteger, Type::MinusZero(), zone());
85 Type const kSafeIntegerOrMinusZero =
86 Type::Union(kSafeInteger, Type::MinusZero(), zone());
87 Type const kPositiveSafeInteger = CreateRange(0.0, kMaxSafeInteger);
91 Type const kFixedArrayLengthType = CreateRange(0.0, FixedArray::kMaxLength);
95 Type const kFixedDoubleArrayLengthType =
96 CreateRange(0.0, FixedDoubleArray::kMaxLength);
100 Type const kJSArrayLengthType = Type::Unsigned32();
105 Type const kJSArrayBufferByteLengthType =
106 CreateRange(0.0, JSArrayBuffer::kMaxByteLength);
110 Type const kJSArrayBufferViewByteLengthType = kJSArrayBufferByteLengthType;
114 Type const kJSArrayBufferViewByteOffsetType = kJSArrayBufferByteLengthType;
118 Type const kJSTypedArrayLengthType = Type::UnsignedSmall();
122 Type const kStringLengthType = CreateRange(0.0, String::kMaxLength);
126 Type const kTimeValueType =
127 CreateRange(-DateCache::kMaxTimeInMs, DateCache::kMaxTimeInMs);
131 Type const kJSDateDayType =
132 Type::Union(CreateRange(1, 31.0), Type::NaN(), zone());
136 Type const kJSDateHourType =
137 Type::Union(CreateRange(0, 23.0), Type::NaN(), zone());
141 Type const kJSDateMinuteType =
142 Type::Union(CreateRange(0, 59.0), Type::NaN(), zone());
146 Type const kJSDateMonthType =
147 Type::Union(CreateRange(0, 11.0), Type::NaN(), zone());
151 Type const kJSDateSecondType = kJSDateMinuteType;
155 Type const kJSDateValueType =
156 Type::Union(kTimeValueType, Type::NaN(), zone());
160 Type const kJSDateWeekdayType =
161 Type::Union(CreateRange(0, 6.0), Type::NaN(), zone());
165 Type const kJSDateYearType =
166 Type::Union(Type::SignedSmall(), Type::NaN(), zone());
169 Type const kArgumentsLengthType = Type::Unsigned30();
173 Type const kJSArrayIteratorKindType = CreateRange(0.0, 2.0);
176 template <
typename T>
178 return CreateRange(std::numeric_limits<T>::min(),
179 std::numeric_limits<T>::max());
182 Type CreateRange(
double min,
double max) {
183 return Type::Range(min, max, zone());
186 Zone* zone() {
return &zone_; }
193 #endif // V8_COMPILER_TYPE_CACHE_H_