5#ifndef V8_CODEGEN_INTERFACE_DESCRIPTORS_INL_H_
6#define V8_CODEGEN_INTERFACE_DESCRIPTORS_INL_H_
15#if V8_ENABLE_WEBASSEMBLY
21#elif V8_TARGET_ARCH_ARM64
23#elif V8_TARGET_ARCH_IA32
25#elif V8_TARGET_ARCH_ARM
27#elif V8_TARGET_ARCH_PPC64
29#elif V8_TARGET_ARCH_S390X
31#elif V8_TARGET_ARCH_MIPS64
33#elif V8_TARGET_ARCH_LOONG64
35#elif V8_TARGET_ARCH_RISCV32 || V8_TARGET_ARCH_RISCV64
38#error Unsupported target architecture.
45constexpr std::array<Register, kJSBuiltinRegisterParams>
53template <
typename DerivedDescriptor>
59template <
typename DerivedDescriptor>
66template <
typename DerivedDescriptor>
73template <
typename DerivedDescriptor>
80template <
typename DerivedDescriptor>
97template <
typename DerivedDescriptor>
102 static constexpr auto registers = DerivedDescriptor::registers();
103 static constexpr auto double_registers =
104 DerivedDescriptor::double_registers();
105 static constexpr auto return_registers =
106 DerivedDescriptor::return_registers();
107 static constexpr auto return_double_registers =
108 DerivedDescriptor::return_double_registers();
114 if (DerivedDescriptor::kRestrictAllocatableRegisters) {
117 DCHECK(!DerivedDescriptor::kCalleeSaveRegisters);
123 DCHECK_GE(double_registers.size(), GetRegisterParameterCount());
124 DCHECK_GE(return_registers.size(), DerivedDescriptor::kReturnCount);
125 DCHECK_GE(return_double_registers.size(), DerivedDescriptor::kReturnCount);
126 data->InitializeRegisters(
127 DerivedDescriptor::flags(), DerivedDescriptor::kEntrypointTag,
128 DerivedDescriptor::kReturnCount, DerivedDescriptor::GetParameterCount(),
129 DerivedDescriptor::kStackArgumentOrder,
130 DerivedDescriptor::GetRegisterParameterCount(),
registers.data(),
131 double_registers.data(), return_registers.data(),
132 return_double_registers.data());
135 DerivedDescriptor::InitializeTypes(data);
137 DCHECK(data->IsInitialized());
138 DCHECK(this->CheckFloatingPointParameters(data));
140 DerivedDescriptor::Verify(data);
144template <
typename DerivedDescriptor>
148 DerivedDescriptor::kReturnCount >= 0,
149 "DerivedDescriptor subclass should override return count with a value "
150 "that is greater than or equal to 0");
152 return DerivedDescriptor::kReturnCount;
156template <
typename DerivedDescriptor>
160 DerivedDescriptor::kParameterCount >= 0,
161 "DerivedDescriptor subclass should override parameter count with a "
162 "value that is greater than or equal to 0");
164 return DerivedDescriptor::kParameterCount;
179template <
size_t N,
size_t Index>
181 static constexpr int Call(std::array<Register, N> regs) {
182 if (!std::get<Index>(regs).is_valid()) {
194 static constexpr int Call(std::array<Register, N> regs) {
return N; }
196template <
size_t N,
size_t Index = 0>
205template <
typename DerivedDescriptor>
210 "DerivedDescriptor subclass should define a registers() function "
211 "returning a std::array<Register>");
221 return std::min<int>({DerivedDescriptor::GetParameterCount(),
223 DerivedDescriptor::registers())),
224 DerivedDescriptor::kMaxRegisterParams});
228template <
typename DerivedDescriptor>
231 return DerivedDescriptor::GetParameterCount() -
232 DerivedDescriptor::GetRegisterParameterCount();
236template <
typename DerivedDescriptor>
240 return DerivedDescriptor::registers()[
i];
244template <
typename DerivedDescriptor>
248 return i - DerivedDescriptor::GetRegisterParameterCount();
252template <
typename DerivedDescriptor>
255 if constexpr (!DerivedDescriptor::kCustomMachineTypes) {
261 if (DerivedDescriptor::AllowVarArgs() &&
262 i >= DerivedDescriptor::GetParameterCount()) {
265 DCHECK_LT(
i, DerivedDescriptor::GetParameterCount());
266 return DerivedDescriptor::kMachineTypes
267 [DerivedDescriptor::GetReturnCount() +
i];
272template <
typename DerivedDescriptor>
278 DerivedDescriptor::double_registers()[
i].
code());
282constexpr Register FastNewObjectDescriptor::TargetRegister() {
297 return std::get<kSlotAddress>(
registers());
302 return std::get<kSlotAddress + 1>(
registers());
310#if V8_TARGET_ARCH_X64
316#elif V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_LOONG64 || \
317 V8_TARGET_ARCH_MIPS64
324 constexpr auto allocated_registers =
registers();
325 for (
size_t i = 0;
i < allocated_registers.
size(); ++
i) {
326 saved_registers.
set(allocated_registers[
i]);
329 return saved_registers;
343 return std::get<kSlotAddress>(
registers());
348 return std::get<kIndirectPointerTag>(
registers());
360 return saved_registers;
363constexpr Register ApiGetterDescriptor::ReceiverRegister() {
364 return LoadDescriptor::ReceiverRegister();
368constexpr Register LoadGlobalNoFeedbackDescriptor::ICKindRegister() {
373constexpr Register LoadNoFeedbackDescriptor::ICKindRegister() {
374 return LoadGlobalNoFeedbackDescriptor::ICKindRegister();
377#if V8_TARGET_ARCH_IA32
381constexpr Register LoadGlobalWithVectorDescriptor::VectorRegister() {
382 static_assert(!LoadWithVectorDescriptor::VectorRegister().is_valid());
383 return LoadDescriptor::ReceiverRegister();
387constexpr Register LoadGlobalWithVectorDescriptor::VectorRegister() {
388 return LoadWithVectorDescriptor::VectorRegister();
448 DefineKeyedOwnDescriptor::FlagsRegister(),
460 LoadDescriptor::ReceiverRegister(),
461 LoadWithReceiverAndVectorDescriptor::LookupStartObjectRegister(),
468#if V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_ARM || \
469 V8_TARGET_ARCH_PPC64 || V8_TARGET_ARCH_S390X || V8_TARGET_ARCH_RISCV64 || \
470 V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_LOONG64 || V8_TARGET_ARCH_RISCV32
475#elif V8_TARGET_ARCH_IA32
488#if V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_ARM64 || \
489 V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_PPC64 || V8_TARGET_ARCH_S390X || \
490 V8_TARGET_ARCH_RISCV64 || V8_TARGET_ARCH_MIPS64 || \
491 V8_TARGET_ARCH_LOONG64 || V8_TARGET_ARCH_RISCV32
500#if V8_TARGET_ARCH_MIPS64
513#ifdef V8_ENABLE_MAGLEV
522constexpr Register OnStackReplacementDescriptor::MaybeTargetCodeRegister() {
585 LoadDescriptor::ReceiverRegister(), LookupStartObjectRegister(),
587 LoadWithVectorDescriptor::VectorRegister());
595 StoreWithVectorDescriptor::VectorRegister());
604 StoreWithVectorDescriptor::VectorRegister());
646 return RegisterArray(KeyedLoadBaselineDescriptor::ReceiverRegister(),
655 KeyedLoadBaselineDescriptor::ReceiverRegister(),
657 EnumeratedKeyedLoadBaselineDescriptor::EnumIndexRegister(),
660 KeyedLoadWithVectorDescriptor::VectorRegister());
670 return RegisterArray(KeyedLoadBaselineDescriptor::ReceiverRegister(),
683 return RegisterArray(KeyedHasICBaselineDescriptor::ReceiverRegister(),
702 DefineKeyedOwnDescriptor::FlagsRegister(),
769 return std::get<kWrapperBuffer>(
registers());
774WasmHandleStackOverflowDescriptor::FrameBaseRegister() {
775 return std::get<kFrameBase>(
registers());
783#if V8_ENABLE_WEBASSEMBLY
791#if V8_ENABLE_WEBASSEMBLY
801#if V8_ENABLE_WEBASSEMBLY
810#define DEFINE_STATIC_BUILTIN_DESCRIPTOR_GETTER(Name, DescriptorName) \
812 struct CallInterfaceDescriptorFor<Builtin::k##Name> { \
813 using type = DescriptorName##Descriptor; \
820#undef DEFINE_STATIC_BUILTIN_DESCRIPTOR_GETTER
821#define DEFINE_STATIC_BUILTIN_DESCRIPTOR_GETTER(Name, ...) \
823 struct CallInterfaceDescriptorFor<Builtin::k##Name> { \
824 using type = Name##Descriptor; \
827#undef DEFINE_STATIC_BUILTIN_DESCRIPTOR_GETTER
#define BUILTIN_LIST_TFS(V)
#define IGNORE_BUILTIN(...)
union v8::internal::@341::BuiltinMetadata::KindSpecificData data
static constexpr Register HolderRegister()
static constexpr auto registers()
static constexpr Register CallbackRegister()
static constexpr auto registers()
static constexpr Register WeightRegister()
static constexpr Register FunctionTemplateInfoRegister()
static DEFINE_PARAMETERS_VARARGS(kActualArgumentsCount, kTopmostScriptHavingContext, kFunctionTemplateInfo) DEFINE_PARAMETER_TYPES(MachineType constexpr Register TopmostScriptHavingContextRegister()
static constexpr auto registers()
static constexpr Register FunctionTemplateInfoRegister()
static DEFINE_PARAMETERS_VARARGS(kApiFunctionAddress, kActualArgumentsCount, kFunctionTemplateInfo) DEFINE_PARAMETER_TYPES(MachineType constexpr Register ActualArgumentsCountRegister()
static constexpr auto registers()
bool IsInitialized() const
static constexpr std::array< Register, kJSBuiltinRegisterParams > DefaultJSRegisterArray()
static constexpr auto DefaultReturnDoubleRegisterArray()
static constexpr auto DefaultDoubleRegisterArray()
static constexpr auto DefaultRegisterArray()
static constexpr auto DefaultReturnRegisterArray()
static constexpr auto registers()
static constexpr auto registers()
static constexpr auto registers()
static constexpr auto registers()
static constexpr Register CacheTypeRegister()
static constexpr Register SlotRegister()
static constexpr auto registers()
static constexpr auto registers()
static constexpr Register NewTargetRegister()
static constexpr Register KeyRegister()
static constexpr auto registers()
static constexpr RegList ComputeSavedRegisters(Register object, Register slot_address=no_reg)
static constexpr Register IndirectPointerTagRegister()
static constexpr Register ObjectRegister()
static constexpr Register SlotAddressRegister()
static constexpr auto registers()
static constexpr Register NameRegister()
static constexpr Register SlotRegister()
static constexpr auto registers()
static constexpr auto registers()
static constexpr Register SlotRegister()
static constexpr Register NameRegister()
static constexpr auto registers()
static constexpr auto registers()
static constexpr Register SlotRegister()
static constexpr Register NameRegister()
static constexpr auto registers()
static constexpr auto registers()
static constexpr auto registers()
static constexpr auto registers()
static constexpr auto registers()
static constexpr auto registers()
static constexpr MachineType AnyTagged()
static constexpr auto registers()
static constexpr Register TemporaryRegister()
static constexpr Register FeedbackVectorRegister()
static constexpr auto registers()
static constexpr auto registers()
static constexpr Register ExpectedParameterCountRegister()
constexpr void set(RegisterT reg)
static constexpr DwVfpRegister from_code(int8_t code)
static constexpr Register MicrotaskQueueRegister()
static constexpr auto registers()
static constexpr auto return_registers()
static constexpr auto return_double_registers()
static constexpr MachineType GetParameterType(int i)
static constexpr auto double_registers()
static constexpr DoubleRegister GetDoubleRegisterParameter(int i)
static constexpr auto registers()
static constexpr Register GetRegisterParameter(int i)
void Initialize(CallInterfaceDescriptorData *data)
static constexpr int GetRegisterParameterCount()
static constexpr int GetStackParameterCount()
static constexpr int GetReturnCount()
static constexpr int GetParameterCount()
static constexpr int GetStackParameterIndex(int i)
static constexpr auto registers()
static constexpr Register NameRegister()
static constexpr Register SlotRegister()
static constexpr Register ValueRegister()
static constexpr auto registers()
static constexpr auto registers()
static constexpr auto registers()
static constexpr auto registers()
static constexpr Register ArgumentRegister()
static constexpr auto registers()
static constexpr auto registers()
static constexpr Register GapRegister()
static constexpr Register WrapperBufferRegister()
static constexpr auto registers()
static constexpr auto return_double_registers()
static constexpr auto return_registers()
static constexpr auto registers()
static constexpr Register ObjectRegister()
static constexpr Register ValueRegister()
static constexpr RegList ComputeSavedRegisters(Register object, Register slot_address=no_reg)
static constexpr Register SlotAddressRegister()
#define DEFINE_STATIC_BUILTIN_DESCRIPTOR_GETTER(Name, DescriptorName)
RegListBase< RegisterT > registers
constexpr size_t FirstInvalidRegister(std::array< Register, N > regs)
constexpr DoubleRegister kFpReturnRegisters[]
constexpr Register kGpParamRegisters[]
constexpr Register kGpReturnRegisters[]
constexpr Register no_reg
constexpr Register kRuntimeCallFunctionRegister
constexpr EmptyDoubleRegisterArray DoubleRegisterArray()
constexpr Register kRuntimeCallArgvRegister
constexpr Register kJavaScriptCallTargetRegister
constexpr DwVfpRegister no_dreg
constexpr EmptyRegisterArray RegisterArray()
constexpr Register kJavaScriptCallArgCountRegister
constexpr bool IsFloatingPoint(MachineRepresentation rep)
constexpr Register kReturnRegister0
constexpr Register kContextRegister
V8_EXPORT_PRIVATE bool AreAliased(const CPURegister ®1, const CPURegister ®2, const CPURegister ®3=NoReg, const CPURegister ®4=NoReg, const CPURegister ®5=NoReg, const CPURegister ®6=NoReg, const CPURegister ®7=NoReg, const CPURegister ®8=NoReg)
constexpr Register kRuntimeCallArgCountRegister
constexpr Register kAllocateSizeRegister
constexpr Register kJavaScriptCallExtraArg1Register
constexpr Register kJavaScriptCallCodeStartRegister
constexpr Register kJavaScriptCallDispatchHandleRegister
constexpr Register kJavaScriptCallNewTargetRegister
constexpr Register kJSFunctionRegister
constexpr Register kInterpreterBytecodeArrayRegister
#define DCHECK_GE(v1, v2)
#define DCHECK(condition)
#define DCHECK_LT(v1, v2)
#define DCHECK_EQ(v1, v2)
static constexpr int Call(std::array< Register, N > regs)
static constexpr int Call(std::array< Register, N > regs)