Commit 9afba3ff authored by Liu Yu's avatar Liu Yu Committed by V8 LUCI CQ

Reland "[loong64][mips64][wasm] WasmCompileLazyFrame scanning"

This is a reland of commit 7af609f9

Original change's description:
> [loong64][mips64][wasm] WasmCompileLazyFrame scanning
>
> Port commit eb3fb6cb

Change-Id: I9d48e02cf4d5710c6c36efb1c82c584755867b9f
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3805838Reviewed-by: 's avatarZhao Jiazhong <zhaojiazhong-hf@loongson.cn>
Auto-Submit: Liu Yu <liuyu@loongson.cn>
Commit-Queue: Zhao Jiazhong <zhaojiazhong-hf@loongson.cn>
Cr-Commit-Position: refs/heads/main@{#82153}
parent 15b4fc63
......@@ -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;
})();
......@@ -2742,11 +2743,14 @@ 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(kWasmInstanceRegister, kWasmCompileLazyFuncIndexRegister, 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;
})();
......@@ -2751,11 +2752,14 @@ void Builtins::Generate_WasmCompileLazy(MacroAssembler* masm) {
__ bind(&simd_pushed);
// 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(kWasmInstanceRegister, kWasmCompileLazyFuncIndexRegister, 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: [a7, a6, a5, a4, a3, a2, a0].
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: [a7, a6, a5, a4, a3, a2, a0].
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