From 641bb72b40d344c72b86925af1cef79666a2d5bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 6 Aug 2019 15:33:11 +0200 Subject: [PATCH] Memchecks: Avoid taking the mutex lock if no memchecks active. Possible minor speedup in GoW and other block-copy-heavy games. --- Core/Debugger/Breakpoints.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Core/Debugger/Breakpoints.cpp b/Core/Debugger/Breakpoints.cpp index dd6184d2ce..920bd8955f 100644 --- a/Core/Debugger/Breakpoints.cpp +++ b/Core/Debugger/Breakpoints.cpp @@ -16,6 +16,7 @@ // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. #include +#include #include #include "Common/Log.h" @@ -28,6 +29,8 @@ #include "Core/MIPS/JitCommon/JitCommon.h" #include "Core/CoreTiming.h" +std::atomic anyMemChecks_ = false; + static std::mutex breakPointsMutex_; std::vector CBreakPoints::breakPoints_; u32 CBreakPoints::breakSkipFirstAt_ = 0; @@ -388,6 +391,7 @@ void CBreakPoints::AddMemCheck(u32 start, u32 end, MemCheckCondition cond, Break check.result = result; memChecks_.push_back(check); + anyMemChecks_ = true; guard.unlock(); Update(); } @@ -395,6 +399,7 @@ void CBreakPoints::AddMemCheck(u32 start, u32 end, MemCheckCondition cond, Break { memChecks_[mc].cond = (MemCheckCondition)(memChecks_[mc].cond | cond); memChecks_[mc].result = (BreakAction)(memChecks_[mc].result | result); + anyMemChecks_ = true; guard.unlock(); Update(); } @@ -410,6 +415,7 @@ void CBreakPoints::RemoveMemCheck(u32 start, u32 end) if (mc != INVALID_MEMCHECK) { memChecks_.erase(memChecks_.begin() + mc); + anyMemChecks_ = !memChecks_.empty(); guard.unlock(); Update(); } @@ -499,6 +505,8 @@ MemCheck *CBreakPoints::GetMemCheckLocked(u32 address, int size) { BreakAction CBreakPoints::ExecMemCheck(u32 address, bool write, int size, u32 pc) { + if (!anyMemChecks_) + return BREAK_ACTION_IGNORE; std::unique_lock guard(memCheckMutex_); auto check = GetMemCheckLocked(address, size); if (check) {