From 448fc89e4c6b76685f7ad6c745a8386640fcc4df Mon Sep 17 00:00:00 2001 From: MerryMage Date: Mon, 15 Oct 2018 21:00:45 +0100 Subject: [PATCH] JitRegCache: Count locks/unlocks --- .../Core/Core/PowerPC/Jit64/JitRegCache.cpp | 4 +-- Source/Core/Core/PowerPC/Jit64/JitRegCache.h | 26 +++++++++++++------ 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/Source/Core/Core/PowerPC/Jit64/JitRegCache.cpp b/Source/Core/Core/PowerPC/Jit64/JitRegCache.cpp index 3b65768db3..2307670268 100644 --- a/Source/Core/Core/PowerPC/Jit64/JitRegCache.cpp +++ b/Source/Core/Core/PowerPC/Jit64/JitRegCache.cpp @@ -212,13 +212,13 @@ X64Reg RegCache::RX(preg_t preg) const void RegCache::UnlockAll() { for (auto& reg : m_regs) - reg.Unlock(); + reg.UnlockAll(); } void RegCache::UnlockAllX() { for (auto& xreg : m_xregs) - xreg.Unlock(); + xreg.UnlockAll(); } bool RegCache::IsFreeX(size_t xreg) const diff --git a/Source/Core/Core/PowerPC/Jit64/JitRegCache.h b/Source/Core/Core/PowerPC/Jit64/JitRegCache.h index 9c59cab388..ac91409aa1 100644 --- a/Source/Core/Core/PowerPC/Jit64/JitRegCache.h +++ b/Source/Core/Core/PowerPC/Jit64/JitRegCache.h @@ -75,15 +75,20 @@ public: location = Gen::Imm32(imm32); } - bool IsLocked() const { return locked; } - void Lock() { locked = true; } - void Unlock() { locked = false; } + bool IsLocked() const { return locked > 0; } + void Lock() { locked++; } + void Unlock() + { + ASSERT(IsLocked()); + locked--; + } + void UnlockAll() { locked = 0; } // TODO: Remove from final version private: Gen::OpArg default_location{}; Gen::OpArg location{}; bool away = false; // value not in source register - bool locked = false; + size_t locked = 0; }; class X64CachedReg @@ -110,15 +115,20 @@ public: bool IsDirty() const { return dirty; } void MakeDirty() { dirty = true; } - bool IsLocked() const { return locked; } - void Lock() { locked = true; } - void Unlock() { locked = false; } + bool IsLocked() const { return locked > 0; } + void Lock() { locked++; } + void Unlock() + { + ASSERT(IsLocked()); + locked--; + } + void UnlockAll() { locked = 0; } // TODO: Remove from final version private: preg_t ppcReg = static_cast(Gen::INVALID_REG); bool free = true; bool dirty = false; - bool locked = false; + size_t locked = 0; }; class RegCache