From c1757ee1662d103407f851ec8f9ae83b2849d7ff Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Wed, 23 Jan 2013 22:24:20 -0800 Subject: [PATCH] Check downcount in jit after a syscall. --- Core/MIPS/ARM/ArmAsm.cpp | 5 +++++ Core/MIPS/x86/Asm.cpp | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/Core/MIPS/ARM/ArmAsm.cpp b/Core/MIPS/ARM/ArmAsm.cpp index d6b43d126d..5f317de8f7 100644 --- a/Core/MIPS/ARM/ArmAsm.cpp +++ b/Core/MIPS/ARM/ArmAsm.cpp @@ -115,6 +115,10 @@ void Jit::GenerateFixedCode() dispatcherCheckCoreState = GetCodePtr(); + // The result of slice decrementation should be in flags if somebody jumped here + // IMPORTANT - We jump on negative, not carry!!! + FixupBranch bailCoreState = B_CC(CC_MI); + ARMABI_MOVI2R(R0, (u32)&coreState); LDR(R0, R0); CMP(R0, 0); @@ -158,6 +162,7 @@ void Jit::GenerateFixedCode() B(dispatcherNoCheck); // no point in special casing this SetJumpTarget(bail); + SetJumpTarget(bailCoreState); ARMABI_MOVI2R(R0, (u32)&coreState); LDR(R0, R0); diff --git a/Core/MIPS/x86/Asm.cpp b/Core/MIPS/x86/Asm.cpp index 8ddb13e9e8..1d4367c757 100644 --- a/Core/MIPS/x86/Asm.cpp +++ b/Core/MIPS/x86/Asm.cpp @@ -81,11 +81,16 @@ void AsmRoutineManager::Generate(MIPSState *mips, MIPSComp::Jit *jit) dispatcherCheckCoreState = GetCodePtr(); + // The result of slice decrementation should be in flags if somebody jumped here + // IMPORTANT - We jump on negative, not carry!!! + FixupBranch bailCoreState = J_CC(CC_S, true); + CMP(32, M((void*)&coreState), Imm32(0)); FixupBranch badCoreState = J_CC(CC_NZ, true); FixupBranch skipToRealDispatch2 = J(); //skip the sync and compare first time 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_S, true); @@ -134,6 +139,7 @@ void AsmRoutineManager::Generate(MIPSState *mips, MIPSComp::Jit *jit) JMP(dispatcherNoCheck); // Let's just dispatch again, we'll enter the block since we know it's there. SetJumpTarget(bail); + SetJumpTarget(bailCoreState); CMP(32, M((void*)&coreState), Imm32(0)); J_CC(CC_Z, outerLoop, true);