diff --git a/Utilities/mutex.cpp b/Utilities/mutex.cpp index 9937212670..efdab8060f 100644 --- a/Utilities/mutex.cpp +++ b/Utilities/mutex.cpp @@ -14,7 +14,10 @@ void shared_mutex::imp_lock_shared(s64 _old) for (int i = 0; i < 10; i++) { - busy_wait(); + if (i != 0) + { + busy_wait(); + } const s64 value = m_value.load(); @@ -173,7 +176,10 @@ void shared_mutex::imp_lock(s64 _old) for (int i = 0; i < 10; i++) { - busy_wait(); + if (i != 0) + { + busy_wait(); + } const s64 value = m_value.load(); @@ -236,6 +242,10 @@ void shared_mutex::imp_lock_degrade() bool shared_mutex::try_lock_shared() { + if (m_value < c_min) // Fast path + { + return false; + } // Conditional decrement return m_value.fetch_op([](s64& value) { if (value >= c_min) value -= c_min; }) >= c_min; } diff --git a/rpcs3/Emu/Cell/SPUASMJITRecompiler.cpp b/rpcs3/Emu/Cell/SPUASMJITRecompiler.cpp index 3400adf07c..54f4bb2e54 100644 --- a/rpcs3/Emu/Cell/SPUASMJITRecompiler.cpp +++ b/rpcs3/Emu/Cell/SPUASMJITRecompiler.cpp @@ -36,25 +36,25 @@ spu_recompiler::spu_recompiler() } } -void spu_recompiler::compile(spu_function_t& f) +bool spu_recompiler::compile(std::shared_ptr f) { std::lock_guard lock(m_mutex); - if (f.compiled) + if (f->compiled) { // return if function already compiled - return; + return true; } - if (f.addr >= 0x40000 || f.addr % 4 || f.size == 0 || f.size > 0x40000 - f.addr || f.size % 4) + if (f->addr >= 0x40000 || f->addr % 4 || f->size == 0 || f->size > 0x40000 - f->addr || f->size % 4) { - fmt::throw_exception("Invalid SPU function (addr=0x%05x, size=0x%x)" HERE, f.addr, f.size); + fmt::throw_exception("Invalid SPU function (addr=0x%05x, size=0x%x)" HERE, f->addr, f->size); } using namespace asmjit; SPUDisAsm dis_asm(CPUDisAsm_InterpreterMode); - dis_asm.offset = reinterpret_cast(f.data.data()) - f.addr; + dis_asm.offset = reinterpret_cast(f->data.data()) - f->addr; StringLogger logger; logger.addOptions(Logger::kOptionBinaryForm); @@ -63,10 +63,10 @@ void spu_recompiler::compile(spu_function_t& f) if (g_cfg.core.spu_debug) { - fmt::append(log, "========== SPU FUNCTION 0x%05x - 0x%05x ==========\n\n", f.addr, f.addr + f.size); + fmt::append(log, "========== SPU FUNCTION 0x%05x - 0x%05x ==========\n\n", f->addr, f->addr + f->size); } - this->m_func = &f; + this->m_func = f; asmjit::CodeHolder code; code.init(m_jit->getCodeInfo()); @@ -121,13 +121,13 @@ void spu_recompiler::compile(spu_function_t& f) compiler.alloc(vec_vars[5], asmjit::x86::xmm5); // Initialize labels - std::vector