Memchecks: Avoid taking the mutex lock if no memchecks active. Possible minor speedup in GoW and other block-copy-heavy games.

This commit is contained in:
Henrik Rydgård 2019-08-06 15:33:11 +02:00
parent 2ba998d007
commit 641bb72b40

View file

@ -16,6 +16,7 @@
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
#include <cstdio>
#include <atomic>
#include <mutex>
#include "Common/Log.h"
@ -28,6 +29,8 @@
#include "Core/MIPS/JitCommon/JitCommon.h"
#include "Core/CoreTiming.h"
std::atomic<bool> anyMemChecks_ = false;
static std::mutex breakPointsMutex_;
std::vector<BreakPoint> 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<std::mutex> guard(memCheckMutex_);
auto check = GetMemCheckLocked(address, size);
if (check) {