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) {
CHECK_EQ(saved_gp_regs.Count(), arraysize(wasm::kGpParamRegisters));
// The Wasm instance must be part of the saved registers.
CHECK(saved_gp_regs.has(kWasmInstanceRegister));
CHECK_EQ(WasmCompileLazyFrameConstants::kNumberOfSavedGpParamRegs,
CHECK_EQ(WasmCompileLazyFrameConstants::kNumberOfSavedGpParamRegs + 1,
saved_gp_regs.Count());
return saved_gp_regs;
})();
......@@ -2808,11 +2808,13 @@ void Builtins::Generate_WasmCompileLazy(MacroAssembler* masm) {
// Pass instance and function index as an explicit arguments to the runtime
// 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
// set the current context on the isolate.
__ 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
// to the value before the call
......
......@@ -23,22 +23,24 @@ class EntryFrameConstants : public AllStatic {
class WasmCompileLazyFrameConstants : public TypedFrameConstants {
public:
// Number of gp parameters, without the instance.
static constexpr int kNumberOfSavedGpParamRegs =
arraysize(wasm::kGpParamRegisters);
arraysize(wasm::kGpParamRegisters) - 1;
static constexpr int kNumberOfSavedFpParamRegs =
arraysize(wasm::kFpParamRegisters);
static constexpr int kNumberOfSavedAllParamRegs =
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.
// See Generate_WasmCompileLazy in builtins-riscv64.cc.
// TODO(riscv): add rvv v reg save
static constexpr int kWasmInstanceOffset =
TYPED_FRAME_PUSHED_VALUE_OFFSET(kNumberOfSavedAllParamRegs);
static constexpr int kFixedFrameSizeFromFp =
TypedFrameConstants::kFixedFrameSizeFromFp +
kNumberOfSavedGpParamRegs * kSystemPointerSize +
kNumberOfSavedFpParamRegs * kDoubleSize;
// SP-relative.
static constexpr int kWasmInstanceOffset = 2 * kSystemPointerSize;
static constexpr int kFunctionIndexOffset = 1 * kSystemPointerSize;
static constexpr int kNativeModuleOffset = 0;
};
// Frame constructed by the {WasmDebugBreak} builtin.
......
......@@ -78,7 +78,13 @@ inline MemOperand GetStackSlot(int offset) { return MemOperand(fp, -offset); }
inline MemOperand GetInstanceOperand() { return GetStackSlot(kInstanceOffset); }
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)) {
int32_t offset_imm32 = static_cast<int32_t>(offset_imm);
if (offset == no_reg) return MemOperand(addr, offset_imm32);
......@@ -517,7 +523,8 @@ void LiftoffAssembler::Load(LiftoffRegister dst, Register src_addr,
Register offset_reg, uintptr_t offset_imm,
LoadType type, uint32_t* protected_load_pc,
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();
switch (type.value()) {
......@@ -577,8 +584,10 @@ void LiftoffAssembler::Load(LiftoffRegister dst, Register src_addr,
void LiftoffAssembler::Store(Register dst_addr, Register offset_reg,
uintptr_t offset_imm, LiftoffRegister src,
StoreType type, LiftoffRegList pinned,
uint32_t* protected_store_pc, bool is_store_mem) {
MemOperand dst_op = liftoff::GetMemOp(this, dst_addr, offset_reg, offset_imm);
uint32_t* protected_store_pc, bool is_store_mem,
bool i64_offset) {
MemOperand dst_op =
liftoff::GetMemOp(this, dst_addr, offset_reg, offset_imm, i64_offset);
#if defined(V8_TARGET_BIG_ENDIAN)
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