Commit 032ab3d2 authored by Camillo Bruni's avatar Camillo Bruni Committed by V8 LUCI CQ

[codegen] Assert that RegisterArray has only unique registers

Bug: v8:11420
Change-Id: Iede5f605f500c72b455906cc53fc417a16be1900
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2919821Reviewed-by: 's avatarSantiago Aboy Solanes <solanes@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#74819}
parent 1decfe64
......@@ -21,11 +21,13 @@ constexpr auto CallInterfaceDescriptor::DefaultRegisterArray() {
// static
constexpr auto WriteBarrierDescriptor::registers() {
return RegisterArray(r0, r1, r2, r3, r4, kReturnRegister0);
STATIC_ASSERT(kReturnRegister0 == r0);
return RegisterArray(r0, r1, r2, r3, r4);
}
// static
constexpr auto DynamicCheckMapsDescriptor::registers() {
STATIC_ASSERT(kReturnRegister0 == r0);
return RegisterArray(r0, r1, r2, r3, cp);
}
......
......@@ -22,11 +22,13 @@ constexpr auto CallInterfaceDescriptor::DefaultRegisterArray() {
// static
constexpr auto WriteBarrierDescriptor::registers() {
return RegisterArray(x0, x1, x2, x3, x4, kReturnRegister0);
STATIC_ASSERT(kReturnRegister0 == x0);
return RegisterArray(x0, x1, x2, x3, x4);
}
// static
constexpr auto DynamicCheckMapsDescriptor::registers() {
STATIC_ASSERT(kReturnRegister0 == x0);
return RegisterArray(x0, x1, x2, x3, cp);
}
......
......@@ -20,11 +20,14 @@ constexpr auto CallInterfaceDescriptor::DefaultRegisterArray() {
// static
constexpr auto WriteBarrierDescriptor::registers() {
STATIC_ASSERT(esi == kContextRegister);
return RegisterArray(ecx, edx, esi, edi, kReturnRegister0);
}
// static
constexpr auto DynamicCheckMapsDescriptor::registers() {
STATIC_ASSERT(esi == kContextRegister);
STATIC_ASSERT(eax == kReturnRegister0);
return RegisterArray(eax, ecx, edx, edi, esi);
}
......
......@@ -271,13 +271,18 @@ constexpr auto LoadWithReceiverBaselineDescriptor::registers() {
// static
constexpr auto BaselineOutOfLinePrologueDescriptor::registers() {
// TODO(v8:11421): Implement on other platforms.
#if V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_IA32 || \
V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_PPC64 || \
V8_TARGET_ARCH_S390 || V8_TARGET_ARCH_RISCV64
#if V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_ARM || \
V8_TARGET_ARCH_PPC || V8_TARGET_ARCH_PPC64 || V8_TARGET_ARCH_S390 || \
V8_TARGET_ARCH_RISCV64
return RegisterArray(
kContextRegister, kJSFunctionRegister, kJavaScriptCallArgCountRegister,
kJavaScriptCallExtraArg1Register, kJavaScriptCallNewTargetRegister,
kInterpreterBytecodeArrayRegister);
#elif V8_TARGET_ARCH_IA32
STATIC_ASSERT(kJSFunctionRegister == kInterpreterBytecodeArrayRegister);
return RegisterArray(
kContextRegister, kJSFunctionRegister, kJavaScriptCallArgCountRegister,
kJavaScriptCallExtraArg1Register, kJavaScriptCallNewTargetRegister);
#else
return DefaultRegisterArray();
#endif
......
......@@ -506,6 +506,7 @@ struct EmptyRegisterArray {
template <typename... Registers>
constexpr std::array<Register, 1 + sizeof...(Registers)> RegisterArray(
Register first_reg, Registers... regs) {
DCHECK(!AreAliased(first_reg, regs...));
return {first_reg, regs...};
}
constexpr EmptyRegisterArray RegisterArray() { return {}; }
......
......@@ -33,8 +33,14 @@ constexpr auto TSANRelaxedStoreDescriptor::registers() {
// static
constexpr auto DynamicCheckMapsDescriptor::registers() {
#if V8_TARGET_OS_WIN
return RegisterArray(kReturnRegister0, arg_reg_1, arg_reg_2, arg_reg_3,
kRuntimeCallFunctionRegister, kContextRegister);
#else
STATIC_ASSERT(kContextRegister == arg_reg_2);
return RegisterArray(kReturnRegister0, arg_reg_1, arg_reg_2, arg_reg_3,
kRuntimeCallFunctionRegister);
#endif // V8_TARGET_OS_WIN
}
// static
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment