Commit f9dd6f1f authored by Clemens Backes's avatar Clemens Backes Committed by V8 LUCI CQ

Reland "Avoid use of x18 register on arm64"

This is a reland of commit c2f25454.
We revert to using x17 for the call target, to be compliant with CFI.
Some comments are extended to point to that requirement.

Original change's description:
> Avoid use of x18 register on arm64
>
> This causes crashes on Windows, as x18 is the "platform register",
> holding a pointer to thread-local storage.
>
> R=jkummerow@chromium.org
> CC=seth.brenith@microsoft.com
>
> Bug: v8:12959
> Change-Id: I20b8bee145d4ab3a40d8d140d98572df8300251c
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3695569
> Reviewed-by: Seth Brenith <seth.brenith@microsoft.com>
> Commit-Queue: Clemens Backes <clemensb@chromium.org>
> Reviewed-by: Jakob Kummerow <jkummerow@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#81090}

Bug: v8:12959
Change-Id: If4ead8f7a7aece756cef7d32bb98d7d33dfe4911
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3702331Reviewed-by: 's avatarJakob Kummerow <jkummerow@chromium.org>
Reviewed-by: 's avatarSeth Brenith <seth.brenith@microsoft.com>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/main@{#81111}
parent c2d239dd
......@@ -3093,6 +3093,8 @@ void Builtins::Generate_WasmCompileLazy(MacroAssembler* masm) {
return saved_fp_regs;
})();
UseScratchRegisterScope temps(masm);
temps.Exclude(x17);
{
HardAbortScope hard_abort(masm); // Avoid calls to Abort.
FrameScope scope(masm, StackFrame::WASM_COMPILE_LAZY);
......@@ -3109,7 +3111,7 @@ void Builtins::Generate_WasmCompileLazy(MacroAssembler* masm) {
__ Mov(cp, Smi::zero());
__ CallRuntime(Runtime::kWasmCompileLazy, 2);
// Untag the returned Smi into into x17, for later use.
// Untag the returned Smi into into x17 (ip1), for later use.
static_assert(!kSavedGpRegs.has(x17));
__ SmiUntag(x17, kReturnRegister0);
......@@ -3119,12 +3121,14 @@ void Builtins::Generate_WasmCompileLazy(MacroAssembler* masm) {
}
// The runtime function returned the jump table slot offset as a Smi (now in
// x17). Use that to compute the jump target.
static_assert(!kSavedGpRegs.has(x18));
__ ldr(x18, MemOperand(
// x17). Use that to compute the jump target. Use x17 (ip1) for the branch
// target, to be compliant with CFI.
constexpr Register temp = x8;
static_assert(!kSavedGpRegs.has(temp));
__ ldr(temp, MemOperand(
kWasmInstanceRegister,
WasmInstanceObject::kJumpTableStartOffset - kHeapObjectTag));
__ add(x17, x18, Operand(x17));
__ add(x17, temp, Operand(x17));
// Finally, jump to the jump table slot for the function.
__ Jump(x17);
}
......
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