From 0d42cbc923eef625bd35997860afb409c1a230e3 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 28 Jan 2017 03:39:02 -0500 Subject: [PATCH 1/2] DSPCore: Move JIT cycle code to DSPEmitter Moves x86-specific emitter code out of DSPCore. --- Source/Core/Core/DSP/DSPCore.cpp | 16 +--------------- Source/Core/Core/DSP/Jit/DSPEmitter.cpp | 19 +++++++++++++++++++ Source/Core/Core/DSP/Jit/DSPEmitter.h | 2 ++ 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/Source/Core/Core/DSP/DSPCore.cpp b/Source/Core/Core/DSP/DSPCore.cpp index 712417ed37..b080ffd9bb 100644 --- a/Source/Core/Core/DSP/DSPCore.cpp +++ b/Source/Core/Core/DSP/DSPCore.cpp @@ -245,21 +245,7 @@ int DSPCore_RunCycles(int cycles) { if (g_dsp_jit) { - if (g_dsp.external_interrupt_waiting) - { - DSPCore_CheckExternalInterrupt(); - DSPCore_CheckExceptions(); - DSPCore_SetExternalInterrupt(false); - } - - g_cycles_left = cycles; - auto exec_addr = (JIT::x86::DSPEmitter::DSPCompiledCode)g_dsp_jit->m_enter_dispatcher; - exec_addr(); - - if (g_dsp.reset_dspjit_codespace) - g_dsp_jit->ClearIRAMandDSPJITCodespaceReset(); - - return g_cycles_left; + return g_dsp_jit->RunCycles(static_cast(cycles)); } while (cycles > 0) diff --git a/Source/Core/Core/DSP/Jit/DSPEmitter.cpp b/Source/Core/Core/DSP/Jit/DSPEmitter.cpp index ef73adf24f..8a30c80cf3 100644 --- a/Source/Core/Core/DSP/Jit/DSPEmitter.cpp +++ b/Source/Core/Core/DSP/Jit/DSPEmitter.cpp @@ -48,6 +48,25 @@ DSPEmitter::~DSPEmitter() FreeCodeSpace(); } +u16 DSPEmitter::RunCycles(u16 cycles) +{ + if (g_dsp.external_interrupt_waiting) + { + DSPCore_CheckExternalInterrupt(); + DSPCore_CheckExceptions(); + DSPCore_SetExternalInterrupt(false); + } + + g_cycles_left = cycles; + auto exec_addr = (DSPCompiledCode)m_enter_dispatcher; + exec_addr(); + + if (g_dsp.reset_dspjit_codespace) + ClearIRAMandDSPJITCodespaceReset(); + + return g_cycles_left; +} + void DSPEmitter::ClearIRAM() { for (int i = 0x0000; i < 0x1000; i++) diff --git a/Source/Core/Core/DSP/Jit/DSPEmitter.h b/Source/Core/Core/DSP/Jit/DSPEmitter.h index 6aa72c7dc1..a9f7694a5a 100644 --- a/Source/Core/Core/DSP/Jit/DSPEmitter.h +++ b/Source/Core/Core/DSP/Jit/DSPEmitter.h @@ -32,6 +32,8 @@ public: DSPEmitter(); ~DSPEmitter(); + u16 RunCycles(u16 cycles); + void EmitInstruction(UDSPInstruction inst); void ClearIRAM(); void ClearIRAMandDSPJITCodespaceReset(); From f5fe387a202caaf3418e50f0d2f13ca5f2dbf31d Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sat, 28 Jan 2017 03:41:05 -0500 Subject: [PATCH 2/2] DSPEmitter: Make emitter dispatcher pointers private --- Source/Core/Core/DSP/Jit/DSPEmitter.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Source/Core/Core/DSP/Jit/DSPEmitter.h b/Source/Core/Core/DSP/Jit/DSPEmitter.h index a9f7694a5a..e33c0d6edd 100644 --- a/Source/Core/Core/DSP/Jit/DSPEmitter.h +++ b/Source/Core/Core/DSP/Jit/DSPEmitter.h @@ -247,12 +247,6 @@ public: void madd(const UDSPInstruction opc); void msub(const UDSPInstruction opc); - // CALL this to start the dispatcher - const u8* m_enter_dispatcher; - const u8* m_reenter_dispatcher; - const u8* m_stub_entry_point; - const u8* m_return_dispatcher; - std::list m_unresolved_jumps[MAX_BLOCKS]; private: @@ -299,6 +293,12 @@ private: // The index of the last stored ext value (compile time). int m_store_index = -1; int m_store_index2 = -1; + + // CALL this to start the dispatcher + const u8* m_enter_dispatcher; + const u8* m_reenter_dispatcher; + const u8* m_stub_entry_point; + const u8* m_return_dispatcher; }; } // namespace x86