diff --git a/Core/Core.h b/Core/Core.h index 66a0a19be0..d9b07c7f6a 100644 --- a/Core/Core.h +++ b/Core/Core.h @@ -33,9 +33,10 @@ void Core_Halt(const char *msg); bool Core_IsStepping(); +// RUNNING must be at 0. enum CoreState { - CORE_RUNNING, + CORE_RUNNING = 0, CORE_STEPPING, CORE_POWERDOWN, CORE_ERROR, diff --git a/Core/CoreTiming.cpp b/Core/CoreTiming.cpp index 74eb4f4c91..b5d40610dd 100644 --- a/Core/CoreTiming.cpp +++ b/Core/CoreTiming.cpp @@ -421,7 +421,7 @@ void ProcessFifoWaitEvents() { break; } - } + } } void MoveEvents() @@ -438,7 +438,7 @@ void MoveEvents() // Move free events to threadsafe pool while(allocatedTsEvents > 0 && eventPool) - { + { Event *ev = eventPool; eventPool = ev->next; ev->next = eventTsPool; @@ -455,7 +455,7 @@ void Advance() ProcessFifoWaitEvents(); - if (!first) + if (!first) { // WARN_LOG(CPU, "WARNING - no events in queue. Setting downcount to 10000"); downcount += 10000; diff --git a/Core/MIPS/x86/Asm.cpp b/Core/MIPS/x86/Asm.cpp index 8aca44f08e..67a6611e64 100644 --- a/Core/MIPS/x86/Asm.cpp +++ b/Core/MIPS/x86/Asm.cpp @@ -78,7 +78,12 @@ void AsmRoutineManager::Generate(MIPSState *mips, MIPSComp::Jit *jit) outerLoop = GetCodePtr(); ABI_CallFunction(reinterpret_cast(&CoreTiming::Advance)); FixupBranch skipToRealDispatch = J(); //skip the sync and compare first time - + + dispatcherCheckCoreState = GetCodePtr(); + + CMP(32, M((void*)&coreState), Imm32(0)); + FixupBranch badCoreState = J_CC(CC_NZ, true); + dispatcher = GetCodePtr(); // The result of slice decrementation should be in flags if somebody jumped here // IMPORTANT - We jump on negative, not carry!!! @@ -144,10 +149,11 @@ 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); - - CMP(32, M((void*)&coreState), Imm8(0)); + + CMP(32, M((void*)&coreState), Imm32(0)); J_CC(CC_Z, outerLoop, true); + SetJumpTarget(badCoreState); //Landing pad for drec space ABI_PopAllCalleeSavedRegsAndAdjustStack(); RET(); diff --git a/Core/MIPS/x86/Asm.h b/Core/MIPS/x86/Asm.h index 22b93e174e..226332c676 100644 --- a/Core/MIPS/x86/Asm.h +++ b/Core/MIPS/x86/Asm.h @@ -65,6 +65,7 @@ public: const u8 *outerLoop; const u8 *dispatcher; + const u8 *dispatcherCheckCoreState; const u8 *dispatcherNoCheck; const u8 *fpException; diff --git a/Core/MIPS/x86/Jit.cpp b/Core/MIPS/x86/Jit.cpp index f046de4453..e79e624e2d 100644 --- a/Core/MIPS/x86/Jit.cpp +++ b/Core/MIPS/x86/Jit.cpp @@ -76,6 +76,7 @@ void Jit::RunLoopUntil(u64 globalticks) { // TODO: copy globalticks somewhere ((void (*)())asm_.enterCode)(); + // NOTICE_LOG(HLE, "Exited jitted code at %i, corestate=%i, dc=%i", CoreTiming::GetTicks() / 1000, (int)coreState, CoreTiming::downcount); } const u8 *Jit::DoJit(u32 em_address, JitBlock *b) @@ -168,7 +169,7 @@ void Jit::WriteExitDestInEAX() void Jit::WriteSyscallExit() { SUB(32, M(&CoreTiming::downcount), js.downcountAmount > 127 ? Imm32(js.downcountAmount) : Imm8(js.downcountAmount)); - JMP(asm_.dispatcher, true); + JMP(asm_.dispatcherCheckCoreState, true); } } // namespace