JitRegCache: Simplify ASSERTs
This commit is contained in:
parent
ff0a6b8331
commit
ba33e1e69b
|
@ -50,20 +50,15 @@ void RegCache::SetEmitter(XEmitter* emitter)
|
||||||
|
|
||||||
void RegCache::Flush(FlushMode mode, BitSet32 regsToFlush)
|
void RegCache::Flush(FlushMode mode, BitSet32 regsToFlush)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < m_xregs.size(); i++)
|
ASSERT_MSG(
|
||||||
{
|
DYNA_REC,
|
||||||
if (m_xregs[i].IsLocked())
|
std::none_of(m_xregs.begin(), m_xregs.end(), [](const auto& x) { return x.IsLocked(); }),
|
||||||
{
|
"Someone forgot to unlock a X64 reg");
|
||||||
PanicAlert("Someone forgot to unlock X64 reg %zu", i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (unsigned int i : regsToFlush)
|
for (unsigned int i : regsToFlush)
|
||||||
{
|
{
|
||||||
if (m_regs[i].IsLocked())
|
ASSERT_MSG(DYNA_REC, !m_regs[i].IsLocked(), "Someone forgot to unlock PPC reg %u (X64 reg %i).",
|
||||||
{
|
i, RX(i));
|
||||||
PanicAlert("Someone forgot to unlock PPC reg %u (X64 reg %i).", i, RX(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (m_regs[i].GetLocationType())
|
switch (m_regs[i].GetLocationType())
|
||||||
{
|
{
|
||||||
|
@ -85,8 +80,7 @@ void RegCache::Flush(FlushMode mode, BitSet32 regsToFlush)
|
||||||
|
|
||||||
void RegCache::FlushR(X64Reg reg)
|
void RegCache::FlushR(X64Reg reg)
|
||||||
{
|
{
|
||||||
if (reg >= m_xregs.size())
|
ASSERT_MSG(DYNA_REC, reg < m_xregs.size(), "Flushing non-existent reg %i", reg);
|
||||||
PanicAlert("Flushing non existent reg");
|
|
||||||
ASSERT(!m_xregs[reg].IsLocked());
|
ASSERT(!m_xregs[reg].IsLocked());
|
||||||
if (!m_xregs[reg].IsFree())
|
if (!m_xregs[reg].IsFree())
|
||||||
{
|
{
|
||||||
|
@ -160,20 +154,22 @@ void RegCache::BindToRegister(size_t i, bool doLoad, bool makeDirty)
|
||||||
if (!m_regs[i].IsBound())
|
if (!m_regs[i].IsBound())
|
||||||
{
|
{
|
||||||
X64Reg xr = GetFreeXReg();
|
X64Reg xr = GetFreeXReg();
|
||||||
if (m_xregs[xr].IsDirty())
|
|
||||||
PanicAlert("Xreg already dirty");
|
ASSERT_MSG(DYNA_REC, !m_xregs[xr].IsDirty(), "Xreg %i already dirty", xr);
|
||||||
if (m_xregs[xr].IsLocked())
|
ASSERT_MSG(DYNA_REC, !m_xregs[xr].IsLocked(), "GetFreeXReg returned locked register");
|
||||||
PanicAlert("GetFreeXReg returned locked register");
|
|
||||||
m_xregs[xr].BoundTo(i, makeDirty || m_regs[i].IsAway());
|
m_xregs[xr].BoundTo(i, makeDirty || m_regs[i].IsAway());
|
||||||
|
|
||||||
if (doLoad)
|
if (doLoad)
|
||||||
LoadRegister(i, xr);
|
|
||||||
for (size_t j = 0; j < m_regs.size(); j++)
|
|
||||||
{
|
{
|
||||||
if (i != j && m_regs[j].Location().IsSimpleReg(xr))
|
LoadRegister(i, xr);
|
||||||
{
|
|
||||||
Crash();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ASSERT_MSG(DYNA_REC,
|
||||||
|
std::none_of(m_regs.begin(), m_regs.end(),
|
||||||
|
[xr](const auto& r) { return r.Location().IsSimpleReg(xr); }),
|
||||||
|
"Xreg %i already bound", xr);
|
||||||
|
|
||||||
m_regs[i].BoundTo(xr);
|
m_regs[i].BoundTo(xr);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -183,10 +179,7 @@ void RegCache::BindToRegister(size_t i, bool doLoad, bool makeDirty)
|
||||||
m_xregs[RX(i)].MakeDirty(makeDirty);
|
m_xregs[RX(i)].MakeDirty(makeDirty);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_xregs[RX(i)].IsLocked())
|
ASSERT_MSG(DYNA_REC, !m_xregs[RX(i)].IsLocked(), "WTF, this reg should have been flushed");
|
||||||
{
|
|
||||||
PanicAlert("Seriously WTF, this reg should have been flushed");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegCache::StoreFromRegister(size_t i, FlushMode mode)
|
void RegCache::StoreFromRegister(size_t i, FlushMode mode)
|
||||||
|
@ -224,11 +217,8 @@ const OpArg& RegCache::R(size_t preg) const
|
||||||
|
|
||||||
X64Reg RegCache::RX(size_t preg) const
|
X64Reg RegCache::RX(size_t preg) const
|
||||||
{
|
{
|
||||||
if (m_regs[preg].IsBound())
|
ASSERT_MSG(DYNA_REC, m_regs[preg].IsBound(), "Unbound register - %zu", preg);
|
||||||
return m_regs[preg].Location().GetSimpleReg();
|
return m_regs[preg].Location().GetSimpleReg();
|
||||||
|
|
||||||
PanicAlert("Unbound register - %zu", preg);
|
|
||||||
return Gen::INVALID_REG;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RegCache::UnlockAll()
|
void RegCache::UnlockAll()
|
||||||
|
@ -288,7 +278,7 @@ X64Reg RegCache::GetFreeXReg()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Still no dice? Die!
|
// Still no dice? Die!
|
||||||
ASSERT_MSG(DYNA_REC, 0, "Regcache ran out of regs");
|
ASSERT_MSG(DYNA_REC, false, "Regcache ran out of regs");
|
||||||
return INVALID_REG;
|
return INVALID_REG;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue