Commit b3088d63 authored by Milad Fa's avatar Milad Fa Committed by Commit Bot

PPC/s390: [wasm] Avoid duplicating parameter lists

Port 679af80e

Original Commit Message:

    Avoid duplicating the list of parameter registers to push in the
    WasmCompileLazy builtin by reusing the existing arrays from
    wasm-linkage.h.

    Also verify the computed results against different constants.

R=clemensb@chromium.org, joransiu@ca.ibm.com, junyan@redhat.com, midawson@redhat.com
BUG=
LOG=N

Bug: v8:11377
Change-Id: I7277e865c30d83dd4d13aa501d913fb0d88526b7
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2716322Reviewed-by: 's avatarJunliang Yan <junyan@redhat.com>
Commit-Queue: Milad Fa <mfarazma@redhat.com>
Cr-Commit-Position: refs/heads/master@{#72982}
parent 4e113e46
......@@ -2403,21 +2403,30 @@ void Builtins::Generate_WasmCompileLazy(MacroAssembler* masm) {
// Save all parameter registers (see wasm-linkage.h). They might be
// overwritten in the runtime call below. We don't have any callee-saved
// registers in wasm, so no need to store anything else.
constexpr RegList gp_regs =
Register::ListOf(r3, r4, r5, r6, r7, r8, r9, r10);
constexpr RegList fp_regs =
DoubleRegister::ListOf(d1, d2, d3, d4, d5, d6, d7, d8);
RegList gp_regs = 0;
for (Register gp_param_reg : wasm::kGpParamRegisters) {
gp_regs |= gp_param_reg.bit();
}
RegList fp_regs = 0;
for (DoubleRegister fp_param_reg : wasm::kFpParamRegisters) {
fp_regs |= fp_param_reg.bit();
}
// List must match register numbers under kFpParamRegisters.
constexpr RegList simd_regs =
Simd128Register::ListOf(v1, v2, v3, v4, v5, v6, v7, v8);
static_assert(WasmCompileLazyFrameConstants::kNumberOfSavedGpParamRegs ==
NumRegs(gp_regs),
"frame size mismatch");
static_assert(WasmCompileLazyFrameConstants::kNumberOfSavedFpParamRegs ==
NumRegs(fp_regs),
"frame size mismatch");
static_assert(WasmCompileLazyFrameConstants::kNumberOfSavedFpParamRegs ==
NumRegs(simd_regs),
"frame size mismatch");
CHECK_EQ(NumRegs(gp_regs), arraysize(wasm::kGpParamRegisters));
CHECK_EQ(NumRegs(fp_regs), arraysize(wasm::kFpParamRegisters));
CHECK_EQ(NumRegs(simd_regs), arraysize(wasm::kFpParamRegisters));
CHECK_EQ(WasmCompileLazyFrameConstants::kNumberOfSavedGpParamRegs,
NumRegs(gp_regs));
CHECK_EQ(WasmCompileLazyFrameConstants::kNumberOfSavedFpParamRegs,
NumRegs(fp_regs));
CHECK_EQ(WasmCompileLazyFrameConstants::kNumberOfSavedFpParamRegs,
NumRegs(simd_regs));
__ MultiPush(gp_regs);
__ MultiPushDoubles(fp_regs);
// V8 uses the same set of fp param registers as Simd param registers.
......
......@@ -2452,18 +2452,23 @@ void Builtins::Generate_WasmCompileLazy(MacroAssembler* masm) {
// Save all parameter registers (see wasm-linkage.h). They might be
// overwritten in the runtime call below. We don't have any callee-saved
// registers in wasm, so no need to store anything else.
constexpr RegList gp_regs = Register::ListOf(r2, r3, r4, r5, r6);
#if V8_TARGET_ARCH_S390X
constexpr RegList fp_regs = DoubleRegister::ListOf(d0, d2, d4, d6);
#else
constexpr RegList fp_regs = DoubleRegister::ListOf(d0, d2);
#endif
static_assert(WasmCompileLazyFrameConstants::kNumberOfSavedGpParamRegs ==
NumRegs(gp_regs),
"frame size mismatch");
static_assert(WasmCompileLazyFrameConstants::kNumberOfSavedFpParamRegs ==
NumRegs(fp_regs),
"frame size mismatch");
RegList gp_regs = 0;
for (Register gp_param_reg : wasm::kGpParamRegisters) {
gp_regs |= gp_param_reg.bit();
}
RegList fp_regs = 0;
for (DoubleRegister fp_param_reg : wasm::kFpParamRegisters) {
fp_regs |= fp_param_reg.bit();
}
CHECK_EQ(NumRegs(gp_regs), arraysize(wasm::kGpParamRegisters));
CHECK_EQ(NumRegs(fp_regs), arraysize(wasm::kFpParamRegisters));
CHECK_EQ(WasmCompileLazyFrameConstants::kNumberOfSavedGpParamRegs,
NumRegs(gp_regs));
CHECK_EQ(WasmCompileLazyFrameConstants::kNumberOfSavedFpParamRegs,
NumRegs(fp_regs));
__ MultiPush(gp_regs);
// Check if machine has simd enabled, if so push vector registers. If not
// then only push double registers.
......
......@@ -22,10 +22,13 @@ class EntryFrameConstants : public AllStatic {
class WasmCompileLazyFrameConstants : public TypedFrameConstants {
public:
static constexpr int kNumberOfSavedGpParamRegs = 8;
static constexpr int kNumberOfSavedGpParamRegs = 7;
static constexpr int kNumberOfSavedFpParamRegs = 8;
// FP-relative.
// The instance is pushed as part of the saved registers. Being in {r10}, it
// is the first register pushed (highest register code in
// {wasm::kGpParamRegisters}).
static constexpr int kWasmInstanceOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(0);
static constexpr int kFixedFrameSizeFromFp =
TypedFrameConstants::kFixedFrameSizeFromFp +
......
......@@ -22,7 +22,7 @@ class EntryFrameConstants : public AllStatic {
class WasmCompileLazyFrameConstants : public TypedFrameConstants {
public:
static constexpr int kNumberOfSavedGpParamRegs = 5;
static constexpr int kNumberOfSavedGpParamRegs = 4;
#ifdef V8_TARGET_ARCH_S390X
static constexpr int kNumberOfSavedFpParamRegs = 4;
#else
......@@ -30,6 +30,9 @@ class WasmCompileLazyFrameConstants : public TypedFrameConstants {
#endif
// FP-relative.
// The instance is pushed as part of the saved registers. Being in {r6}, it is
// the first register pushed (highest register code in
// {wasm::kGpParamRegisters}).
static constexpr int kWasmInstanceOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(0);
static constexpr int kFixedFrameSizeFromFp =
TypedFrameConstants::kFixedFrameSizeFromFp +
......
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