Commit 0c785c07 authored by QiuJi's avatar QiuJi Committed by V8 LUCI CQ

[riscv] Reland: [wasm] WasmCompileLazyFrame scanning

Port 4e329f8c
Also fix 64-bit addressed stores on riscv64

Bug: v8:12852
Bug: v8:10949
Change-Id: Ibc0d4efe04da5b4ca3c3e6c2997655b8d3795004
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3806593
Commit-Queue: Yahan Lu <yahan@iscas.ac.cn>
Auto-Submit: ji qiu <qiuji@iscas.ac.cn>
Reviewed-by: 's avatarYahan Lu <yahan@iscas.ac.cn>
Cr-Commit-Position: refs/heads/main@{#82186}
parent 6fd50360
...@@ -2782,7 +2782,7 @@ void Builtins::Generate_WasmCompileLazy(MacroAssembler* masm) { ...@@ -2782,7 +2782,7 @@ void Builtins::Generate_WasmCompileLazy(MacroAssembler* masm) {
CHECK_EQ(saved_gp_regs.Count(), arraysize(wasm::kGpParamRegisters)); CHECK_EQ(saved_gp_regs.Count(), arraysize(wasm::kGpParamRegisters));
// The Wasm instance must be part of the saved registers. // The Wasm instance must be part of the saved registers.
CHECK(saved_gp_regs.has(kWasmInstanceRegister)); CHECK(saved_gp_regs.has(kWasmInstanceRegister));
CHECK_EQ(WasmCompileLazyFrameConstants::kNumberOfSavedGpParamRegs, CHECK_EQ(WasmCompileLazyFrameConstants::kNumberOfSavedGpParamRegs + 1,
saved_gp_regs.Count()); saved_gp_regs.Count());
return saved_gp_regs; return saved_gp_regs;
})(); })();
...@@ -2808,11 +2808,13 @@ void Builtins::Generate_WasmCompileLazy(MacroAssembler* masm) { ...@@ -2808,11 +2808,13 @@ void Builtins::Generate_WasmCompileLazy(MacroAssembler* masm) {
// Pass instance and function index as an explicit arguments to the runtime // Pass instance and function index as an explicit arguments to the runtime
// function. // function.
__ Push(kWasmInstanceRegister, kWasmCompileLazyFuncIndexRegister); // Also allocate a stack slot for the NativeModule, the pushed value does
// not matter.
__ Push(kWasmInstanceRegister, kWasmCompileLazyFuncIndexRegister, a0);
// Initialize the JavaScript context with 0. CEntry will use it to // Initialize the JavaScript context with 0. CEntry will use it to
// set the current context on the isolate. // set the current context on the isolate.
__ Move(kContextRegister, Smi::zero()); __ Move(kContextRegister, Smi::zero());
__ CallRuntime(Runtime::kWasmCompileLazy, 2); __ CallRuntime(Runtime::kWasmCompileLazy, 3);
__ SmiUntag(s1, a0); // move return value to s1 since a0 will be restored __ SmiUntag(s1, a0); // move return value to s1 since a0 will be restored
// to the value before the call // to the value before the call
......
...@@ -23,22 +23,24 @@ class EntryFrameConstants : public AllStatic { ...@@ -23,22 +23,24 @@ class EntryFrameConstants : public AllStatic {
class WasmCompileLazyFrameConstants : public TypedFrameConstants { class WasmCompileLazyFrameConstants : public TypedFrameConstants {
public: public:
// Number of gp parameters, without the instance.
static constexpr int kNumberOfSavedGpParamRegs = static constexpr int kNumberOfSavedGpParamRegs =
arraysize(wasm::kGpParamRegisters); arraysize(wasm::kGpParamRegisters) - 1;
static constexpr int kNumberOfSavedFpParamRegs = static constexpr int kNumberOfSavedFpParamRegs =
arraysize(wasm::kFpParamRegisters); arraysize(wasm::kFpParamRegisters);
static constexpr int kNumberOfSavedAllParamRegs = static constexpr int kNumberOfSavedAllParamRegs =
kNumberOfSavedGpParamRegs + kNumberOfSavedFpParamRegs; kNumberOfSavedGpParamRegs + kNumberOfSavedFpParamRegs;
static constexpr int kInstanceSpillOffset =
TYPED_FRAME_PUSHED_VALUE_OFFSET(0);
static constexpr int kParameterSpillsOffset[] = {
TYPED_FRAME_PUSHED_VALUE_OFFSET(1), TYPED_FRAME_PUSHED_VALUE_OFFSET(2),
TYPED_FRAME_PUSHED_VALUE_OFFSET(3), TYPED_FRAME_PUSHED_VALUE_OFFSET(4),
TYPED_FRAME_PUSHED_VALUE_OFFSET(5), TYPED_FRAME_PUSHED_VALUE_OFFSET(6)};
// FP-relative. // SP-relative.
// See Generate_WasmCompileLazy in builtins-riscv64.cc. static constexpr int kWasmInstanceOffset = 2 * kSystemPointerSize;
// TODO(riscv): add rvv v reg save static constexpr int kFunctionIndexOffset = 1 * kSystemPointerSize;
static constexpr int kWasmInstanceOffset = static constexpr int kNativeModuleOffset = 0;
TYPED_FRAME_PUSHED_VALUE_OFFSET(kNumberOfSavedAllParamRegs);
static constexpr int kFixedFrameSizeFromFp =
TypedFrameConstants::kFixedFrameSizeFromFp +
kNumberOfSavedGpParamRegs * kSystemPointerSize +
kNumberOfSavedFpParamRegs * kDoubleSize;
}; };
// Frame constructed by the {WasmDebugBreak} builtin. // Frame constructed by the {WasmDebugBreak} builtin.
......
...@@ -78,7 +78,13 @@ inline MemOperand GetStackSlot(int offset) { return MemOperand(fp, -offset); } ...@@ -78,7 +78,13 @@ inline MemOperand GetStackSlot(int offset) { return MemOperand(fp, -offset); }
inline MemOperand GetInstanceOperand() { return GetStackSlot(kInstanceOffset); } inline MemOperand GetInstanceOperand() { return GetStackSlot(kInstanceOffset); }
inline MemOperand GetMemOp(LiftoffAssembler* assm, Register addr, inline MemOperand GetMemOp(LiftoffAssembler* assm, Register addr,
Register offset, uintptr_t offset_imm) { Register offset, uintptr_t offset_imm,
bool i64_offset = false) {
if (!i64_offset && offset != no_reg) {
// extract bit[0:31] without sign extend
assm->ExtractBits(kScratchReg2, offset, 0, 32, false);
offset = kScratchReg2;
}
if (is_uint31(offset_imm)) { if (is_uint31(offset_imm)) {
int32_t offset_imm32 = static_cast<int32_t>(offset_imm); int32_t offset_imm32 = static_cast<int32_t>(offset_imm);
if (offset == no_reg) return MemOperand(addr, offset_imm32); if (offset == no_reg) return MemOperand(addr, offset_imm32);
...@@ -517,7 +523,8 @@ void LiftoffAssembler::Load(LiftoffRegister dst, Register src_addr, ...@@ -517,7 +523,8 @@ void LiftoffAssembler::Load(LiftoffRegister dst, Register src_addr,
Register offset_reg, uintptr_t offset_imm, Register offset_reg, uintptr_t offset_imm,
LoadType type, uint32_t* protected_load_pc, LoadType type, uint32_t* protected_load_pc,
bool is_load_mem, bool i64_offset) { bool is_load_mem, bool i64_offset) {
MemOperand src_op = liftoff::GetMemOp(this, src_addr, offset_reg, offset_imm); MemOperand src_op =
liftoff::GetMemOp(this, src_addr, offset_reg, offset_imm, i64_offset);
if (protected_load_pc) *protected_load_pc = pc_offset(); if (protected_load_pc) *protected_load_pc = pc_offset();
switch (type.value()) { switch (type.value()) {
...@@ -577,8 +584,10 @@ void LiftoffAssembler::Load(LiftoffRegister dst, Register src_addr, ...@@ -577,8 +584,10 @@ void LiftoffAssembler::Load(LiftoffRegister dst, Register src_addr,
void LiftoffAssembler::Store(Register dst_addr, Register offset_reg, void LiftoffAssembler::Store(Register dst_addr, Register offset_reg,
uintptr_t offset_imm, LiftoffRegister src, uintptr_t offset_imm, LiftoffRegister src,
StoreType type, LiftoffRegList pinned, StoreType type, LiftoffRegList pinned,
uint32_t* protected_store_pc, bool is_store_mem) { uint32_t* protected_store_pc, bool is_store_mem,
MemOperand dst_op = liftoff::GetMemOp(this, dst_addr, offset_reg, offset_imm); bool i64_offset) {
MemOperand dst_op =
liftoff::GetMemOp(this, dst_addr, offset_reg, offset_imm, i64_offset);
#if defined(V8_TARGET_BIG_ENDIAN) #if defined(V8_TARGET_BIG_ENDIAN)
if (is_store_mem) { if (is_store_mem) {
......
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