Skip to content

Commit

Permalink
JitRegCache: Count locks/unlocks
Browse files Browse the repository at this point in the history
  • Loading branch information
MerryMage committed Oct 28, 2018
1 parent 2dce7e6 commit 448fc89
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
4 changes: 2 additions & 2 deletions Source/Core/Core/PowerPC/Jit64/JitRegCache.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -212,13 +212,13 @@ X64Reg RegCache::RX(preg_t preg) const
void RegCache::UnlockAll() void RegCache::UnlockAll()
{ {
for (auto& reg : m_regs) for (auto& reg : m_regs)
reg.Unlock(); reg.UnlockAll();
} }


void RegCache::UnlockAllX() void RegCache::UnlockAllX()
{ {
for (auto& xreg : m_xregs) for (auto& xreg : m_xregs)
xreg.Unlock(); xreg.UnlockAll();
} }


bool RegCache::IsFreeX(size_t xreg) const bool RegCache::IsFreeX(size_t xreg) const
Expand Down
26 changes: 18 additions & 8 deletions Source/Core/Core/PowerPC/Jit64/JitRegCache.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -75,15 +75,20 @@ class PPCCachedReg
location = Gen::Imm32(imm32); location = Gen::Imm32(imm32);
} }


bool IsLocked() const { return locked; } bool IsLocked() const { return locked > 0; }
void Lock() { locked = true; } void Lock() { locked++; }
void Unlock() { locked = false; } void Unlock()
{
ASSERT(IsLocked());
locked--;
}
void UnlockAll() { locked = 0; } // TODO: Remove from final version


private: private:
Gen::OpArg default_location{}; Gen::OpArg default_location{};
Gen::OpArg location{}; Gen::OpArg location{};
bool away = false; // value not in source register bool away = false; // value not in source register
bool locked = false; size_t locked = 0;
}; };


class X64CachedReg class X64CachedReg
Expand All @@ -110,15 +115,20 @@ class X64CachedReg
bool IsDirty() const { return dirty; } bool IsDirty() const { return dirty; }
void MakeDirty() { dirty = true; } void MakeDirty() { dirty = true; }


bool IsLocked() const { return locked; } bool IsLocked() const { return locked > 0; }
void Lock() { locked = true; } void Lock() { locked++; }
void Unlock() { locked = false; } void Unlock()
{
ASSERT(IsLocked());
locked--;
}
void UnlockAll() { locked = 0; } // TODO: Remove from final version


private: private:
preg_t ppcReg = static_cast<preg_t>(Gen::INVALID_REG); preg_t ppcReg = static_cast<preg_t>(Gen::INVALID_REG);
bool free = true; bool free = true;
bool dirty = false; bool dirty = false;
bool locked = false; size_t locked = 0;
}; };


class RegCache class RegCache
Expand Down

0 comments on commit 448fc89

Please sign in to comment.