From 070fe7f49934b3e8f22a73a7eadc01456096ee0b Mon Sep 17 00:00:00 2001 From: EmptyChaos Date: Mon, 12 Sep 2016 07:56:56 +0000 Subject: [PATCH] Jit64: Fix Dispatcher ABI (downcount) violation The dispatcher requires that the flags contain the downcount state. --- Source/Core/Core/PowerPC/Jit64/Jit.cpp | 4 ++-- Source/Core/Core/PowerPC/Jit64/JitAsm.cpp | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Source/Core/Core/PowerPC/Jit64/Jit.cpp b/Source/Core/Core/PowerPC/Jit64/Jit.cpp index e750b508aa..b0a9b1f1c9 100644 --- a/Source/Core/Core/PowerPC/Jit64/Jit.cpp +++ b/Source/Core/Core/PowerPC/Jit64/Jit.cpp @@ -612,7 +612,7 @@ const u8* Jit64::DoJit(u32 em_address, PPCAnalyst::CodeBuffer* code_buf, JitBloc // Downcount flag check. The last block decremented downcounter, and the flag should still be // available. - FixupBranch skip = J_CC(CC_NBE); + FixupBranch skip = J_CC(CC_G); MOV(32, PPCSTATE(pc), Imm32(js.blockStart)); JMP(asm_routines.doTiming, true); // downcount hit zero - go doTiming. SetJumpTarget(skip); @@ -675,7 +675,7 @@ const u8* Jit64::DoJit(u32 em_address, PPCAnalyst::CodeBuffer* code_buf, JitBloc ABI_CallFunctionC(JitInterface::CompileExceptionCheck, (u32)JitInterface::ExceptionType::EXCEPTIONS_PAIRED_QUANTIZE); ABI_PopRegistersAndAdjustStack({}, 0); - JMP(asm_routines.dispatcher, true); + JMP(asm_routines.dispatcherNoCheck, true); SwitchToNearCode(); // Insert a check that the GQRs are still the value we expect at diff --git a/Source/Core/Core/PowerPC/Jit64/JitAsm.cpp b/Source/Core/Core/PowerPC/Jit64/JitAsm.cpp index 15e2c82bfc..661f89b484 100644 --- a/Source/Core/Core/PowerPC/Jit64/JitAsm.cpp +++ b/Source/Core/Core/PowerPC/Jit64/JitAsm.cpp @@ -69,9 +69,9 @@ void Jit64AsmRoutineManager::Generate() SUB(32, PPCSTATE(downcount), R(RSCRATCH2)); dispatcher = GetCodePtr(); - // The result of slice decrementation should be in flags if somebody jumped here - // IMPORTANT - We jump on negative, not carry!!! - FixupBranch bail = J_CC(CC_BE, true); + // Expected result of SUB(32, PPCSTATE(downcount), Imm32(block_cycles)) is in RFLAGS. + // Branch if downcount is <= 0 (signed). + FixupBranch bail = J_CC(CC_LE, true); FixupBranch dbg_exit;