diff --git a/rpcs3/Emu/Cell/SPUASMJITRecompiler.cpp b/rpcs3/Emu/Cell/SPUASMJITRecompiler.cpp index 1d6f63aafe..1ce02d4d92 100644 --- a/rpcs3/Emu/Cell/SPUASMJITRecompiler.cpp +++ b/rpcs3/Emu/Cell/SPUASMJITRecompiler.cpp @@ -46,18 +46,23 @@ void spu_recompiler::init() } } -bool spu_recompiler::compile(u64 last_reset_count, const std::vector& func) +spu_function_t spu_recompiler::compile(u64 last_reset_count, const std::vector& func) { const auto fn_location = m_spurt->find(last_reset_count, func); if (fn_location == spu_runtime::g_dispatcher) { - return true; + return &dispatch; } if (!fn_location) { - return false; + return nullptr; + } + + if (m_cache && g_cfg.core.spu_cache) + { + m_cache->add(func); } using namespace asmjit; @@ -836,7 +841,7 @@ bool spu_recompiler::compile(u64 last_reset_count, const std::vector& func) { if (err == asmjit::ErrorCode::kErrorNoVirtualMemory) { - return false; + return nullptr; } LOG_FATAL(SPU, "Failed to build a function"); @@ -844,7 +849,7 @@ bool spu_recompiler::compile(u64 last_reset_count, const std::vector& func) if (!m_spurt->add(last_reset_count, fn_location, fn)) { - return false; + return nullptr; } if (g_cfg.core.spu_debug) @@ -858,7 +863,7 @@ bool spu_recompiler::compile(u64 last_reset_count, const std::vector& func) fs::file(m_spurt->get_cache_path() + "spu.log", fs::write + fs::append).write(log); } - return true; + return fn; } spu_recompiler::XmmLink spu_recompiler::XmmAlloc() // get empty xmm register diff --git a/rpcs3/Emu/Cell/SPUASMJITRecompiler.h b/rpcs3/Emu/Cell/SPUASMJITRecompiler.h index ffc04cf333..6d8a906b13 100644 --- a/rpcs3/Emu/Cell/SPUASMJITRecompiler.h +++ b/rpcs3/Emu/Cell/SPUASMJITRecompiler.h @@ -13,7 +13,7 @@ public: virtual void init() override; - virtual bool compile(u64 last_reset_count, const std::vector&) override; + virtual spu_function_t compile(u64 last_reset_count, const std::vector&) override; private: // ASMJIT runtime diff --git a/rpcs3/Emu/Cell/SPURecompiler.cpp b/rpcs3/Emu/Cell/SPURecompiler.cpp index ad09f93128..3867645d5a 100644 --- a/rpcs3/Emu/Cell/SPURecompiler.cpp +++ b/rpcs3/Emu/Cell/SPURecompiler.cpp @@ -786,11 +786,6 @@ spu_recompiler_base::~spu_recompiler_base() void spu_recompiler_base::make_function(const std::vector& data) { - if (m_cache && g_cfg.core.spu_cache) - { - m_cache->add(data); - } - for (u64 reset_count = m_spurt->get_reset_count();;) { if (LIKELY(compile(reset_count, data))) @@ -3104,7 +3099,7 @@ public: } } - virtual bool compile(u64 last_reset_count, const std::vector& func) override + virtual spu_function_t compile(u64 last_reset_count, const std::vector& func) override { if (func.empty() && last_reset_count == 0 && m_interp_magn) { @@ -3115,12 +3110,17 @@ public: if (fn_location == spu_runtime::g_dispatcher) { - return true; + return &dispatch; } if (!fn_location) { - return false; + return nullptr; + } + + if (m_cache && g_cfg.core.spu_cache) + { + m_cache->add(func); } std::string hash; @@ -3684,7 +3684,7 @@ public: if (!m_spurt->add(last_reset_count, fn_location, fn)) { - return false; + return nullptr; } if (g_cfg.core.spu_debug) @@ -3693,7 +3693,7 @@ public: fs::file(m_spurt->get_cache_path() + "spu.log", fs::write + fs::append).write(log); } - return true; + return fn; } static void interp_check(spu_thread* _spu, bool after) @@ -3730,7 +3730,7 @@ public: } } - bool compile_interpreter() + spu_function_t compile_interpreter() { using namespace llvm; @@ -4044,7 +4044,7 @@ public: if (!spu_runtime::g_interpreter) { - return false; + return nullptr; } if (g_cfg.core.spu_debug) @@ -4053,7 +4053,7 @@ public: fs::file(m_spurt->get_cache_path() + "spu.log", fs::write + fs::append).write(log); } - return true; + return spu_runtime::g_interpreter; } static bool exec_check_state(spu_thread* _spu) diff --git a/rpcs3/Emu/Cell/SPURecompiler.h b/rpcs3/Emu/Cell/SPURecompiler.h index d474cf8bc2..91cae775ec 100644 --- a/rpcs3/Emu/Cell/SPURecompiler.h +++ b/rpcs3/Emu/Cell/SPURecompiler.h @@ -283,7 +283,7 @@ public: virtual void init() = 0; // Compile function (may fail) - virtual bool compile(u64 last_reset_count, const std::vector&) = 0; + virtual spu_function_t compile(u64 last_reset_count, const std::vector&) = 0; // Compile function, handle failure void make_function(const std::vector&);