JitInterface::ClearCache: Modernize With CPUThreadGuard
It is recommended to view this diff with whitespace changes hidden.
This commit is contained in:
parent
8f6fd912f7
commit
4568446398
|
@ -408,12 +408,12 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetProfiling
|
||||||
jboolean enable)
|
jboolean enable)
|
||||||
{
|
{
|
||||||
HostThreadLock guard;
|
HostThreadLock guard;
|
||||||
Core::SetState(Core::State::Paused);
|
auto& system = Core::System::GetInstance();
|
||||||
auto& jit_interface = Core::System::GetInstance().GetJitInterface();
|
auto& jit_interface = system.GetJitInterface();
|
||||||
jit_interface.ClearCache();
|
const Core::CPUThreadGuard cpu_guard(system);
|
||||||
|
jit_interface.ClearCache(cpu_guard);
|
||||||
jit_interface.SetProfilingState(enable ? JitInterface::ProfilingState::Enabled :
|
jit_interface.SetProfilingState(enable ? JitInterface::ProfilingState::Enabled :
|
||||||
JitInterface::ProfilingState::Disabled);
|
JitInterface::ProfilingState::Disabled);
|
||||||
Core::SetState(Core::State::Running);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_WriteProfileResults(JNIEnv*,
|
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_WriteProfileResults(JNIEnv*,
|
||||||
|
|
|
@ -1015,18 +1015,17 @@ void UpdateWantDeterminism(bool initial)
|
||||||
{
|
{
|
||||||
NOTICE_LOG_FMT(COMMON, "Want determinism <- {}", new_want_determinism ? "true" : "false");
|
NOTICE_LOG_FMT(COMMON, "Want determinism <- {}", new_want_determinism ? "true" : "false");
|
||||||
|
|
||||||
RunAsCPUThread([&] {
|
const Core::CPUThreadGuard guard(system);
|
||||||
s_wants_determinism = new_want_determinism;
|
s_wants_determinism = new_want_determinism;
|
||||||
const auto ios = system.GetIOS();
|
const auto ios = system.GetIOS();
|
||||||
if (ios)
|
if (ios)
|
||||||
ios->UpdateWantDeterminism(new_want_determinism);
|
ios->UpdateWantDeterminism(new_want_determinism);
|
||||||
|
|
||||||
system.GetFifo().UpdateWantDeterminism(new_want_determinism);
|
system.GetFifo().UpdateWantDeterminism(new_want_determinism);
|
||||||
|
|
||||||
// We need to clear the cache because some parts of the JIT depend on want_determinism,
|
// We need to clear the cache because some parts of the JIT depend on want_determinism,
|
||||||
// e.g. use of FMA.
|
// e.g. use of FMA.
|
||||||
system.GetJitInterface().ClearCache();
|
system.GetJitInterface().ClearCache(guard);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -271,30 +271,30 @@ void MemChecks::AddFromStrings(const TMemChecksStr& mc_strings)
|
||||||
void MemChecks::Add(TMemCheck memory_check)
|
void MemChecks::Add(TMemCheck memory_check)
|
||||||
{
|
{
|
||||||
bool had_any = HasAny();
|
bool had_any = HasAny();
|
||||||
Core::RunAsCPUThread([&] {
|
|
||||||
// Check for existing breakpoint, and overwrite with new info.
|
const Core::CPUThreadGuard guard(m_system);
|
||||||
// This is assuming we usually want the new breakpoint over an old one.
|
// Check for existing breakpoint, and overwrite with new info.
|
||||||
const u32 address = memory_check.start_address;
|
// This is assuming we usually want the new breakpoint over an old one.
|
||||||
auto old_mem_check =
|
const u32 address = memory_check.start_address;
|
||||||
std::find_if(m_mem_checks.begin(), m_mem_checks.end(),
|
auto old_mem_check =
|
||||||
[address](const auto& check) { return check.start_address == address; });
|
std::find_if(m_mem_checks.begin(), m_mem_checks.end(),
|
||||||
if (old_mem_check != m_mem_checks.end())
|
[address](const auto& check) { return check.start_address == address; });
|
||||||
{
|
if (old_mem_check != m_mem_checks.end())
|
||||||
const bool is_enabled = old_mem_check->is_enabled; // Preserve enabled status
|
{
|
||||||
*old_mem_check = std::move(memory_check);
|
const bool is_enabled = old_mem_check->is_enabled; // Preserve enabled status
|
||||||
old_mem_check->is_enabled = is_enabled;
|
*old_mem_check = std::move(memory_check);
|
||||||
old_mem_check->num_hits = 0;
|
old_mem_check->is_enabled = is_enabled;
|
||||||
}
|
old_mem_check->num_hits = 0;
|
||||||
else
|
}
|
||||||
{
|
else
|
||||||
m_mem_checks.emplace_back(std::move(memory_check));
|
{
|
||||||
}
|
m_mem_checks.emplace_back(std::move(memory_check));
|
||||||
// If this is the first one, clear the JIT cache so it can switch to
|
}
|
||||||
// watchpoint-compatible code.
|
// If this is the first one, clear the JIT cache so it can switch to
|
||||||
if (!had_any)
|
// watchpoint-compatible code.
|
||||||
m_system.GetJitInterface().ClearCache();
|
if (!had_any)
|
||||||
m_system.GetMMU().DBATUpdated();
|
m_system.GetJitInterface().ClearCache(guard);
|
||||||
});
|
m_system.GetMMU().DBATUpdated();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MemChecks::ToggleBreakPoint(u32 address)
|
bool MemChecks::ToggleBreakPoint(u32 address)
|
||||||
|
@ -318,21 +318,19 @@ void MemChecks::Remove(u32 address)
|
||||||
if (iter == m_mem_checks.cend())
|
if (iter == m_mem_checks.cend())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Core::RunAsCPUThread([&] {
|
const Core::CPUThreadGuard guard(m_system);
|
||||||
m_mem_checks.erase(iter);
|
m_mem_checks.erase(iter);
|
||||||
if (!HasAny())
|
if (!HasAny())
|
||||||
m_system.GetJitInterface().ClearCache();
|
m_system.GetJitInterface().ClearCache(guard);
|
||||||
m_system.GetMMU().DBATUpdated();
|
m_system.GetMMU().DBATUpdated();
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MemChecks::Clear()
|
void MemChecks::Clear()
|
||||||
{
|
{
|
||||||
Core::RunAsCPUThread([&] {
|
const Core::CPUThreadGuard guard(m_system);
|
||||||
m_mem_checks.clear();
|
m_mem_checks.clear();
|
||||||
m_system.GetJitInterface().ClearCache();
|
m_system.GetJitInterface().ClearCache(guard);
|
||||||
m_system.GetMMU().DBATUpdated();
|
m_system.GetMMU().DBATUpdated();
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TMemCheck* MemChecks::GetMemCheck(u32 address, size_t size)
|
TMemCheck* MemChecks::GetMemCheck(u32 address, size_t size)
|
||||||
|
|
|
@ -241,7 +241,7 @@ bool JitInterface::HandleStackFault()
|
||||||
return m_jit->HandleStackFault();
|
return m_jit->HandleStackFault();
|
||||||
}
|
}
|
||||||
|
|
||||||
void JitInterface::ClearCache()
|
void JitInterface::ClearCache(const Core::CPUThreadGuard&)
|
||||||
{
|
{
|
||||||
if (m_jit)
|
if (m_jit)
|
||||||
m_jit->ClearCache();
|
m_jit->ClearCache();
|
||||||
|
|
|
@ -16,8 +16,9 @@ class JitBase;
|
||||||
|
|
||||||
namespace Core
|
namespace Core
|
||||||
{
|
{
|
||||||
|
class CPUThreadGuard;
|
||||||
class System;
|
class System;
|
||||||
}
|
} // namespace Core
|
||||||
namespace PowerPC
|
namespace PowerPC
|
||||||
{
|
{
|
||||||
enum class CPUCore;
|
enum class CPUCore;
|
||||||
|
@ -72,7 +73,7 @@ public:
|
||||||
bool HandleStackFault();
|
bool HandleStackFault();
|
||||||
|
|
||||||
// Clearing CodeCache
|
// Clearing CodeCache
|
||||||
void ClearCache();
|
void ClearCache(const Core::CPUThreadGuard& guard);
|
||||||
|
|
||||||
// This clear is "safe" in the sense that it's okay to run from
|
// This clear is "safe" in the sense that it's okay to run from
|
||||||
// inside a JIT'ed block: it clears the instruction cache, but not
|
// inside a JIT'ed block: it clears the instruction cache, but not
|
||||||
|
|
|
@ -1753,7 +1753,8 @@ void MenuBar::PatchHLEFunctions()
|
||||||
|
|
||||||
void MenuBar::ClearCache()
|
void MenuBar::ClearCache()
|
||||||
{
|
{
|
||||||
Core::RunAsCPUThread([] { Core::System::GetInstance().GetJitInterface().ClearCache(); });
|
auto& system = Core::System::GetInstance();
|
||||||
|
system.GetJitInterface().ClearCache(Core::CPUThreadGuard{system});
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuBar::LogInstructions()
|
void MenuBar::LogInstructions()
|
||||||
|
|
Loading…
Reference in New Issue