mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 13:27:45 -07:00
JitBase: Avoid System::GetInstance() and ppcState.
This commit is contained in:
parent
7de01597c6
commit
9c0226b7e3
@ -56,7 +56,9 @@ struct CachedInterpreter::Instruction
|
||||
Type type = Type::Abort;
|
||||
};
|
||||
|
||||
CachedInterpreter::CachedInterpreter() = default;
|
||||
CachedInterpreter::CachedInterpreter(Core::System& system) : JitBase(system)
|
||||
{
|
||||
}
|
||||
|
||||
CachedInterpreter::~CachedInterpreter() = default;
|
||||
|
||||
|
@ -13,7 +13,11 @@
|
||||
class CachedInterpreter : public JitBase
|
||||
{
|
||||
public:
|
||||
CachedInterpreter();
|
||||
explicit CachedInterpreter(Core::System& system);
|
||||
CachedInterpreter(const CachedInterpreter&) = delete;
|
||||
CachedInterpreter(CachedInterpreter&&) = delete;
|
||||
CachedInterpreter& operator=(const CachedInterpreter&) = delete;
|
||||
CachedInterpreter& operator=(CachedInterpreter&&) = delete;
|
||||
~CachedInterpreter();
|
||||
|
||||
void Init() override;
|
||||
|
@ -116,7 +116,7 @@ using namespace PowerPC;
|
||||
and such, but it's currently limited to integer ops only. This can definitely be made better.
|
||||
*/
|
||||
|
||||
Jit64::Jit64() : QuantizedMemoryRoutines(*this)
|
||||
Jit64::Jit64(Core::System& system) : JitBase(system), QuantizedMemoryRoutines(*this)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -43,7 +43,11 @@ struct CodeOp;
|
||||
class Jit64 : public JitBase, public QuantizedMemoryRoutines
|
||||
{
|
||||
public:
|
||||
Jit64();
|
||||
explicit Jit64(Core::System& system);
|
||||
Jit64(const Jit64&) = delete;
|
||||
Jit64(Jit64&&) = delete;
|
||||
Jit64& operator=(const Jit64&) = delete;
|
||||
Jit64& operator=(Jit64&&) = delete;
|
||||
~Jit64() override;
|
||||
|
||||
void Init() override;
|
||||
|
@ -38,7 +38,7 @@ constexpr size_t CODE_SIZE = 1024 * 1024 * 32;
|
||||
constexpr size_t FARCODE_SIZE = 1024 * 1024 * 64;
|
||||
constexpr size_t FARCODE_SIZE_MMU = 1024 * 1024 * 64;
|
||||
|
||||
JitArm64::JitArm64() : m_float_emit(this)
|
||||
JitArm64::JitArm64(Core::System& system) : JitBase(system), m_float_emit(this)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,11 @@
|
||||
class JitArm64 : public JitBase, public Arm64Gen::ARM64CodeBlock, public CommonAsmRoutinesBase
|
||||
{
|
||||
public:
|
||||
JitArm64();
|
||||
explicit JitArm64(Core::System& system);
|
||||
JitArm64(const JitArm64&) = delete;
|
||||
JitArm64(JitArm64&&) = delete;
|
||||
JitArm64& operator=(const JitArm64&) = delete;
|
||||
JitArm64& operator=(JitArm64&&) = delete;
|
||||
~JitArm64() override;
|
||||
|
||||
void Init() override;
|
||||
|
@ -60,7 +60,8 @@ void JitTrampoline(JitBase& jit, u32 em_address)
|
||||
jit.Jit(em_address);
|
||||
}
|
||||
|
||||
JitBase::JitBase() : m_code_buffer(code_buffer_size)
|
||||
JitBase::JitBase(Core::System& system)
|
||||
: m_code_buffer(code_buffer_size), m_system(system), m_ppc_state(system.GetPPCState())
|
||||
{
|
||||
m_registered_config_callback_id = Config::AddConfigChangedCallback(
|
||||
[this] { Core::RunAsCPUThread([this] { RefreshConfig(); }); });
|
||||
@ -94,8 +95,8 @@ void JitBase::RefreshConfig()
|
||||
m_fprf = Config::Get(Config::MAIN_FPRF);
|
||||
m_accurate_nans = Config::Get(Config::MAIN_ACCURATE_NANS);
|
||||
m_fastmem_enabled = Config::Get(Config::MAIN_FASTMEM);
|
||||
m_mmu_enabled = Core::System::GetInstance().IsMMUMode();
|
||||
m_pause_on_panic_enabled = Core::System::GetInstance().IsPauseOnPanicMode();
|
||||
m_mmu_enabled = m_system.IsMMUMode();
|
||||
m_pause_on_panic_enabled = m_system.IsPauseOnPanicMode();
|
||||
m_accurate_cpu_cache_enabled = Config::Get(Config::MAIN_ACCURATE_CPU_CACHE);
|
||||
if (m_accurate_cpu_cache_enabled)
|
||||
{
|
||||
@ -192,7 +193,7 @@ bool JitBase::HandleStackFault()
|
||||
// to reset the guard page.
|
||||
// Yeah, it's kind of gross.
|
||||
GetBlockCache()->InvalidateICache(0, 0xffffffff, true);
|
||||
Core::System::GetInstance().GetCoreTiming().ForceExceptionCheck(0);
|
||||
m_system.GetCoreTiming().ForceExceptionCheck(0);
|
||||
m_cleanup_after_stackfault = true;
|
||||
|
||||
return true;
|
||||
@ -213,8 +214,7 @@ void JitBase::CleanUpAfterStackFault()
|
||||
|
||||
bool JitBase::CanMergeNextInstructions(int count) const
|
||||
{
|
||||
auto& system = Core::System::GetInstance();
|
||||
if (system.GetCPU().IsStepping() || js.instructionsLeft < count)
|
||||
if (m_system.GetCPU().IsStepping() || js.instructionsLeft < count)
|
||||
return false;
|
||||
// Be careful: a breakpoint kills flags in between instructions
|
||||
for (int i = 1; i <= count; i++)
|
||||
@ -230,8 +230,7 @@ bool JitBase::CanMergeNextInstructions(int count) const
|
||||
void JitBase::UpdateMemoryAndExceptionOptions()
|
||||
{
|
||||
bool any_watchpoints = PowerPC::memchecks.HasAny();
|
||||
jo.fastmem =
|
||||
m_fastmem_enabled && jo.fastmem_arena && (PowerPC::ppcState.msr.DR || !any_watchpoints);
|
||||
jo.fastmem = m_fastmem_enabled && jo.fastmem_arena && (m_ppc_state.msr.DR || !any_watchpoints);
|
||||
jo.memcheck = m_mmu_enabled || m_pause_on_panic_enabled || any_watchpoints;
|
||||
jo.fp_exceptions = m_enable_float_exceptions;
|
||||
jo.div_by_zero_exceptions = m_enable_div_by_zero_exceptions;
|
||||
|
@ -17,6 +17,15 @@
|
||||
#include "Core/PowerPC/JitCommon/JitCache.h"
|
||||
#include "Core/PowerPC/PPCAnalyst.h"
|
||||
|
||||
namespace Core
|
||||
{
|
||||
class System;
|
||||
}
|
||||
namespace PowerPC
|
||||
{
|
||||
struct PowerPCState;
|
||||
}
|
||||
|
||||
//#define JIT_LOG_GENERATED_CODE // Enables logging of generated code
|
||||
//#define JIT_LOG_GPR // Enables logging of the PPC general purpose regs
|
||||
//#define JIT_LOG_FPR // Enables logging of the PPC floating point regs
|
||||
@ -162,7 +171,11 @@ protected:
|
||||
bool ShouldHandleFPExceptionForInstruction(const PPCAnalyst::CodeOp* op);
|
||||
|
||||
public:
|
||||
JitBase();
|
||||
explicit JitBase(Core::System& system);
|
||||
JitBase(const JitBase&) = delete;
|
||||
JitBase(JitBase&&) = delete;
|
||||
JitBase& operator=(const JitBase&) = delete;
|
||||
JitBase& operator=(JitBase&&) = delete;
|
||||
~JitBase() override;
|
||||
|
||||
bool IsDebuggingEnabled() const { return m_enable_debugging; }
|
||||
@ -182,6 +195,9 @@ public:
|
||||
// This should probably be removed from public:
|
||||
JitOptions jo{};
|
||||
JitState js{};
|
||||
|
||||
Core::System& m_system;
|
||||
PowerPC::PowerPCState& m_ppc_state;
|
||||
};
|
||||
|
||||
void JitTrampoline(JitBase& jit, u32 em_address);
|
||||
|
@ -54,20 +54,22 @@ void DoState(PointerWrap& p)
|
||||
}
|
||||
CPUCoreBase* InitJitCore(PowerPC::CPUCore core)
|
||||
{
|
||||
auto& system = Core::System::GetInstance();
|
||||
|
||||
switch (core)
|
||||
{
|
||||
#if _M_X86
|
||||
case PowerPC::CPUCore::JIT64:
|
||||
g_jit = new Jit64();
|
||||
g_jit = new Jit64(system);
|
||||
break;
|
||||
#endif
|
||||
#if _M_ARM_64
|
||||
case PowerPC::CPUCore::JITARM64:
|
||||
g_jit = new JitArm64();
|
||||
g_jit = new JitArm64(system);
|
||||
break;
|
||||
#endif
|
||||
case PowerPC::CPUCore::CachedInterpreter:
|
||||
g_jit = new CachedInterpreter();
|
||||
g_jit = new CachedInterpreter(system);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "Core/MemTools.h"
|
||||
#include "Core/PowerPC/JitCommon/JitBase.h"
|
||||
#include "Core/PowerPC/JitInterface.h"
|
||||
#include "Core/System.h"
|
||||
|
||||
// include order is important
|
||||
#include <gtest/gtest.h> // NOLINT
|
||||
@ -25,6 +26,8 @@ enum
|
||||
class PageFaultFakeJit : public JitBase
|
||||
{
|
||||
public:
|
||||
explicit PageFaultFakeJit(Core::System& system) : JitBase(system) {}
|
||||
|
||||
// CPUCoreBase methods
|
||||
void Init() override {}
|
||||
void Shutdown() override {}
|
||||
@ -72,7 +75,7 @@ TEST(PageFault, PageFault)
|
||||
EXPECT_NE(data, nullptr);
|
||||
Common::WriteProtectMemory(data, PAGE_GRAN, false);
|
||||
|
||||
PageFaultFakeJit pfjit;
|
||||
PageFaultFakeJit pfjit(Core::System::GetInstance());
|
||||
JitInterface::SetJit(&pfjit);
|
||||
pfjit.m_data = data;
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "Core/PowerPC/Jit64/Jit.h"
|
||||
#include "Core/PowerPC/Jit64Common/Jit64AsmCommon.h"
|
||||
#include "Core/PowerPC/Jit64Common/Jit64PowerPCState.h"
|
||||
#include "Core/System.h"
|
||||
|
||||
#include "../TestValues.h"
|
||||
|
||||
@ -22,7 +23,7 @@ namespace
|
||||
class TestCommonAsmRoutines : public CommonAsmRoutines
|
||||
{
|
||||
public:
|
||||
TestCommonAsmRoutines() : CommonAsmRoutines(jit)
|
||||
explicit TestCommonAsmRoutines(Core::System& system) : CommonAsmRoutines(jit), jit(system)
|
||||
{
|
||||
using namespace Gen;
|
||||
|
||||
@ -51,7 +52,7 @@ public:
|
||||
|
||||
TEST(Jit64, ConvertDoubleToSingle)
|
||||
{
|
||||
TestCommonAsmRoutines routines;
|
||||
TestCommonAsmRoutines routines(Core::System::GetInstance());
|
||||
|
||||
for (const u64 input : double_test_values)
|
||||
{
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "Core/PowerPC/Jit64/Jit.h"
|
||||
#include "Core/PowerPC/Jit64Common/Jit64AsmCommon.h"
|
||||
#include "Core/PowerPC/Jit64Common/Jit64PowerPCState.h"
|
||||
#include "Core/System.h"
|
||||
|
||||
#include "../TestValues.h"
|
||||
|
||||
@ -22,7 +23,7 @@ namespace
|
||||
class TestCommonAsmRoutines : public CommonAsmRoutines
|
||||
{
|
||||
public:
|
||||
TestCommonAsmRoutines() : CommonAsmRoutines(jit)
|
||||
explicit TestCommonAsmRoutines(Core::System& system) : CommonAsmRoutines(jit), jit(system)
|
||||
{
|
||||
using namespace Gen;
|
||||
|
||||
@ -58,7 +59,7 @@ public:
|
||||
|
||||
TEST(Jit64, Frsqrte)
|
||||
{
|
||||
TestCommonAsmRoutines routines;
|
||||
TestCommonAsmRoutines routines(Core::System::GetInstance());
|
||||
|
||||
UReg_FPSCR fpscr;
|
||||
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "Common/FPURoundMode.h"
|
||||
#include "Core/PowerPC/Interpreter/Interpreter_FPUtils.h"
|
||||
#include "Core/PowerPC/JitArm64/Jit.h"
|
||||
#include "Core/System.h"
|
||||
|
||||
#include "../TestValues.h"
|
||||
|
||||
@ -30,7 +31,7 @@ struct Pair
|
||||
class TestConversion : private JitArm64
|
||||
{
|
||||
public:
|
||||
TestConversion()
|
||||
explicit TestConversion(Core::System& system) : JitArm64(system)
|
||||
{
|
||||
const Common::ScopedJITPageWriteAndNoExecute enable_jit_page_writes;
|
||||
|
||||
@ -119,7 +120,7 @@ private:
|
||||
|
||||
TEST(JitArm64, ConvertDoubleToSingle)
|
||||
{
|
||||
TestConversion test;
|
||||
TestConversion test(Core::System::GetInstance());
|
||||
|
||||
for (const u64 input : double_test_values)
|
||||
{
|
||||
@ -154,7 +155,7 @@ TEST(JitArm64, ConvertDoubleToSingle)
|
||||
|
||||
TEST(JitArm64, ConvertSingleToDouble)
|
||||
{
|
||||
TestConversion test;
|
||||
TestConversion test(Core::System::GetInstance());
|
||||
|
||||
for (const u32 input : single_test_values)
|
||||
{
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "Core/PowerPC/Interpreter/Interpreter_FPUtils.h"
|
||||
#include "Core/PowerPC/JitArm64/Jit.h"
|
||||
#include "Core/PowerPC/PowerPC.h"
|
||||
#include "Core/System.h"
|
||||
|
||||
#include "../TestValues.h"
|
||||
|
||||
@ -22,7 +23,7 @@ using namespace Arm64Gen;
|
||||
class TestFPRF : public JitArm64
|
||||
{
|
||||
public:
|
||||
TestFPRF()
|
||||
explicit TestFPRF(Core::System& system) : JitArm64(system)
|
||||
{
|
||||
const Common::ScopedJITPageWriteAndNoExecute enable_jit_page_writes;
|
||||
|
||||
@ -67,7 +68,7 @@ static u32 RunUpdateFPRF(const std::function<void()>& f)
|
||||
|
||||
TEST(JitArm64, FPRF)
|
||||
{
|
||||
TestFPRF test;
|
||||
TestFPRF test(Core::System::GetInstance());
|
||||
|
||||
for (const u64 double_input : double_test_values)
|
||||
{
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "Core/PowerPC/Interpreter/Interpreter_FPUtils.h"
|
||||
#include "Core/PowerPC/JitArm64/Jit.h"
|
||||
#include "Core/PowerPC/PowerPC.h"
|
||||
#include "Core/System.h"
|
||||
|
||||
#include "../TestValues.h"
|
||||
|
||||
@ -21,7 +22,7 @@ using namespace Arm64Gen;
|
||||
class TestFres : public JitArm64
|
||||
{
|
||||
public:
|
||||
TestFres()
|
||||
explicit TestFres(Core::System& system) : JitArm64(system)
|
||||
{
|
||||
const Common::ScopedJITPageWriteAndNoExecute enable_jit_page_writes;
|
||||
|
||||
@ -50,7 +51,7 @@ public:
|
||||
|
||||
TEST(JitArm64, Fres)
|
||||
{
|
||||
TestFres test;
|
||||
TestFres test(Core::System::GetInstance());
|
||||
|
||||
for (const u64 ivalue : double_test_values)
|
||||
{
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "Core/PowerPC/Interpreter/Interpreter_FPUtils.h"
|
||||
#include "Core/PowerPC/JitArm64/Jit.h"
|
||||
#include "Core/PowerPC/PowerPC.h"
|
||||
#include "Core/System.h"
|
||||
|
||||
#include "../TestValues.h"
|
||||
|
||||
@ -21,7 +22,7 @@ using namespace Arm64Gen;
|
||||
class TestFrsqrte : public JitArm64
|
||||
{
|
||||
public:
|
||||
TestFrsqrte()
|
||||
explicit TestFrsqrte(Core::System& system) : JitArm64(system)
|
||||
{
|
||||
const Common::ScopedJITPageWriteAndNoExecute enable_jit_page_writes;
|
||||
|
||||
@ -50,7 +51,7 @@ public:
|
||||
|
||||
TEST(JitArm64, Frsqrte)
|
||||
{
|
||||
TestFrsqrte test;
|
||||
TestFrsqrte test(Core::System::GetInstance());
|
||||
|
||||
for (const u64 ivalue : double_test_values)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user