From d448ed3308dfa02dda19eea0d8ec2db21a1f50b1 Mon Sep 17 00:00:00 2001 From: MerryMage Date: Sun, 7 Oct 2018 09:05:37 +0100 Subject: [PATCH] JitRegCache: Fix SanityCheck --- Source/Core/Core/PowerPC/Jit64/Jit.cpp | 4 ++-- .../Core/Core/PowerPC/Jit64/JitRegCache.cpp | 20 ++++++++++--------- Source/Core/Core/PowerPC/Jit64/JitRegCache.h | 2 +- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/Source/Core/Core/PowerPC/Jit64/Jit.cpp b/Source/Core/Core/PowerPC/Jit64/Jit.cpp index 44f1b8566f..c4cfefd77a 100644 --- a/Source/Core/Core/PowerPC/Jit64/Jit.cpp +++ b/Source/Core/Core/PowerPC/Jit64/Jit.cpp @@ -935,10 +935,10 @@ u8* Jit64::DoJit(u32 em_address, JitBlock* b, u32 nextPC) } #if defined(_DEBUG) || defined(DEBUGFAST) - if (gpr.SanityCheck() || fpr.SanityCheck()) + if (!gpr.SanityCheck() || !fpr.SanityCheck()) { std::string ppc_inst = Common::GekkoDisassembler::Disassemble(op.inst.hex, em_address); - // NOTICE_LOG(DYNA_REC, "Unflushed register: %s", ppc_inst.c_str()); + NOTICE_LOG(DYNA_REC, "Unflushed register: %s", ppc_inst.c_str()); } #endif i += js.skipInstructions; diff --git a/Source/Core/Core/PowerPC/Jit64/JitRegCache.cpp b/Source/Core/Core/PowerPC/Jit64/JitRegCache.cpp index a7f5e81f0c..3b65768db3 100644 --- a/Source/Core/Core/PowerPC/Jit64/JitRegCache.cpp +++ b/Source/Core/Core/PowerPC/Jit64/JitRegCache.cpp @@ -92,7 +92,7 @@ void RegCache::FlushLockX(X64Reg reg1, X64Reg reg2) LockX(reg2); } -int RegCache::SanityCheck() const +bool RegCache::SanityCheck() const { for (size_t i = 0; i < m_regs.size(); i++) { @@ -100,21 +100,23 @@ int RegCache::SanityCheck() const { case PPCCachedReg::LocationType::Default: case PPCCachedReg::LocationType::SpeculativeImmediate: + case PPCCachedReg::LocationType::Immediate: break; case PPCCachedReg::LocationType::Bound: { - Gen::X64Reg simple = m_regs[i].Location().GetSimpleReg(); - if (m_xregs[simple].IsLocked()) - return 1; - if (m_xregs[simple].Contents() != i) - return 2; + if (m_regs[i].IsLocked()) + return false; + + Gen::X64Reg xr = m_regs[i].Location().GetSimpleReg(); + if (m_xregs[xr].IsLocked()) + return false; + if (m_xregs[xr].Contents() != i) + return false; break; } - case PPCCachedReg::LocationType::Immediate: - return 3; } } - return 0; + return true; } void RegCache::KillImmediate(preg_t preg, bool doLoad, bool makeDirty) diff --git a/Source/Core/Core/PowerPC/Jit64/JitRegCache.h b/Source/Core/Core/PowerPC/Jit64/JitRegCache.h index 215b7f1898..9c59cab388 100644 --- a/Source/Core/Core/PowerPC/Jit64/JitRegCache.h +++ b/Source/Core/Core/PowerPC/Jit64/JitRegCache.h @@ -147,7 +147,7 @@ public: void FlushLockX(Gen::X64Reg reg); void FlushLockX(Gen::X64Reg reg1, Gen::X64Reg reg2); - int SanityCheck() const; + bool SanityCheck() const; void KillImmediate(preg_t preg, bool doLoad, bool makeDirty); // TODO - instead of doload, use "read", "write"