mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07:00
Merge pull request #12620 from mitaclaw/jit-interface-cpu-thread-guard
JitInterface::ClearCache: Modernize With CPUThreadGuard
This commit is contained in:
commit
f814dc58b5
@ -408,12 +408,12 @@ JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_SetProfiling
|
||||
jboolean enable)
|
||||
{
|
||||
HostThreadLock guard;
|
||||
Core::SetState(Core::State::Paused);
|
||||
auto& jit_interface = Core::System::GetInstance().GetJitInterface();
|
||||
jit_interface.ClearCache();
|
||||
auto& system = Core::System::GetInstance();
|
||||
auto& jit_interface = system.GetJitInterface();
|
||||
const Core::CPUThreadGuard cpu_guard(system);
|
||||
jit_interface.ClearCache(cpu_guard);
|
||||
jit_interface.SetProfilingState(enable ? JitInterface::ProfilingState::Enabled :
|
||||
JitInterface::ProfilingState::Disabled);
|
||||
Core::SetState(Core::State::Running);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_dolphinemu_dolphinemu_NativeLibrary_WriteProfileResults(JNIEnv*,
|
||||
|
@ -1006,18 +1006,17 @@ void UpdateWantDeterminism(Core::System& system, bool initial)
|
||||
{
|
||||
NOTICE_LOG_FMT(COMMON, "Want determinism <- {}", new_want_determinism ? "true" : "false");
|
||||
|
||||
RunAsCPUThread([&] {
|
||||
s_wants_determinism = new_want_determinism;
|
||||
const auto ios = system.GetIOS();
|
||||
if (ios)
|
||||
ios->UpdateWantDeterminism(new_want_determinism);
|
||||
const Core::CPUThreadGuard guard(system);
|
||||
s_wants_determinism = new_want_determinism;
|
||||
const auto ios = system.GetIOS();
|
||||
if (ios)
|
||||
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,
|
||||
// e.g. use of FMA.
|
||||
system.GetJitInterface().ClearCache();
|
||||
});
|
||||
// We need to clear the cache because some parts of the JIT depend on want_determinism,
|
||||
// e.g. use of FMA.
|
||||
system.GetJitInterface().ClearCache(guard);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -271,30 +271,30 @@ void MemChecks::AddFromStrings(const TMemChecksStr& mc_strings)
|
||||
void MemChecks::Add(TMemCheck memory_check)
|
||||
{
|
||||
bool had_any = HasAny();
|
||||
Core::RunAsCPUThread([&] {
|
||||
// Check for existing breakpoint, and overwrite with new info.
|
||||
// This is assuming we usually want the new breakpoint over an old one.
|
||||
const u32 address = memory_check.start_address;
|
||||
auto old_mem_check =
|
||||
std::find_if(m_mem_checks.begin(), 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);
|
||||
old_mem_check->is_enabled = is_enabled;
|
||||
old_mem_check->num_hits = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
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 (!had_any)
|
||||
m_system.GetJitInterface().ClearCache();
|
||||
m_system.GetMMU().DBATUpdated();
|
||||
});
|
||||
|
||||
const Core::CPUThreadGuard guard(m_system);
|
||||
// Check for existing breakpoint, and overwrite with new info.
|
||||
// This is assuming we usually want the new breakpoint over an old one.
|
||||
const u32 address = memory_check.start_address;
|
||||
auto old_mem_check =
|
||||
std::find_if(m_mem_checks.begin(), 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);
|
||||
old_mem_check->is_enabled = is_enabled;
|
||||
old_mem_check->num_hits = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
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 (!had_any)
|
||||
m_system.GetJitInterface().ClearCache(guard);
|
||||
m_system.GetMMU().DBATUpdated();
|
||||
}
|
||||
|
||||
bool MemChecks::ToggleBreakPoint(u32 address)
|
||||
@ -318,21 +318,19 @@ void MemChecks::Remove(u32 address)
|
||||
if (iter == m_mem_checks.cend())
|
||||
return;
|
||||
|
||||
Core::RunAsCPUThread([&] {
|
||||
m_mem_checks.erase(iter);
|
||||
if (!HasAny())
|
||||
m_system.GetJitInterface().ClearCache();
|
||||
m_system.GetMMU().DBATUpdated();
|
||||
});
|
||||
const Core::CPUThreadGuard guard(m_system);
|
||||
m_mem_checks.erase(iter);
|
||||
if (!HasAny())
|
||||
m_system.GetJitInterface().ClearCache(guard);
|
||||
m_system.GetMMU().DBATUpdated();
|
||||
}
|
||||
|
||||
void MemChecks::Clear()
|
||||
{
|
||||
Core::RunAsCPUThread([&] {
|
||||
m_mem_checks.clear();
|
||||
m_system.GetJitInterface().ClearCache();
|
||||
m_system.GetMMU().DBATUpdated();
|
||||
});
|
||||
const Core::CPUThreadGuard guard(m_system);
|
||||
m_mem_checks.clear();
|
||||
m_system.GetJitInterface().ClearCache(guard);
|
||||
m_system.GetMMU().DBATUpdated();
|
||||
}
|
||||
|
||||
TMemCheck* MemChecks::GetMemCheck(u32 address, size_t size)
|
||||
|
@ -241,7 +241,7 @@ bool JitInterface::HandleStackFault()
|
||||
return m_jit->HandleStackFault();
|
||||
}
|
||||
|
||||
void JitInterface::ClearCache()
|
||||
void JitInterface::ClearCache(const Core::CPUThreadGuard&)
|
||||
{
|
||||
if (m_jit)
|
||||
m_jit->ClearCache();
|
||||
|
@ -16,8 +16,9 @@ class JitBase;
|
||||
|
||||
namespace Core
|
||||
{
|
||||
class CPUThreadGuard;
|
||||
class System;
|
||||
}
|
||||
} // namespace Core
|
||||
namespace PowerPC
|
||||
{
|
||||
enum class CPUCore;
|
||||
@ -72,7 +73,7 @@ public:
|
||||
bool HandleStackFault();
|
||||
|
||||
// Clearing CodeCache
|
||||
void ClearCache();
|
||||
void ClearCache(const Core::CPUThreadGuard& guard);
|
||||
|
||||
// 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
|
||||
|
@ -1752,7 +1752,8 @@ void MenuBar::PatchHLEFunctions()
|
||||
|
||||
void MenuBar::ClearCache()
|
||||
{
|
||||
Core::RunAsCPUThread([] { Core::System::GetInstance().GetJitInterface().ClearCache(); });
|
||||
auto& system = Core::System::GetInstance();
|
||||
system.GetJitInterface().ClearCache(Core::CPUThreadGuard{system});
|
||||
}
|
||||
|
||||
void MenuBar::LogInstructions()
|
||||
|
Loading…
Reference in New Issue
Block a user