Commit 7af609f9 authored by Liu Yu's avatar Liu Yu Committed by V8 LUCI CQ

[loong64][mips64][wasm] WasmCompileLazyFrame scanning

Port commit eb3fb6cb

Change-Id: Ic2c87341458b7867fea2d5b8cea56315ac727477
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3803996
Auto-Submit: Liu Yu <liuyu@loongson.cn>
Commit-Queue: Zhao Jiazhong <zhaojiazhong-hf@loongson.cn>
Reviewed-by: 's avatarZhao Jiazhong <zhaojiazhong-hf@loongson.cn>
Cr-Commit-Position: refs/heads/main@{#82126}
parent 7961bd20
......@@ -2710,7 +2710,8 @@ 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,
// + instance
CHECK_EQ(WasmCompileLazyFrameConstants::kNumberOfSavedGpParamRegs + 1,
saved_gp_regs.Count());
return saved_gp_regs;
})();
......@@ -2743,10 +2744,15 @@ void Builtins::Generate_WasmCompileLazy(MacroAssembler* masm) {
// Pass instance and function index as an explicit arguments to the runtime
// function.
__ Push(kWasmInstanceRegister, kWasmCompileLazyFuncIndexRegister);
// Allocate a stack slot, where the runtime function can spill a pointer to
// the the NativeModule.
__ Push(zero_reg);
// 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);
// Untag the returned Smi into into t7, for later use.
static_assert(!kSavedGpRegs.has(t7));
......
......@@ -2705,7 +2705,8 @@ 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,
// + instance
CHECK_EQ(WasmCompileLazyFrameConstants::kNumberOfSavedGpParamRegs + 1,
saved_gp_regs.Count());
return saved_gp_regs;
})();
......@@ -2752,10 +2753,15 @@ void Builtins::Generate_WasmCompileLazy(MacroAssembler* masm) {
// Pass instance and function index as an explicit arguments to the runtime
// function.
__ Push(kWasmInstanceRegister, kWasmCompileLazyFuncIndexRegister);
// Allocate a stack slot, where the runtime function can spill a pointer to
// the the NativeModule.
__ Push(zero_reg);
// 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);
// Restore registers.
Label pop_doubles, simd_popped;
......
......@@ -22,17 +22,28 @@ class EntryFrameConstants : public AllStatic {
class WasmCompileLazyFrameConstants : public TypedFrameConstants {
public:
static constexpr int kNumberOfSavedGpParamRegs = 7;
// Number of gp parameters, without the instance.
static constexpr int kNumberOfSavedGpParamRegs = 6;
static constexpr int kNumberOfSavedFpParamRegs = 8;
static constexpr int kNumberOfSavedAllParamRegs = 15;
static constexpr int kNumberOfSavedAllParamRegs = 14;
// FP-relative.
// See Generate_WasmCompileLazy in builtins-loong64.cc.
static constexpr int kWasmInstanceOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(6);
static constexpr int kFixedFrameSizeFromFp =
TypedFrameConstants::kFixedFrameSizeFromFp +
kNumberOfSavedGpParamRegs * kPointerSize +
kNumberOfSavedFpParamRegs * kDoubleSize;
// On loong64, spilled registers are implicitly sorted backwards by number.
// We spill:
// a0: param0 = instance
// a2, a3, a4, a5, a6, a7: param1, param2, ..., param6
// in the following FP-relative order: [f7, f6, f5, f4, f3, f2, f1, f0].
static constexpr int kInstanceSpillOffset =
TYPED_FRAME_PUSHED_VALUE_OFFSET(6);
static constexpr int kParameterSpillsOffset[] = {
TYPED_FRAME_PUSHED_VALUE_OFFSET(5), TYPED_FRAME_PUSHED_VALUE_OFFSET(4),
TYPED_FRAME_PUSHED_VALUE_OFFSET(3), TYPED_FRAME_PUSHED_VALUE_OFFSET(2),
TYPED_FRAME_PUSHED_VALUE_OFFSET(1), TYPED_FRAME_PUSHED_VALUE_OFFSET(0)};
// 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.
......
......@@ -22,18 +22,28 @@ class EntryFrameConstants : public AllStatic {
class WasmCompileLazyFrameConstants : public TypedFrameConstants {
public:
static constexpr int kNumberOfSavedGpParamRegs = 7;
// Number of gp parameters, without the instance.
static constexpr int kNumberOfSavedGpParamRegs = 6;
static constexpr int kNumberOfSavedFpParamRegs = 7;
static constexpr int kNumberOfSavedAllParamRegs = 14;
static constexpr int kNumberOfSavedAllParamRegs = 13;
// FP-relative.
// See Generate_WasmCompileLazy in builtins-mips64.cc.
static constexpr int kWasmInstanceOffset = TYPED_FRAME_PUSHED_VALUE_OFFSET(6);
// On mips64, spilled registers are implicitly sorted backwards by number.
// We spill:
// a0: param0 = instance
// a2, a3, a4, a5, a6, a7: param1, param2, ..., param6
// in the following FP-relative order: [f14, f12, f10, f8, f6, f4, f2].
static constexpr int kInstanceSpillOffset =
TYPED_FRAME_PUSHED_VALUE_OFFSET(6);
static constexpr int kFixedFrameSizeFromFp =
TypedFrameConstants::kFixedFrameSizeFromFp +
kNumberOfSavedGpParamRegs * kPointerSize +
kNumberOfSavedFpParamRegs * kSimd128Size;
static constexpr int kParameterSpillsOffset[] = {
TYPED_FRAME_PUSHED_VALUE_OFFSET(5), TYPED_FRAME_PUSHED_VALUE_OFFSET(4),
TYPED_FRAME_PUSHED_VALUE_OFFSET(3), TYPED_FRAME_PUSHED_VALUE_OFFSET(2),
TYPED_FRAME_PUSHED_VALUE_OFFSET(1), TYPED_FRAME_PUSHED_VALUE_OFFSET(0)};
// 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.
......
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