mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-04-28 13:28:01 +03:00
PPU: HasBreakpoint fast path when empty
This commit is contained in:
parent
2afd7707fe
commit
f3dab14514
2 changed files with 19 additions and 1 deletions
|
@ -14,6 +14,9 @@ void breakpoint_handler::SetBreakOnBPM(bool break_on_bpm)
|
||||||
|
|
||||||
bool breakpoint_handler::HasBreakpoint(u32 loc, bs_t<breakpoint_types> type)
|
bool breakpoint_handler::HasBreakpoint(u32 loc, bs_t<breakpoint_types> type)
|
||||||
{
|
{
|
||||||
|
if (m_empty.load(std::memory_order_acquire))
|
||||||
|
return false;
|
||||||
|
|
||||||
std::lock_guard lock(mutex_breakpoints);
|
std::lock_guard lock(mutex_breakpoints);
|
||||||
|
|
||||||
return m_breakpoints.contains(loc) && ((m_breakpoints.at(loc) & type) == type);
|
return m_breakpoints.contains(loc) && ((m_breakpoints.at(loc) & type) == type);
|
||||||
|
@ -28,7 +31,14 @@ bool breakpoint_handler::AddBreakpoint(u32 loc, bs_t<breakpoint_types> type)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return m_breakpoints.insert({loc, type}).second;
|
bool result = m_breakpoints.insert({loc, type}).second;
|
||||||
|
|
||||||
|
if (result)
|
||||||
|
{
|
||||||
|
m_empty.store(false, std::memory_order_release);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool breakpoint_handler::RemoveBreakpoint(u32 loc)
|
bool breakpoint_handler::RemoveBreakpoint(u32 loc)
|
||||||
|
@ -50,5 +60,11 @@ bool breakpoint_handler::RemoveBreakpoint(u32 loc)
|
||||||
{
|
{
|
||||||
ensure(ppu_breakpoint(loc, false));
|
ensure(ppu_breakpoint(loc, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_breakpoints.empty())
|
||||||
|
{
|
||||||
|
m_empty.store(true, std::memory_order_release);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include "Utilities/bit_set.h"
|
#include "Utilities/bit_set.h"
|
||||||
#include <map>
|
#include <map>
|
||||||
#include "Utilities/mutex.h"
|
#include "Utilities/mutex.h"
|
||||||
|
#include <atomic>
|
||||||
|
|
||||||
enum class breakpoint_types
|
enum class breakpoint_types
|
||||||
{
|
{
|
||||||
|
@ -46,6 +47,7 @@ private:
|
||||||
// TODO : generalize to hold multiple games and handle flags.Probably do : std::map<std::string (gameid), std::set<breakpoint>>.
|
// TODO : generalize to hold multiple games and handle flags.Probably do : std::map<std::string (gameid), std::set<breakpoint>>.
|
||||||
// Although, externally, they'll only be accessed by loc (I think) so a map of maps may also do?
|
// Although, externally, they'll only be accessed by loc (I think) so a map of maps may also do?
|
||||||
shared_mutex mutex_breakpoints;
|
shared_mutex mutex_breakpoints;
|
||||||
|
std::atomic<bool> m_empty{true};
|
||||||
std::map<u32, bs_t<breakpoint_types>> m_breakpoints; //! Holds all breakpoints.
|
std::map<u32, bs_t<breakpoint_types>> m_breakpoints; //! Holds all breakpoints.
|
||||||
bool m_break_on_bpm = false;
|
bool m_break_on_bpm = false;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue