Commit fc945778 authored by Milad Fa's avatar Milad Fa Committed by V8 LUCI CQ

PPC/s390: [wasm][arm][ia32] Push instance only twice in lazy-compile builtin

Port d5b3d8e9

Original Commit Message:

    This change already landed for x64, now come arm and ia32. The code
    already existed for arm64.

    The wasm instance got pushed three times in the lazy-compile builtin:
    1) as part of the parameters;
    2) as a parameter for the runtime function;
    3) to load the jump table address after the runtime function;

    The third push can be avoided by loading the jump table address after
    all parameters get loaded from the stack again.

R=ahaas@chromium.org, joransiu@ca.ibm.com, junyan@redhat.com, midawson@redhat.com
BUG=
LOG=N

Change-Id: I731473b2d5e08e7ea5841ef589dd3f896b5302db
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3769698
Commit-Queue: Milad Farazmand <mfarazma@redhat.com>
Reviewed-by: 's avatarJunliang Yan <junyan@redhat.com>
Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/main@{#81789}
parent 8a44f0e5
......@@ -2940,12 +2940,7 @@ void Builtins::Generate_WasmCompileLazy(MacroAssembler* masm) {
__ MultiPush(gp_regs);
__ MultiPushF64AndV128(fp_regs, simd_regs);
// Push the Wasm instance for loading the jump table address after the
// runtime call.
__ Push(kWasmInstanceRegister);
// Push the Wasm instance again as an explicit argument to the runtime
// function.
// Push the Wasm instance as an explicit argument to the runtime function.
__ Push(kWasmInstanceRegister);
// Push the function index as second argument.
__ Push(kWasmCompileLazyFuncIndexRegister);
......@@ -2955,19 +2950,21 @@ void Builtins::Generate_WasmCompileLazy(MacroAssembler* masm) {
__ CallRuntime(Runtime::kWasmCompileLazy, 2);
// The runtime function returns the jump table slot offset as a Smi. Use
// that to compute the jump target in r11.
__ Pop(kWasmInstanceRegister);
__ LoadU64(
r11,
MemOperand(kWasmInstanceRegister,
WasmInstanceObject::kJumpTableStartOffset - kHeapObjectTag),
r0);
__ SmiUntag(kReturnRegister0);
__ AddS64(r11, r11, kReturnRegister0);
// r11 now holds the jump table slot where we want to jump to in the end.
__ mr(r11, kReturnRegister0);
// Restore registers.
__ MultiPopF64AndV128(fp_regs, simd_regs);
__ MultiPop(gp_regs);
// After the instance register has been restored, we can add the jump table
// start to the jump table offset already stored in r8.
__ LoadU64(
ip,
MemOperand(kWasmInstanceRegister,
WasmInstanceObject::kJumpTableStartOffset - kHeapObjectTag),
r0);
__ AddS64(r11, r11, ip);
}
// Finally, jump to the jump table slot for the function.
......
......@@ -2938,12 +2938,7 @@ void Builtins::Generate_WasmCompileLazy(MacroAssembler* masm) {
__ MultiPush(gp_regs);
__ MultiPushF64OrV128(fp_regs, ip);
// Push the Wasm instance for loading the jump table address after the
// runtime call.
__ Push(kWasmInstanceRegister);
// Push the Wasm instance again as an explicit argument to the runtime
// function.
// Push the Wasm instance as an explicit argument to the runtime function.
__ Push(kWasmInstanceRegister);
// Push the function index as second argument.
__ Push(kWasmCompileLazyFuncIndexRegister);
......@@ -2953,17 +2948,19 @@ void Builtins::Generate_WasmCompileLazy(MacroAssembler* masm) {
__ CallRuntime(Runtime::kWasmCompileLazy, 2);
// The runtime function returns the jump table slot offset as a Smi. Use
// that to compute the jump target in ip.
__ Pop(kWasmInstanceRegister);
__ LoadU64(ip, MemOperand(kWasmInstanceRegister,
WasmInstanceObject::kJumpTableStartOffset -
kHeapObjectTag));
__ SmiUntag(kReturnRegister0);
__ AddS64(ip, ip, kReturnRegister0);
// ip now holds the jump table slot where we want to jump to in the end.
__ mov(ip, kReturnRegister0);
// Restore registers.
__ MultiPopF64OrV128(fp_regs, r1);
__ MultiPop(gp_regs);
// After the instance register has been restored, we can add the jump table
// start to the jump table offset already stored in r8.
__ LoadU64(r0, MemOperand(kWasmInstanceRegister,
WasmInstanceObject::kJumpTableStartOffset -
kHeapObjectTag));
__ AddS64(ip, ip, r0);
}
// Finally, jump to the jump table slot for the function.
......
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