mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 13:27:45 -07:00
JitInterface: Convert m_jit to unique_ptr.
This commit is contained in:
parent
9217a9eba4
commit
7f50c070b2
@ -46,9 +46,9 @@ JitInterface::JitInterface(Core::System& system) : m_system(system)
|
||||
|
||||
JitInterface::~JitInterface() = default;
|
||||
|
||||
void JitInterface::SetJit(JitBase* jit)
|
||||
void JitInterface::SetJit(std::unique_ptr<JitBase> jit)
|
||||
{
|
||||
m_jit = jit;
|
||||
m_jit = std::move(jit);
|
||||
}
|
||||
|
||||
void JitInterface::DoState(PointerWrap& p)
|
||||
@ -65,31 +65,31 @@ CPUCoreBase* JitInterface::InitJitCore(PowerPC::CPUCore core)
|
||||
{
|
||||
#if _M_X86
|
||||
case PowerPC::CPUCore::JIT64:
|
||||
m_jit = new Jit64(system);
|
||||
m_jit = std::make_unique<Jit64>(system);
|
||||
break;
|
||||
#endif
|
||||
#if _M_ARM_64
|
||||
case PowerPC::CPUCore::JITARM64:
|
||||
m_jit = new JitArm64(system);
|
||||
m_jit = std::make_unique<JitArm64>(system);
|
||||
break;
|
||||
#endif
|
||||
case PowerPC::CPUCore::CachedInterpreter:
|
||||
m_jit = new CachedInterpreter(system);
|
||||
m_jit = std::make_unique<CachedInterpreter>(system);
|
||||
break;
|
||||
|
||||
default:
|
||||
// Under this case the caller overrides the CPU core to the default and logs that
|
||||
// it performed the override.
|
||||
m_jit = nullptr;
|
||||
m_jit.reset();
|
||||
return nullptr;
|
||||
}
|
||||
m_jit->Init();
|
||||
return m_jit;
|
||||
return m_jit.get();
|
||||
}
|
||||
|
||||
CPUCoreBase* JitInterface::GetCore() const
|
||||
{
|
||||
return m_jit;
|
||||
return m_jit.get();
|
||||
}
|
||||
|
||||
void JitInterface::SetProfilingState(ProfilingState state)
|
||||
@ -319,7 +319,6 @@ void JitInterface::Shutdown()
|
||||
if (m_jit)
|
||||
{
|
||||
m_jit->Shutdown();
|
||||
delete m_jit;
|
||||
m_jit = nullptr;
|
||||
m_jit.reset();
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <variant>
|
||||
|
||||
@ -94,11 +95,11 @@ public:
|
||||
static void CompileExceptionCheckFromJIT(JitInterface& jit_interface, ExceptionType type);
|
||||
|
||||
/// used for the page fault unit test, don't use outside of tests!
|
||||
void SetJit(JitBase* jit);
|
||||
void SetJit(std::unique_ptr<JitBase> jit);
|
||||
|
||||
void Shutdown();
|
||||
|
||||
private:
|
||||
JitBase* m_jit = nullptr;
|
||||
std::unique_ptr<JitBase> m_jit;
|
||||
Core::System& m_system;
|
||||
};
|
||||
|
@ -75,8 +75,10 @@ TEST(PageFault, PageFault)
|
||||
EXPECT_NE(data, nullptr);
|
||||
Common::WriteProtectMemory(data, PAGE_GRAN, false);
|
||||
|
||||
PageFaultFakeJit pfjit(Core::System::GetInstance());
|
||||
Core::System::GetInstance().GetJitInterface().SetJit(&pfjit);
|
||||
auto& system = Core::System::GetInstance();
|
||||
auto unique_pfjit = std::make_unique<PageFaultFakeJit>(system);
|
||||
auto& pfjit = *unique_pfjit;
|
||||
system.GetJitInterface().SetJit(std::move(unique_pfjit));
|
||||
pfjit.m_data = data;
|
||||
|
||||
auto start = std::chrono::high_resolution_clock::now();
|
||||
@ -88,7 +90,6 @@ TEST(PageFault, PageFault)
|
||||
};
|
||||
|
||||
EMM::UninstallExceptionHandler();
|
||||
Core::System::GetInstance().GetJitInterface().SetJit(nullptr);
|
||||
|
||||
fmt::print("page fault timing:\n");
|
||||
fmt::print("start->HandleFault {} ns\n",
|
||||
@ -98,4 +99,6 @@ TEST(PageFault, PageFault)
|
||||
fmt::print("HandleFault->end {} ns\n",
|
||||
difference_in_nanoseconds(pfjit.m_post_unprotect_time, end));
|
||||
fmt::print("total {} ns\n", difference_in_nanoseconds(start, end));
|
||||
|
||||
system.GetJitInterface().SetJit(nullptr);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user