From 5271f36d78d559d6a7690e4ab6fbba4c3be70d00 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Fri, 5 Jul 2013 01:33:39 -0700 Subject: [PATCH] Output less code per memcheck. Somehow this also fixed a bug with memchecks that didn't hit, but I don't know why. Reverting and making them far jumps doesn't help.... strange. Anyway, this should be less code which is good. --- Core/MIPS/x86/Jit.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/Core/MIPS/x86/Jit.cpp b/Core/MIPS/x86/Jit.cpp index cdc5c2607..6578e7b03 100644 --- a/Core/MIPS/x86/Jit.cpp +++ b/Core/MIPS/x86/Jit.cpp @@ -712,6 +712,10 @@ void JitMemCheck(u32 addr, int size, int isWrite) if (CBreakPoints::CheckSkipFirst() == currentMIPS->pc) return; + // Did we already hit one? + if (coreState != CORE_RUNNING) + return; + MemCheck *check = CBreakPoints::GetMemCheck(addr, size); if (check) check->Action(addr, isWrite == 1, size, currentMIPS->pc); @@ -738,7 +742,8 @@ void Jit::JitSafeMem::MemCheckImm(ReadType type) void Jit::JitSafeMem::MemCheckAsm(ReadType type) { - auto memchecks = CBreakPoints::GetMemChecks(); + const auto memchecks = CBreakPoints::GetMemChecks(); + bool possible = false; for (auto it = memchecks.begin(), end = memchecks.end(); it != end; ++it) { if (!(it->cond & MEMCHECK_READ) && type == MEM_READ) @@ -746,6 +751,8 @@ void Jit::JitSafeMem::MemCheckAsm(ReadType type) if (!(it->cond & MEMCHECK_WRITE) && type == MEM_WRITE) continue; + possible = true; + FixupBranch skipNext, skipNextRange; if (it->end != 0) { @@ -766,14 +773,17 @@ void Jit::JitSafeMem::MemCheckAsm(ReadType type) jit_->ABI_CallFunctionACC(jit_->thunks.ProtectFunction((void *)&JitMemCheck, 3), R(xaddr_), size_, type == MEM_WRITE ? 1 : 0); jit_->POP(xaddr_); - jit_->CMP(32, M((void*)&coreState), Imm32(0)); - skipChecks_.push_back(jit_->J_CC(CC_NE, true)); - jit_->js.afterOp |= JitState::AFTER_CORE_STATE | JitState::AFTER_REWIND_PC_BAD_STATE; - jit_->SetJumpTarget(skipNext); if (it->end != 0) jit_->SetJumpTarget(skipNextRange); } + + if (possible) + { + jit_->CMP(32, M((void*)&coreState), Imm32(0)); + skipChecks_.push_back(jit_->J_CC(CC_NE, true)); + jit_->js.afterOp |= JitState::AFTER_CORE_STATE | JitState::AFTER_REWIND_PC_BAD_STATE; + } } void Jit::Comp_DoNothing(u32 op) { }