Commit 679af80e authored by Clemens Backes's avatar Clemens Backes Committed by Commit Bot

[wasm][arm] Avoid duplicating parameter lists

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=zhin@chromium.org

Bug: v8:11377
Change-Id: I727d4dcd1f1a0d3ae0e1a6ec03f0fb40c08564ed
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2668767
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Reviewed-by: 's avatarZhi An Ng <zhin@chromium.org>
Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#72547}
parent 2ba0b613
......@@ -2317,9 +2317,24 @@ 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(r0, r1, r2, r3);
constexpr DwVfpRegister lowest_fp_reg = d0;
constexpr DwVfpRegister highest_fp_reg = d7;
RegList gp_regs = 0;
for (Register gp_param_reg : wasm::kGpParamRegisters) {
gp_regs |= gp_param_reg.bit();
}
DwVfpRegister lowest_fp_reg = std::begin(wasm::kFpParamRegisters)[0];
DwVfpRegister highest_fp_reg = std::end(wasm::kFpParamRegisters)[-1];
for (DwVfpRegister fp_param_reg : wasm::kFpParamRegisters) {
CHECK(fp_param_reg.code() >= lowest_fp_reg.code() &&
fp_param_reg.code() <= highest_fp_reg.code());
}
CHECK_EQ(NumRegs(gp_regs), arraysize(wasm::kGpParamRegisters));
CHECK_EQ(highest_fp_reg.code() - lowest_fp_reg.code() + 1,
arraysize(wasm::kFpParamRegisters));
CHECK_EQ(NumRegs(gp_regs),
WasmCompileLazyFrameConstants::kNumberOfSavedGpParamRegs);
CHECK_EQ(highest_fp_reg.code() - lowest_fp_reg.code() + 1,
WasmCompileLazyFrameConstants::kNumberOfSavedFpParamRegs);
__ stm(db_w, sp, gp_regs);
__ vstm(db_w, sp, lowest_fp_reg, highest_fp_reg);
......
......@@ -2698,16 +2698,28 @@ 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(x0, x1, x2, x3, x4, x5, x6, x7);
constexpr RegList fp_regs =
Register::ListOf(d0, d1, d2, d3, d4, d5, d6, d7);
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();
}
// Also push x1, because we must push multiples of 16 bytes (see
// {TurboAssembler::PushCPURegList}.
CHECK_EQ(1, NumRegs(gp_regs) % 2);
gp_regs |= x1.bit();
CHECK_EQ(0, NumRegs(gp_regs) % 2);
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) + 1);
CHECK_EQ(NumRegs(fp_regs), arraysize(wasm::kFpParamRegisters));
CHECK_EQ(WasmCompileLazyFrameConstants::kNumberOfSavedGpParamRegs,
NumRegs(gp_regs));
CHECK_EQ(WasmCompileLazyFrameConstants::kNumberOfSavedFpParamRegs,
NumRegs(fp_regs));
__ PushXRegList(gp_regs);
__ PushQRegList(fp_regs);
......
......@@ -61,7 +61,10 @@ class WasmCompileLazyFrameConstants : public TypedFrameConstants {
static constexpr int kNumberOfSavedFpParamRegs = 8;
// FP-relative.
static constexpr int kWasmInstanceOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(0);
// The instance is pushed as part of the saved registers. Being in {r3}, it is
// at position 1 in the list [r0, r2, r3, r6] (kGpParamRegisters sorted by
// number and indexed zero-based from the back).
static constexpr int kWasmInstanceOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(1);
static constexpr int kFixedFrameSizeFromFp =
TypedFrameConstants::kFixedFrameSizeFromFp +
kNumberOfSavedGpParamRegs * kPointerSize +
......
......@@ -76,6 +76,10 @@ class WasmCompileLazyFrameConstants : public TypedFrameConstants {
static constexpr int kNumberOfSavedFpParamRegs = 8;
// FP-relative.
// The instance is pushed as part of the saved registers. Being in {r7}, it is
// the first register pushed (highest register code in
// {wasm::kGpParamRegisters}). Because of padding of the frame header, it is
// actually one word further down the stack though (thus at position {1}).
static constexpr int kWasmInstanceOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(1);
static constexpr int kFixedFrameSizeFromFp =
// Header is padded to 16 byte (see {MacroAssembler::EnterFrame}).
......
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