#ifndef V8_CODEGEN_TNODE_H_
#define V8_CODEGEN_TNODE_H_
#include <type_traits>
#include "include/v8config.h"
#include "src/codegen/machine-type.h"
#include "src/objects/tagged.h"
namespace v8 {
namespace internal {
class HeapNumber;
class BigInt;
namespace compiler {
class Node;
}
struct UntaggedT { … };
struct IntegralT : UntaggedT { … };
struct WordT : IntegralT { … };
struct RawPtrT : WordT { … };
struct SandboxedPtrT : WordT { … };
template <class To>
struct RawPtr : RawPtrT { … };
struct Word32T : IntegralT { … };
struct Int32T : Word32T { … };
struct Uint32T : Word32T { … };
struct Int16T : Int32T { … };
struct Uint16T : Uint32T, Int32T { … };
struct Int8T : Int16T { … };
struct Uint8T : Uint16T, Int16T { … };
struct Word64T : IntegralT { … };
struct Int64T : Word64T { … };
struct Uint64T : Word64T { … };
struct IntPtrT : WordT { … };
struct UintPtrT : WordT { … };
struct ExternalPointerHandleT : Uint32T { … };
struct CppHeapPointerHandleT : Uint32T { … };
struct IndirectPointerHandleT : Uint32T { … };
struct JSDispatchHandleT : Uint32T { … };
#ifdef V8_ENABLE_SANDBOX
struct ExternalPointerT : Uint32T { … };
#else
struct ExternalPointerT : UntaggedT {
static constexpr MachineType kMachineType = MachineType::Pointer();
};
#endif
#ifdef V8_COMPRESS_POINTERS
struct CppHeapPointerT : Uint32T { … };
#else
struct CppHeapPointerT : UntaggedT {
static constexpr MachineType kMachineType = MachineType::Pointer();
};
#endif
struct Float16T : Word32T { … };
struct Float32T : UntaggedT { … };
struct Float64T : UntaggedT { … };
#ifdef V8_COMPRESS_POINTERS
TaggedT;
#else
using TaggedT = IntPtrT;
#endif
#ifdef V8_ENABLE_SANDBOX
TrustedPointerT;
#else
using TrustedPointerT = TaggedT;
#endif
struct BoolT : Word32T { … };
template <class T1, class T2>
struct PairT { … };
struct Simd128T : UntaggedT { … };
struct I8x16T : Simd128T { … };
struct I16x8T : Simd128T { … };
struct I32x2T : Simd128T { … };
inline constexpr MachineType CommonMachineType(MachineType type1,
MachineType type2) { … }
template <class Type, class Enable = void>
struct MachineTypeOf { … };
template <class Type, class Enable>
constexpr MachineType MachineTypeOf<Type, Enable>::value;
template <>
struct MachineTypeOf<Object> {
static constexpr MachineType value = MachineType::AnyTagged();
};
template <>
struct MachineTypeOf<MaybeObject> {
static constexpr MachineType value = MachineType::AnyTagged();
};
template <>
struct MachineTypeOf<Smi> {
static constexpr MachineType value = MachineType::TaggedSigned();
};
template <>
struct MachineTypeOf<TaggedIndex> {
static constexpr MachineType value = MachineType::Pointer();
};
template <class HeapObjectSubtype>
struct MachineTypeOf<
HeapObjectSubtype,
std::enable_if_t<std::is_base_of_v<HeapObject, HeapObjectSubtype> ||
std::is_base_of_v<HeapObjectLayout, HeapObjectSubtype>>> {
static constexpr MachineType value = MachineType::TaggedPointer();
};
template <class HeapObjectSubtype>
constexpr MachineType MachineTypeOf<
HeapObjectSubtype,
std::enable_if_t<std::is_base_of_v<HeapObject, HeapObjectSubtype> ||
std::is_base_of_v<HeapObjectLayout, HeapObjectSubtype>>>::
value;
template <>
struct MachineTypeOf<ExternalReference> {
static constexpr MachineType value = MachineType::Pointer();
};
template <class T>
struct MachineTypeOf<Union<T>> {
static constexpr MachineType value = MachineTypeOf<T>::value;
};
template <class T, class... Ts>
struct MachineTypeOf<Union<T, Ts...>> {
static constexpr MachineType value = CommonMachineType(
MachineTypeOf<T>::value, MachineTypeOf<Union<Ts...>>::value);
static_assert(value.representation() != MachineRepresentation::kNone,
"no common representation");
};
template <class Type, class Enable = void>
struct MachineRepresentationOf { … };
template <class T>
struct MachineRepresentationOf<T, std::void_t<decltype(T::kMachineType)>> {
static constexpr MachineRepresentation value =
T::kMachineType.representation();
};
template <class T>
struct MachineRepresentationOf<T, std::enable_if_t<is_taggable_v<T>>> {
static constexpr MachineRepresentation value =
MachineTypeOf<T>::value.representation();
};
template <>
struct MachineRepresentationOf<ExternalReference> {
static constexpr MachineRepresentation value =
RawPtrT::kMachineRepresentation;
};
template <typename T>
constexpr bool IsMachineRepresentationOf(MachineRepresentation r) { … }
PhiMachineRepresentationOf =
std::is_base_of<Word32T, T>::value ? MachineRepresentation::kWord32
: MachineRepresentationOf<T>::value;
template <class T>
struct is_valid_type_tag { … };
is_valid_type_tag<PairT<T1, T2>>;
is_valid_type_tag<Union<T...>>;
using AnyTaggedT = UnionOf<Object, MaybeObject>;
using ContextOrEmptyContext = UnionOf<Context, Smi>;
BuiltinPtr;
template <>
struct is_subtype<ExternalReference, RawPtrT> {
static const bool value = true;
};
template <class T, class U>
struct types_have_common_values { … };
types_have_common_values<BoolT, U>;
types_have_common_values<Uint32T, U>;
types_have_common_values<Int32T, U>;
types_have_common_values<Uint64T, U>;
types_have_common_values<Int64T, U>;
types_have_common_values<IntPtrT, U>;
types_have_common_values<UintPtrT, U>;
types_have_common_values<Union<Ts...>, U>;
types_have_common_values<T, Union<Us...>>;
types_have_common_values<Union<Ts...>, Union<Us...>>;
template <class T>
class TNode { … };
TNode<Tagged<T>>;
template <class T>
class SloppyTNode : public TNode<T> { … };
}
}
#endif