JitRegCache: Fix SanityCheck

This commit is contained in:
MerryMage 2018-10-07 09:05:37 +01:00
parent d5999bc0df
commit d448ed3308
3 changed files with 14 additions and 12 deletions

View File

@ -935,10 +935,10 @@ u8* Jit64::DoJit(u32 em_address, JitBlock* b, u32 nextPC)
} }
#if defined(_DEBUG) || defined(DEBUGFAST) #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); 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 #endif
i += js.skipInstructions; i += js.skipInstructions;

View File

@ -92,7 +92,7 @@ void RegCache::FlushLockX(X64Reg reg1, X64Reg reg2)
LockX(reg2); LockX(reg2);
} }
int RegCache::SanityCheck() const bool RegCache::SanityCheck() const
{ {
for (size_t i = 0; i < m_regs.size(); i++) 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::Default:
case PPCCachedReg::LocationType::SpeculativeImmediate: case PPCCachedReg::LocationType::SpeculativeImmediate:
case PPCCachedReg::LocationType::Immediate:
break; break;
case PPCCachedReg::LocationType::Bound: case PPCCachedReg::LocationType::Bound:
{ {
Gen::X64Reg simple = m_regs[i].Location().GetSimpleReg(); if (m_regs[i].IsLocked())
if (m_xregs[simple].IsLocked()) return false;
return 1;
if (m_xregs[simple].Contents() != i) Gen::X64Reg xr = m_regs[i].Location().GetSimpleReg();
return 2; if (m_xregs[xr].IsLocked())
return false;
if (m_xregs[xr].Contents() != i)
return false;
break; break;
} }
case PPCCachedReg::LocationType::Immediate:
return 3;
} }
} }
return 0; return true;
} }
void RegCache::KillImmediate(preg_t preg, bool doLoad, bool makeDirty) void RegCache::KillImmediate(preg_t preg, bool doLoad, bool makeDirty)

View File

@ -147,7 +147,7 @@ public:
void FlushLockX(Gen::X64Reg reg); void FlushLockX(Gen::X64Reg reg);
void FlushLockX(Gen::X64Reg reg1, Gen::X64Reg reg2); void FlushLockX(Gen::X64Reg reg1, Gen::X64Reg reg2);
int SanityCheck() const; bool SanityCheck() const;
void KillImmediate(preg_t preg, bool doLoad, bool makeDirty); void KillImmediate(preg_t preg, bool doLoad, bool makeDirty);
// TODO - instead of doload, use "read", "write" // TODO - instead of doload, use "read", "write"