PPC/s390: [wasm] Fix registers spilled in DebugBreak frame

Port e47f9a9d50

Original Commit Message:

    The set of registers to spill was wrong. Instead of spilling wasm
    parameter registers (like the WasmCompileLazy builtin), we should spill
    all registers that are being used as Liftoff cache registers.
    This CL defines platform-specific WasmDebugBreakFrameConstants which
    hold the set of registers to spill. This set is used in the builtin, and
    will later be used for inspecting the spilled registers.

    In order to iterate bit sets more easily in both direction (MSB to LSB
    or LSB to MSB), we add a base::bits::IterateBits{,Backwards} method
    which provides the respective iterators.

R=clemensb@chromium.org, joransiu@ca.ibm.com, jyan@ca.ibm.com, michael_dawson@ca.ibm.com
BUG=
LOG=N

Change-Id: Ic308a7712f080e43a0c45f496b087ce8450f657a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2105563
Reviewed-by: Junliang Yan <jyan@ca.ibm.com>
Commit-Queue: Milad Farazmand <miladfar@ca.ibm.com>
Cr-Commit-Position: refs/heads/master@{#66736}
This commit is contained in:
Milad Farazmand 2020-03-16 18:34:19 +00:00 committed by Commit Bot
parent b7971e95d0
commit e54259ee15
4 changed files with 42 additions and 18 deletions

View File

@ -2605,12 +2605,8 @@ void Builtins::Generate_WasmDebugBreak(MacroAssembler* masm) {
// Save all parameter registers. They might hold live values, we restore
// them after the runtime call.
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);
__ MultiPush(gp_regs);
__ MultiPushDoubles(fp_regs);
__ MultiPush(WasmDebugBreakFrameConstants::kPushedGpRegs);
__ MultiPushDoubles(WasmDebugBreakFrameConstants::kPushedFpRegs);
// Initialize the JavaScript context with 0. CEntry will use it to
// set the current context on the isolate.
@ -2618,8 +2614,8 @@ void Builtins::Generate_WasmDebugBreak(MacroAssembler* masm) {
__ CallRuntime(Runtime::kWasmDebugBreak, 0);
// Restore registers.
__ MultiPopDoubles(fp_regs);
__ MultiPop(gp_regs);
__ MultiPopDoubles(WasmDebugBreakFrameConstants::kPushedFpRegs);
__ MultiPop(WasmDebugBreakFrameConstants::kPushedGpRegs);
}
__ Ret();
}

View File

@ -2665,14 +2665,8 @@ void Builtins::Generate_WasmDebugBreak(MacroAssembler* masm) {
// Save all parameter registers. They might hold live values, we restore
// them after the runtime call.
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
__ MultiPush(gp_regs);
__ MultiPushDoubles(fp_regs);
__ MultiPush(WasmDebugBreakFrameConstants::kPushedGpRegs);
__ MultiPushDoubles(WasmDebugBreakFrameConstants::kPushedFpRegs);
// Initialize the JavaScript context with 0. CEntry will use it to
// set the current context on the isolate.
@ -2680,8 +2674,8 @@ void Builtins::Generate_WasmDebugBreak(MacroAssembler* masm) {
__ CallRuntime(Runtime::kWasmDebugBreak, 0);
// Restore registers.
__ MultiPopDoubles(fp_regs);
__ MultiPop(gp_regs);
__ MultiPopDoubles(WasmDebugBreakFrameConstants::kPushedFpRegs);
__ MultiPop(WasmDebugBreakFrameConstants::kPushedGpRegs);
}
__ Ret();
}

View File

@ -5,6 +5,7 @@
#ifndef V8_EXECUTION_PPC_FRAME_CONSTANTS_PPC_H_
#define V8_EXECUTION_PPC_FRAME_CONSTANTS_PPC_H_
#include "src/base/bits.h"
#include "src/base/macros.h"
#include "src/execution/frame-constants.h"
@ -30,6 +31,22 @@ class WasmCompileLazyFrameConstants : public TypedFrameConstants {
kNumberOfSavedFpParamRegs * kDoubleSize;
};
// Frame constructed by the {WasmDebugBreak} builtin.
// After pushing the frame type marker, the builtin pushes all Liftoff cache
// registers (see liftoff-assembler-defs.h).
class WasmDebugBreakFrameConstants : public TypedFrameConstants {
public:
// {r3, r4, r5, r6, r7, r8, r9, r10, r11}
static constexpr uint32_t kPushedGpRegs = 0b111111111000;
// {d0 .. d12}
static constexpr uint32_t kPushedFpRegs = 0b1111111111111;
static constexpr int kNumPushedGpRegisters =
base::bits::CountPopulation(kPushedGpRegs);
static constexpr int kNumPushedFpRegisters =
base::bits::CountPopulation(kPushedFpRegs);
};
} // namespace internal
} // namespace v8

View File

@ -5,6 +5,7 @@
#ifndef V8_EXECUTION_S390_FRAME_CONSTANTS_S390_H_
#define V8_EXECUTION_S390_FRAME_CONSTANTS_S390_H_
#include "src/base/bits.h"
#include "src/base/macros.h"
#include "src/execution/frame-constants.h"
@ -36,6 +37,22 @@ class WasmCompileLazyFrameConstants : public TypedFrameConstants {
kNumberOfSavedFpParamRegs * kDoubleSize;
};
// Frame constructed by the {WasmDebugBreak} builtin.
// After pushing the frame type marker, the builtin pushes all Liftoff cache
// registers (see liftoff-assembler-defs.h).
class WasmDebugBreakFrameConstants : public TypedFrameConstants {
public:
// {r2, r3, r4, r5, r6, r7, r8}
static constexpr uint32_t kPushedGpRegs = 0b111111100;
// {d0 .. d12}
static constexpr uint32_t kPushedFpRegs = 0b1111111111111;
static constexpr int kNumPushedGpRegisters =
base::bits::CountPopulation(kPushedGpRegs);
static constexpr int kNumPushedFpRegisters =
base::bits::CountPopulation(kPushedFpRegs);
};
} // namespace internal
} // namespace v8