Skip to content

Commit

Permalink
Memchecks: Avoid taking the mutex lock if no memchecks active. Possib…
Browse files Browse the repository at this point in the history
…le minor speedup in GoW and other block-copy-heavy games.
  • Loading branch information
hrydgard committed Aug 6, 2019
1 parent 2ba998d commit 641bb72
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Core/Debugger/Breakpoints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
// https:/hrydgard/ppsspp and http://www.ppsspp.org/.

#include <cstdio>
#include <atomic>
#include <mutex>

#include "Common/Log.h"
Expand All @@ -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;
Expand Down Expand Up @@ -388,13 +391,15 @@ void CBreakPoints::AddMemCheck(u32 start, u32 end, MemCheckCondition cond, Break
check.result = result;

memChecks_.push_back(check);
anyMemChecks_ = true;
guard.unlock();
Update();
}
else
{
memChecks_[mc].cond = (MemCheckCondition)(memChecks_[mc].cond | cond);
memChecks_[mc].result = (BreakAction)(memChecks_[mc].result | result);
anyMemChecks_ = true;
guard.unlock();
Update();
}
Expand All @@ -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();
}
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 641bb72

Please sign in to comment.