From 5f00b3286748166fb1ae06f5cde03e307195880c Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Sun, 27 Oct 2019 12:57:02 +0300 Subject: [PATCH] SPU: fixup for duplicates in recompilers Fixup for the edge case. --- rpcs3/Emu/Cell/SPUASMJITRecompiler.cpp | 13 +++++++++++++ rpcs3/Emu/Cell/SPURecompiler.cpp | 13 +++++++++++++ 2 files changed, 26 insertions(+) diff --git a/rpcs3/Emu/Cell/SPUASMJITRecompiler.cpp b/rpcs3/Emu/Cell/SPUASMJITRecompiler.cpp index fa0f81056a..b2e3090887 100644 --- a/rpcs3/Emu/Cell/SPUASMJITRecompiler.cpp +++ b/rpcs3/Emu/Cell/SPUASMJITRecompiler.cpp @@ -47,6 +47,8 @@ void spu_recompiler::init() spu_function_t spu_recompiler::compile(std::vector&& _func) { + const u32 start0 = _func[0]; + const auto add_loc = m_spurt->add_empty(std::move(_func)); if (!add_loc) @@ -61,6 +63,17 @@ spu_function_t spu_recompiler::compile(std::vector&& _func) const std::vector& func = add_loc->data; + if (func[0] != start0) + { + // Wait for the duplicate + while (!add_loc->compiled) + { + add_loc->compiled.wait(nullptr); + } + + return add_loc->compiled; + } + if (auto cache = g_fxo->get(); cache && g_cfg.core.spu_cache && !add_loc->cached.exchange(1)) { cache->add(func); diff --git a/rpcs3/Emu/Cell/SPURecompiler.cpp b/rpcs3/Emu/Cell/SPURecompiler.cpp index 9e4b48a739..86eafdc05a 100644 --- a/rpcs3/Emu/Cell/SPURecompiler.cpp +++ b/rpcs3/Emu/Cell/SPURecompiler.cpp @@ -4161,6 +4161,8 @@ public: return compile_interpreter(); } + const u32 start0 = _func[0]; + const auto add_loc = m_spurt->add_empty(std::move(_func)); if (!add_loc) @@ -4170,6 +4172,17 @@ public: const std::vector& func = add_loc->data; + if (func[0] != start0) + { + // Wait for the duplicate + while (!add_loc->compiled) + { + add_loc->compiled.wait(nullptr); + } + + return add_loc->compiled; + } + std::string log; if (auto cache = g_fxo->get(); cache && g_cfg.core.spu_cache && !add_loc->cached.exchange(1))