diff --git a/Source/Core/Core/PowerPC/Jit64/Jit.cpp b/Source/Core/Core/PowerPC/Jit64/Jit.cpp index 545047c40c..6934f66479 100644 --- a/Source/Core/Core/PowerPC/Jit64/Jit.cpp +++ b/Source/Core/Core/PowerPC/Jit64/Jit.cpp @@ -646,6 +646,15 @@ void Jit64::WriteRfiExitDestInRSCRATCH() JMP(asm_routines.dispatcher, true); } +void Jit64::WriteIdleExit(u32 destination) +{ + ABI_PushRegistersAndAdjustStack({}, 0); + ABI_CallFunction(CoreTiming::Idle); + ABI_PopRegistersAndAdjustStack({}, 0); + MOV(32, PPCSTATE(pc), Imm32(destination)); + WriteExceptionExit(); +} + void Jit64::WriteExceptionExit() { Cleanup(); diff --git a/Source/Core/Core/PowerPC/Jit64/Jit.h b/Source/Core/Core/PowerPC/Jit64/Jit.h index 452cdbdfc6..d2baa32c8a 100644 --- a/Source/Core/Core/PowerPC/Jit64/Jit.h +++ b/Source/Core/Core/PowerPC/Jit64/Jit.h @@ -84,6 +84,7 @@ public: void WriteExceptionExit(); void WriteExternalExceptionExit(); void WriteRfiExitDestInRSCRATCH(); + void WriteIdleExit(u32 destination); bool Cleanup(); void GenerateConstantOverflow(bool overflow); diff --git a/Source/Core/Core/PowerPC/Jit64/Jit_Branch.cpp b/Source/Core/Core/PowerPC/Jit64/Jit_Branch.cpp index 2ebb8e4175..bd257a3977 100644 --- a/Source/Core/Core/PowerPC/Jit64/Jit_Branch.cpp +++ b/Source/Core/Core/PowerPC/Jit64/Jit_Branch.cpp @@ -93,11 +93,7 @@ void Jit64::bx(UGeckoInstruction inst) #endif if (js.op->branchIsIdleLoop) { - ABI_PushRegistersAndAdjustStack({}, 0); - ABI_CallFunction(CoreTiming::Idle); - ABI_PopRegistersAndAdjustStack({}, 0); - MOV(32, PPCSTATE(pc), Imm32(js.op->branchTo)); - WriteExceptionExit(); + WriteIdleExit(js.op->branchTo); } else { @@ -159,11 +155,7 @@ void Jit64::bcx(UGeckoInstruction inst) if (js.op->branchIsIdleLoop) { - ABI_PushRegistersAndAdjustStack({}, 0); - ABI_CallFunction(CoreTiming::Idle); - ABI_PopRegistersAndAdjustStack({}, 0); - MOV(32, PPCSTATE(pc), Imm32(js.op->branchTo)); - WriteExceptionExit(); + WriteIdleExit(js.op->branchTo); } else { @@ -288,11 +280,7 @@ void Jit64::bclrx(UGeckoInstruction inst) if (js.op->branchIsIdleLoop) { - ABI_PushRegistersAndAdjustStack({}, 0); - ABI_CallFunction(CoreTiming::Idle); - ABI_PopRegistersAndAdjustStack({}, 0); - MOV(32, PPCSTATE(pc), Imm32(js.op->branchTo)); - WriteExceptionExit(); + WriteIdleExit(js.op->branchTo); } else { diff --git a/Source/Core/Core/PowerPC/Jit64/Jit_Integer.cpp b/Source/Core/Core/PowerPC/Jit64/Jit_Integer.cpp index 057d039b8d..8eadc3d33f 100644 --- a/Source/Core/Core/PowerPC/Jit64/Jit_Integer.cpp +++ b/Source/Core/Core/PowerPC/Jit64/Jit_Integer.cpp @@ -368,11 +368,7 @@ void Jit64::DoMergedBranch() if (next.LK) MOV(32, PPCSTATE(spr[SPR_LR]), Imm32(nextPC + 4)); - ABI_PushRegistersAndAdjustStack({}, 0); - ABI_CallFunction(CoreTiming::Idle); - ABI_PopRegistersAndAdjustStack({}, 0); - MOV(32, PPCSTATE(pc), Imm32(js.op[1].branchTo)); - WriteExceptionExit(); + WriteIdleExit(js.op[1].branchTo); } else if (next.OPCD == 16) // bcx {