From e87e1606c571dd030ff0fd3f0b641dcf54b88fc1 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Thu, 19 Jun 2014 08:01:45 -0700 Subject: [PATCH] Fix func replacements and delay slots on arm. Fixes #6303. --- Core/MIPS/ARM/ArmCompReplace.cpp | 2 +- Core/MIPS/ARM/ArmJit.cpp | 26 +++++++++++++++++++------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/Core/MIPS/ARM/ArmCompReplace.cpp b/Core/MIPS/ARM/ArmCompReplace.cpp index 0c11ec52dd..0b4e0cf0a7 100644 --- a/Core/MIPS/ARM/ArmCompReplace.cpp +++ b/Core/MIPS/ARM/ArmCompReplace.cpp @@ -26,7 +26,7 @@ namespace MIPSComp { int Jit::Replace_fabsf() { fpr.MapDirtyIn(0, 12); VABS(fpr.R(0), fpr.R(12)); - return 6; // Number of instructions in the MIPS function + return 4; // Number of instructions in the MIPS function } } \ No newline at end of file diff --git a/Core/MIPS/ARM/ArmJit.cpp b/Core/MIPS/ARM/ArmJit.cpp index f4b736b6a7..edf613e9a9 100644 --- a/Core/MIPS/ARM/ArmJit.cpp +++ b/Core/MIPS/ARM/ArmJit.cpp @@ -377,15 +377,27 @@ bool Jit::ReplaceJalTo(u32 dest) { MIPSReplaceFunc repl = entry->jitReplaceFunc; int cycles = (this->*repl)(); js.downcountAmount += cycles; - // No writing exits, keep going! - - // Add a trigger so that if the inlined code changes, we invalidate this block. - // TODO: Correctly determine the size of this block. - blocks.ProxyBlock(js.blockStart, dest, 4, GetCodePtr()); - return true; } else { - return false; + gpr.SetImm(MIPS_REG_RA, js.compilerPC + 8); + CompileDelaySlot(DELAYSLOT_NICE); + FlushAll(); + if (BLInRange((const void *)(entry->replaceFunc))) { + BL((const void *)(entry->replaceFunc)); + } else { + MOVI2R(R0, (u32)entry->replaceFunc); + BL(R0); + } + WriteDownCountR(R0); + js.downcountAmount = 0; // we just subtracted most of it } + + js.compilerPC += 4; + // No writing exits, keep going! + + // Add a trigger so that if the inlined code changes, we invalidate this block. + // TODO: Correctly determine the size of this block. + blocks.ProxyBlock(js.blockStart, dest, 4, GetCodePtr()); + return true; } void Jit::Comp_ReplacementFunc(MIPSOpcode op)