diff --git a/rpcs3/Emu/Cell/SPUASMJITRecompiler.cpp b/rpcs3/Emu/Cell/SPUASMJITRecompiler.cpp index b4c69905ec..43539a5e74 100644 --- a/rpcs3/Emu/Cell/SPUASMJITRecompiler.cpp +++ b/rpcs3/Emu/Cell/SPUASMJITRecompiler.cpp @@ -40,7 +40,6 @@ void spu_recompiler::init() // Initialize if necessary if (!m_spurt) { - m_cache = fxm::get(); m_spurt = g_fxo->get(); } } @@ -59,9 +58,9 @@ spu_function_t spu_recompiler::compile(u64 last_reset_count, const std::vectorget(); cache && g_cfg.core.spu_cache) { - m_cache->add(func); + cache->add(func); } using namespace asmjit; diff --git a/rpcs3/Emu/Cell/SPURecompiler.cpp b/rpcs3/Emu/Cell/SPURecompiler.cpp index 9985bddb8f..0976fa6e1a 100644 --- a/rpcs3/Emu/Cell/SPURecompiler.cpp +++ b/rpcs3/Emu/Cell/SPURecompiler.cpp @@ -313,16 +313,16 @@ void spu_cache::initialize() // SPU cache file (version + block size type) const std::string loc = ppu_cache + "spu-" + fmt::to_lower(g_cfg.core.spu_block_size.to_string()) + "-v1-tane.dat"; - auto cache = std::make_shared(loc); + spu_cache cache(loc); - if (!*cache) + if (!cache) { LOG_ERROR(SPU, "Failed to initialize SPU cache at: %s", loc); return; } // Read cache - auto func_list = cache->get(); + auto func_list = cache.get(); atomic_t fnext{}; atomic_t fail_flag{0}; @@ -469,11 +469,8 @@ void spu_cache::initialize() LOG_SUCCESS(SPU, "SPU Runtime: Built %u functions.", func_list.size()); } - // Register cache instance - fxm::import([&]() -> std::shared_ptr&& - { - return std::move(cache); - }); + // Initialize global cache instance + g_fxo->init(std::move(cache)); } bool spu_runtime::func_compare::operator()(const std::vector& lhs, const std::vector& rhs) const @@ -571,7 +568,7 @@ bool spu_runtime::add(u64 last_reset_count, void* _where, spu_function_t compile // Register function in PIC map m_pic_map[{func.data() + _off, func.size() - _off}] = compiled; - if (fxm::check_unlocked()) + if (g_fxo->get()) { // Rebuild trampolines if necessary if (const auto new_tr = rebuild_ubertrampoline()) @@ -4168,7 +4165,6 @@ public: // Initialize if necessary if (!m_spurt) { - m_cache = fxm::get(); m_spurt = g_fxo->get(); cpu_translator::initialize(m_jit.get_context(), m_jit.get_engine()); @@ -4203,9 +4199,9 @@ public: std::string log; - if (m_cache && g_cfg.core.spu_cache) + if (auto cache = g_fxo->get(); cache && g_cfg.core.spu_cache) { - m_cache->add(func); + cache->add(func); } { @@ -4220,7 +4216,7 @@ public: fmt::append(m_hash, "spu-0x%05x-%s", func[0], fmt::base57(output)); } - if (m_cache) + if (g_fxo->get()) { LOG_SUCCESS(SPU, "LLVM: Building %s (size %u)...", m_hash, func.size() - 1); } diff --git a/rpcs3/Emu/Cell/SPURecompiler.h b/rpcs3/Emu/Cell/SPURecompiler.h index 02ce6498ee..2e329a8d1e 100644 --- a/rpcs3/Emu/Cell/SPURecompiler.h +++ b/rpcs3/Emu/Cell/SPURecompiler.h @@ -19,6 +19,10 @@ class spu_cache public: spu_cache(const std::string& loc); + spu_cache(spu_cache&&) noexcept = default; + + spu_cache& operator=(spu_cache&&) noexcept = default; + ~spu_cache(); operator bool() const @@ -337,8 +341,6 @@ protected: // Sorted function info std::map m_funcs; - std::shared_ptr m_cache; - private: // For private use std::bitset<0x10000> m_bits;