From ca04601b141bca5aea325aa2708c299ce964786b Mon Sep 17 00:00:00 2001 From: Ryan Houdek Date: Tue, 2 Dec 2014 19:07:31 -0600 Subject: [PATCH] [AArch64] Fixes the dispatcher Changes the dispatcher to make sure to we are saving the LR(X30) to the stack. Also makes sure to keep the stack aligned. AArch64's AAPCS64 mandates the stack to be quad-word aligned. Fixes the dispatcher from infinite looping due to a downcount check jumping to the dispatcher. This was because checking exceptions and the state pointer wouldn't reset the global conditional flags. So it would leave the timing/exception, jump to the start of the dispatcher and then jump back again due to the conditional branch. --- Source/Core/Core/PowerPC/JitArm64/JitAsm.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/Source/Core/Core/PowerPC/JitArm64/JitAsm.cpp b/Source/Core/Core/PowerPC/JitArm64/JitAsm.cpp index ee36b50e63..0cc89722cc 100644 --- a/Source/Core/Core/PowerPC/JitArm64/JitAsm.cpp +++ b/Source/Core/Core/PowerPC/JitArm64/JitAsm.cpp @@ -15,6 +15,9 @@ void JitArm64AsmRoutineManager::Generate() { enterCode = GetCodePtr(); + SUB(SP, SP, 16); + STR(INDEX_UNSIGNED, X30, SP, 0); + MOVI2R(X29, (u64)&PowerPC::ppcState); dispatcher = GetCodePtr(); @@ -64,14 +67,20 @@ void JitArm64AsmRoutineManager::Generate() // Check the state pointer to see if we are exiting // Gets checked on every exception check - MOVI2R(W0, (u64)PowerPC::GetStatePtr()); - LDR(INDEX_UNSIGNED, W0, W0, 0); - FixupBranch Exit = CBNZ(W0); + MOVI2R(X0, (u64)PowerPC::GetStatePtr()); + LDR(INDEX_UNSIGNED, W0, X0, 0); + + CMP(W0, 0); + FixupBranch Exit = B(CC_NEQ); B(dispatcher); SetJumpTarget(Exit); + LDR(INDEX_UNSIGNED, X30, SP, 0); + ADD(SP, SP, 16); + RET(X30); + FlushIcache(); }