5#ifndef V8_COMPILER_TURBOFAN_TYPES_H_
6#define V8_COMPILER_TURBOFAN_TYPES_H_
16#ifdef V8_ENABLE_WEBASSEMBLY
106#define INTERNAL_BITSET_TYPE_LIST(V) \
107 V(OtherUnsigned31, uint64_t{1} << 1) \
108 V(OtherUnsigned32, uint64_t{1} << 2) \
109 V(OtherSigned32, uint64_t{1} << 3) \
110 V(OtherNumber, uint64_t{1} << 4) \
111 V(OtherString, uint64_t{1} << 5) \
113#define PROPER_ATOMIC_BITSET_TYPE_LOW_LIST(V) \
114 V(Negative31, uint64_t{1} << 6) \
115 V(Null, uint64_t{1} << 7) \
116 V(Undefined, uint64_t{1} << 8) \
117 V(Boolean, uint64_t{1} << 9) \
118 V(Unsigned30, uint64_t{1} << 10) \
119 V(MinusZero, uint64_t{1} << 11) \
120 V(NaN, uint64_t{1} << 12) \
121 V(Symbol, uint64_t{1} << 13) \
122 V(InternalizedString, uint64_t{1} << 14) \
123 V(OtherCallable, uint64_t{1} << 15) \
124 V(OtherObject, uint64_t{1} << 16) \
125 V(OtherUndetectable, uint64_t{1} << 17) \
126 V(CallableProxy, uint64_t{1} << 18) \
127 V(OtherProxy, uint64_t{1} << 19) \
128 V(CallableFunction, uint64_t{1} << 20) \
129 V(ClassConstructor, uint64_t{1} << 21) \
130 V(BoundFunction, uint64_t{1} << 22) \
131 V(OtherInternal, uint64_t{1} << 23) \
132 V(ExternalPointer, uint64_t{1} << 24) \
133 V(Array, uint64_t{1} << 25) \
134 V(UnsignedBigInt63, uint64_t{1} << 26) \
135 V(OtherUnsignedBigInt64, uint64_t{1} << 27) \
136 V(NegativeBigInt63, uint64_t{1} << 28) \
137 V(OtherBigInt, uint64_t{1} << 29) \
138 V(WasmObject, uint64_t{1} << 30) \
139 V(SandboxedPointer, uint64_t{1} << 31)
143#define PROPER_ATOMIC_BITSET_TYPE_HIGH_LIST(V) \
144 V(Machine, uint64_t{1} << 32) \
145 V(Hole, uint64_t{1} << 33) \
146 V(StringWrapper, uint64_t{1} << 34) \
147 V(TypedArray, uint64_t{1} << 35)
149#define PROPER_BITSET_TYPE_LIST(V) \
150 V(None, uint64_t{0}) \
151 PROPER_ATOMIC_BITSET_TYPE_LOW_LIST(V) \
152 PROPER_ATOMIC_BITSET_TYPE_HIGH_LIST(V) \
153 V(Signed31, kUnsigned30 | kNegative31) \
154 V(Signed32, kSigned31 | kOtherUnsigned31 | \
156 V(Signed32OrMinusZero, kSigned32 | kMinusZero) \
157 V(Signed32OrMinusZeroOrNaN, kSigned32 | kMinusZero | kNaN) \
158 V(Negative32, kNegative31 | kOtherSigned32) \
159 V(Unsigned31, kUnsigned30 | kOtherUnsigned31) \
160 V(Unsigned32, kUnsigned30 | kOtherUnsigned31 | \
162 V(Unsigned32OrMinusZero, kUnsigned32 | kMinusZero) \
163 V(Unsigned32OrMinusZeroOrNaN, kUnsigned32 | kMinusZero | kNaN) \
164 V(Integral32, kSigned32 | kUnsigned32) \
165 V(Integral32OrMinusZero, kIntegral32 | kMinusZero) \
166 V(Integral32OrMinusZeroOrNaN, kIntegral32OrMinusZero | kNaN) \
167 V(PlainNumber, kIntegral32 | kOtherNumber) \
168 V(OrderedNumber, kPlainNumber | kMinusZero) \
169 V(MinusZeroOrNaN, kMinusZero | kNaN) \
170 V(Number, kOrderedNumber | kNaN) \
171 V(SignedBigInt64, kUnsignedBigInt63 | kNegativeBigInt63) \
172 V(UnsignedBigInt64, kUnsignedBigInt63 | kOtherUnsignedBigInt64) \
173 V(BigInt, kSignedBigInt64 | kOtherUnsignedBigInt64 | \
175 V(Numeric, kNumber | kBigInt) \
176 V(String, kInternalizedString | kOtherString) \
177 V(StringOrStringWrapper, kString | kStringWrapper) \
178 V(UniqueName, kSymbol | kInternalizedString) \
179 V(Name, kSymbol | kString) \
180 V(InternalizedStringOrNull, kInternalizedString | kNull) \
181 V(BooleanOrNumber, kBoolean | kNumber) \
182 V(BooleanOrNullOrNumber, kBooleanOrNumber | kNull) \
183 V(BooleanOrNullOrUndefined, kBoolean | kNull | kUndefined) \
184 V(NullOrNumber, kNull | kNumber) \
185 V(NullOrUndefined, kNull | kUndefined) \
186 V(Undetectable, kNullOrUndefined | kOtherUndetectable) \
187 V(NumberOrHole, kNumber | kHole) \
188 V(NumberOrOddball, kNumber | kBooleanOrNullOrUndefined ) \
189 V(NumberOrOddballOrHole, kNumberOrOddball| kHole ) \
190 V(NumericOrString, kNumeric | kString) \
191 V(NumberOrUndefined, kNumber | kUndefined) \
192 V(PlainPrimitive, kNumber | kString | kBoolean | \
194 V(NonBigIntPrimitive, kSymbol | kPlainPrimitive) \
195 V(Primitive, kBigInt | kNonBigIntPrimitive) \
196 V(OtherUndetectableOrUndefined, kOtherUndetectable | kUndefined) \
197 V(Proxy, kCallableProxy | kOtherProxy) \
198 V(ArrayOrOtherObject, kArray | kOtherObject) \
199 V(ArrayOrProxy, kArray | kProxy) \
200 V(StringWrapperOrOtherObject, kStringWrapper | kOtherObject) \
201 V(Function, kCallableFunction | kClassConstructor) \
202 V(DetectableCallable, kFunction | kBoundFunction | \
203 kOtherCallable | kCallableProxy) \
204 V(Callable, kDetectableCallable | kOtherUndetectable) \
205 V(NonCallable, kArray | kStringWrapper | kTypedArray | \
206 kOtherObject | kOtherProxy | kWasmObject) \
207 V(NonCallableOrNull, kNonCallable | kNull) \
208 V(DetectableObject, kArray | kFunction | kBoundFunction | \
209 kStringWrapper | kTypedArray | kOtherCallable | \
211 V(DetectableReceiver, kDetectableObject | kProxy | kWasmObject) \
212 V(DetectableReceiverOrNull, kDetectableReceiver | kNull) \
213 V(Object, kDetectableObject | kOtherUndetectable) \
214 V(Receiver, kObject | kProxy | kWasmObject) \
215 V(ReceiverOrUndefined, kReceiver | kUndefined) \
216 V(ReceiverOrNull, kReceiver | kNull) \
217 V(ReceiverOrNullOrUndefined, kReceiver | kNull | kUndefined) \
218 V(SymbolOrReceiver, kSymbol | kReceiver) \
219 V(StringOrReceiver, kString | kReceiver) \
220 V(Unique, kBoolean | kUniqueName | kNull | \
221 kUndefined | kHole | kReceiver) \
222 V(Internal, kHole | kExternalPointer | \
223 kSandboxedPointer | kOtherInternal) \
224 V(NonInternal, kPrimitive | kReceiver) \
225 V(NonBigInt, kNonBigIntPrimitive | kReceiver) \
226 V(NonNumber, kBigInt | kUnique | kString | kInternal) \
227 V(Any, uint64_t{0xfffffffffffffffe})
247#define BITSET_TYPE_LIST(V) \
248 INTERNAL_BITSET_TYPE_LIST(V) \
249 PROPER_BITSET_TYPE_LIST(V)
252class HeapConstantType;
253class OtherNumberConstantType;
266#define DECLARE_TYPE(type, value) k##type = (value),
272 static bitset SignedSmall();
273 static bitset UnsignedSmall();
278 return (bits1 | bits2) == bits2;
281 static double Min(bitset);
282 static double Max(bitset);
284 static bitset Glb(
double min,
double max);
286 return Lub<HeapObjectType>(type,
broker);
289 return Lub<MapRef>(map,
broker);
291 static bitset Lub(
double value);
292 static bitset Lub(
double min,
double max);
293 static bitset ExpandInternals(bitset bits);
295 static const char*
Name(bitset);
296 static void Print(std::ostream& os, bitset);
298 static void Print(bitset);
301 static bitset NumberBits(bitset bits);
310 static inline const Boundary* Boundaries();
311 static inline size_t BoundariesSize();
313 template <
typename MapRefLike>
349 Limits(
double min,
double max) : min(min), max(max) {}
351 : min(range->
Min()), max(range->
Max()) {}
392#ifdef V8_ENABLE_WEBASSEMBLY
397 return zone->
New<WasmType>(value_type, module);
400 const wasm::WasmModule* module()
const {
return module_; }
406 explicit WasmType(wasm::ValueType value_type,
const wasm::WasmModule* module)
409 BitsetType::bitset Lub()
const {
411 return BitsetType::kAny;
415 const wasm::WasmModule*
module_;
427#define DEFINE_TYPE_CONSTRUCTOR(type, value) \
428 static Type type() { return NewBitset(BitsetType::k##type); }
430#undef DEFINE_TYPE_CONSTRUCTOR
432 Type() : payload_(uint64_t{0}) {}
447#ifdef V8_ENABLE_WEBASSEMBLY
455 BitsetType::ExpandInternals(BitsetType::Lub(type,
broker)));
460 bool IsInvalid()
const {
return payload_ == uint64_t{0}; }
463 return payload_ == that.payload_ || this->SlowIs(that);
466 bool Equals(
Type that)
const {
return this->
Is(that) && that.Is(*
this); }
469 bool IsBitset()
const {
return payload_ & uint64_t{1}; }
470 bool IsRange()
const {
return IsKind(TypeBase::kRange); }
473 return IsKind(TypeBase::kOtherNumberConstant);
475 bool IsTuple()
const {
return IsKind(TypeBase::kTuple); }
476#ifdef V8_ENABLE_WEBASSEMBLY
477 bool IsWasm()
const {
return IsKind(TypeBase::kWasm); }
481 if (
IsNone())
return false;
482 return Is(Type::Null()) ||
Is(Type::Undefined()) ||
Is(Type::MinusZero()) ||
483 Is(Type::NaN()) || IsHeapConstant() ||
484 (
Is(Type::PlainNumber()) && Min() == Max());
494#ifdef V8_ENABLE_WEBASSEMBLY
507 Type GetRange()
const;
509 int NumConstants()
const;
518 void PrintTo(std::ostream& os)
const;
534 friend class Iterator;
537 friend size_t hash_value(
Type type);
542 : payload_(reinterpret_cast<uint64_t>(type_base)) {}
546 if (IsBitset())
return false;
552 return reinterpret_cast<TypeBase*
>(payload_);
556 bool IsAny()
const {
return payload_ ==
Any().payload_; }
557 bool IsUnion()
const {
return IsKind(TypeBase::kUnion); }
561 return static_cast<bitset>(payload_) ^ uint64_t { 1 };
566 bitset BitsetGlb()
const;
567 bitset BitsetLub()
const;
569 bool SlowIs(
Type that)
const;
574 static Type OtherNumberConstant(
double value,
Zone* zone);
587 bool SimplyEquals(
Type that)
const;
593 static Type NormalizeRangeAndBitset(
Type range, bitset* bits,
Zone* zone);
T * AllocateArray(size_t length)
static bitset Lub(MapRefLike map, JSHeapBroker *broker)
static bool Is(bitset bits1, bitset bits2)
static bitset Lub(MapRef map, JSHeapBroker *broker)
static bool IsNone(bitset bits)
static bitset Lub(HeapObjectType const &type, JSHeapBroker *broker)
BitsetType::bitset bitset_
BitsetType::bitset Lub() const
static HeapConstantType * New(HeapObjectRef heap_ref, BitsetType::bitset bitset, Zone *zone)
HeapObjectRef Ref() const
static OtherNumberConstantType * New(double value, Zone *zone)
OtherNumberConstantType(double value)
BitsetType::bitset Lub() const
static bool IsOtherNumberConstant(double value)
static RangeType * New(Limits lim, Zone *zone)
static bool IsInteger(double x)
BitsetType::bitset bitset_
BitsetType::bitset Lub() const
RangeType(BitsetType::bitset bitset, Limits limits)
static RangeType * New(double min, double max, Zone *zone)
int LengthForTesting() const
StructuralType(Kind kind, int length, Zone *zone)
void Set(int i, Type type)
void InitElement(int i, Type type)
static TupleType * New(int length, Zone *zone)
Type Element(int i) const
TupleType(int length, Zone *zone)
static bool IsKind(Type type, Kind kind)
bool operator!=(Type other) const
static Type UnsignedSmall()
Type BitsetLubForTesting()
bool CanBeAsserted() const
Type BitsetGlbForTesting()
bool IsHeapConstant() const
Type(TypeBase *type_base)
static Type For(MapRef type, JSHeapBroker *broker)
const TypeBase * ToTypeBase() const
bitset AsBitsetForTesting()
bool Equals(Type that) const
static Type SignedSmall()
bool operator==(Type other) const
const UnionType * AsUnionForTesting()
static Type FromTypeBase(TypeBase *type)
static Type NewBitset(bitset bits)
BitsetType::bitset bitset
bool IsOtherNumberConstant() const
bool IsKind(TypeBase::Kind kind) const
static UnionType * New(int length, Zone *zone)
UnionType(int length, Zone *zone)
#define PROPER_BITSET_TYPE_LIST(V)
#define DECLARE_TYPE(type, value)
#define DEFINE_TYPE_CONSTRUCTOR(type, value)
#define BITSET_TYPE_LIST(V)
ZoneVector< RpoNumber > & result
size_t hash_value(const BranchParameters &p)
std::ostream & operator<<(std::ostream &os, AccessMode access_mode)
bool IsNone(Tagged< FieldType > obj)
bool Is(IndirectHandle< U > value)
static bool IsMinusZero(double value)
#define NON_EXPORTED_BASE(code)
#define DCHECK(condition)
#define V8_EXPORT_PRIVATE
Limits(double min, double max)
static Limits Union(Limits lhs, Limits rhs)
Limits(const RangeType *range)
static Limits Intersect(Limits lhs, Limits rhs)
const wasm::WasmModule * module_