From 351d095ffffccd424763cb77b13f716b5e4155c1 Mon Sep 17 00:00:00 2001 From: JosJuice Date: Fri, 20 Aug 2021 15:21:24 +0200 Subject: [PATCH] JitArm64: Optimize a few tail calls Maybe "tail call" isn't quite the right term for what this code is doing, since it's jumping to the dispatcher rather than returning, but it's the same optimization as for a tail call. --- Source/Core/Core/PowerPC/JitArm64/Jit.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Source/Core/Core/PowerPC/JitArm64/Jit.cpp b/Source/Core/Core/PowerPC/JitArm64/Jit.cpp index c1519450ed..a2aae7c2d3 100644 --- a/Source/Core/Core/PowerPC/JitArm64/Jit.cpp +++ b/Source/Core/Core/PowerPC/JitArm64/Jit.cpp @@ -344,8 +344,9 @@ void JitArm64::IntializeSpeculativeConstants() STR(IndexType::Unsigned, DISPATCHER_PC, PPC_REG, PPCSTATE_OFF(pc)); MOVP2R(ARM64Reg::X8, &JitInterface::CompileExceptionCheck); MOVI2R(ARM64Reg::W0, static_cast(JitInterface::ExceptionType::SpeculativeConstants)); - BLR(ARM64Reg::X8); - B(dispatcher_no_check); + // Write dispatcher_no_check to LR for tail call + MOVP2R(ARM64Reg::X30, dispatcher_no_check); + BR(ARM64Reg::X8); SwitchToNearCode(); } @@ -837,10 +838,11 @@ bool JitArm64::DoJit(u32 em_address, JitBlock* b, u32 nextPC) SetJumpTarget(fail); MOVI2R(DISPATCHER_PC, js.blockStart); STR(IndexType::Unsigned, DISPATCHER_PC, PPC_REG, PPCSTATE_OFF(pc)); + MOVP2R(ARM64Reg::X8, &JitInterface::CompileExceptionCheck); MOVI2R(ARM64Reg::W0, static_cast(JitInterface::ExceptionType::PairedQuantize)); - MOVP2R(ARM64Reg::X1, &JitInterface::CompileExceptionCheck); - BLR(ARM64Reg::X1); - B(dispatcher_no_check); + // Write dispatcher_no_check to LR for tail call + MOVP2R(ARM64Reg::X30, dispatcher_no_check); + BR(ARM64Reg::X8); SwitchToNearCode(); SetJumpTarget(no_fail); js.assumeNoPairedQuantize = true;