Commit 06bdd8d6 authored by Thibaud Michaud's avatar Thibaud Michaud Committed by Commit Bot

[liftoff][tail-call] Add indirect tail calls

R=clemensb@chromium.org

Bug: v8:10693
Change-Id: Ic71d873bf7099ba671b9db1e87392d54aeebd7cf
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2312096Reviewed-by: 's avatarClemens Backes <clemensb@chromium.org>
Commit-Queue: Thibaud Michaud <thibaudm@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68996}
parent d3940aa3
......@@ -3616,6 +3616,11 @@ void LiftoffAssembler::CallIndirect(const wasm::FunctionSig* sig,
Call(target);
}
void LiftoffAssembler::TailCallIndirect(Register target) {
DCHECK(target != no_reg);
Jump(target);
}
void LiftoffAssembler::CallRuntimeStub(WasmCode::RuntimeStubId sid) {
// A direct call to a wasm runtime stub defined in this module.
// Just encode the stub index. This will be patched at relocation.
......
......@@ -2629,6 +2629,11 @@ void LiftoffAssembler::CallIndirect(const wasm::FunctionSig* sig,
Call(target);
}
void LiftoffAssembler::TailCallIndirect(Register target) {
DCHECK(target.is_valid());
Jump(target);
}
void LiftoffAssembler::CallRuntimeStub(WasmCode::RuntimeStubId sid) {
// A direct call to a wasm runtime stub defined in this module.
// Just encode the stub index. This will be patched at relocation.
......
......@@ -4237,6 +4237,17 @@ void LiftoffAssembler::CallIndirect(const wasm::FunctionSig* sig,
}
}
void LiftoffAssembler::TailCallIndirect(Register target) {
// Since we have more cache registers than parameter registers, the
// {LiftoffCompiler} should always be able to place {target} in a register.
DCHECK(target.is_valid());
if (FLAG_untrusted_code_mitigations) {
RetpolineJump(target);
} else {
jmp(target);
}
}
void LiftoffAssembler::CallRuntimeStub(WasmCode::RuntimeStubId sid) {
// A direct call to a wasm runtime stub defined in this module.
// Just encode the stub index. This will be patched at relocation.
......
......@@ -1097,6 +1097,7 @@ class LiftoffAssembler : public TurboAssembler {
inline void CallIndirect(const FunctionSig* sig,
compiler::CallDescriptor* call_descriptor,
Register target);
inline void TailCallIndirect(Register target);
inline void CallRuntimeStub(WasmCode::RuntimeStubId sid);
// Reserve space in the current frame, store address to space in {addr}.
......
This diff is collapsed.
......@@ -3900,6 +3900,18 @@ void LiftoffAssembler::CallIndirect(const wasm::FunctionSig* sig,
}
}
void LiftoffAssembler::TailCallIndirect(Register target) {
if (target == no_reg) {
popq(kScratchRegister);
target = kScratchRegister;
}
if (FLAG_untrusted_code_mitigations) {
RetpolineJump(target);
} else {
jmp(target);
}
}
void LiftoffAssembler::CallRuntimeStub(WasmCode::RuntimeStubId sid) {
// A direct call to a wasm runtime stub defined in this module.
// Just encode the stub index. This will be patched at relocation.
......
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