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

PPC/s390: Fix frame size to account for q registers

Port 45b99aaa

Original Commit Message:

    In https://crrev.com/c/2645694 we push the full q registers before lazy
    compile, but we did not change the fixed frame size to account for the
    wider registers being pushed.

    This manifested in the frame having data like:

    (gdb) x/10xg start.ptr_
    0x7f5576ff3eb0: 0x0000000000000000      0x0000336b08202759
    0x7f5576ff3ec0: 0x7ff000007f801000      0x0000000000000000
    0x7f5576ff3ed0: 0x7ff000007f801001      0x0000000000000000
    0x7f5576ff3ee0: 0x7ff000007f801002      0x0000000000000000
    0x7f5576ff3ef0: 0x7ff000007f801003      0x0000000000000000

    The GC then walks part of this frame, thinking that 0x7ff000007f801003
    is a heap object, and then crashes.

    Add some static_asserts (similar to builtins-x64) to remind ourselves
    that the pushed registers have to match the size in frame constants.

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

Change-Id: I994f1b7fecbb24ea97d846b1eed98201bc3b08ad
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2669308Reviewed-by: 's avatarJunliang Yan <junyan@redhat.com>
Commit-Queue: Milad Fa <mfarazma@redhat.com>
Cr-Commit-Position: refs/heads/master@{#72496}
parent dd90d107
......@@ -2404,6 +2404,15 @@ void Builtins::Generate_WasmCompileLazy(MacroAssembler* masm) {
DoubleRegister::ListOf(d1, d2, d3, d4, d5, d6, d7, d8);
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");
__ MultiPush(gp_regs);
__ MultiPushDoubles(fp_regs);
// V8 uses the same set of fp param registers as Simd param registers.
......@@ -2412,6 +2421,14 @@ void Builtins::Generate_WasmCompileLazy(MacroAssembler* masm) {
// Check the comments under crrev.com/c/2645694 for more details.
if (CpuFeatures::SupportsWasmSimd128()) {
__ MultiPushV128(simd_regs);
} else {
// kFixedFrameSizeFromFp is hard coded to include space for Simd
// registers, so we still need to allocate space on the stack even if we
// are not pushing them.
__ addi(
sp, sp,
Operand(-static_cast<int8_t>(base::bits::CountPopulation(simd_regs)) *
kSimd128Size));
}
// Pass instance and function index as explicit arguments to the runtime
......@@ -2427,6 +2444,11 @@ void Builtins::Generate_WasmCompileLazy(MacroAssembler* masm) {
// Restore registers.
if (CpuFeatures::SupportsWasmSimd128()) {
__ MultiPopV128(simd_regs);
} else {
__ addi(
sp, sp,
Operand(static_cast<int8_t>(base::bits::CountPopulation(simd_regs)) *
kSimd128Size));
}
__ MultiPopDoubles(fp_regs);
__ MultiPop(gp_regs);
......
......@@ -2454,6 +2454,12 @@ void Builtins::Generate_WasmCompileLazy(MacroAssembler* masm) {
#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");
__ MultiPush(gp_regs);
__ MultiPushV128(fp_regs);
......
......@@ -30,7 +30,8 @@ class WasmCompileLazyFrameConstants : public TypedFrameConstants {
static constexpr int kFixedFrameSizeFromFp =
TypedFrameConstants::kFixedFrameSizeFromFp +
kNumberOfSavedGpParamRegs * kSystemPointerSize +
kNumberOfSavedFpParamRegs * kDoubleSize;
kNumberOfSavedFpParamRegs * kDoubleSize +
kNumberOfSavedFpParamRegs * kSimd128Size;
};
// Frame constructed by the {WasmDebugBreak} builtin.
......
......@@ -34,7 +34,7 @@ class WasmCompileLazyFrameConstants : public TypedFrameConstants {
static constexpr int kFixedFrameSizeFromFp =
TypedFrameConstants::kFixedFrameSizeFromFp +
kNumberOfSavedGpParamRegs * kSystemPointerSize +
kNumberOfSavedFpParamRegs * kDoubleSize;
kNumberOfSavedFpParamRegs * kSimd128Size;
};
// Frame constructed by the {WasmDebugBreak} builtin.
......
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