From 10b33d0f790c57b2db458af2735a4c87a19f2f4e Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Thu, 5 May 2022 12:55:17 +0300 Subject: [PATCH] SPU: optimize conflicting PUTLLUC (No-TSX) Enable previously TSX-only optimization. --- rpcs3/Emu/Cell/SPUThread.cpp | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/rpcs3/Emu/Cell/SPUThread.cpp b/rpcs3/Emu/Cell/SPUThread.cpp index 5d7beb4145..86fd827e75 100644 --- a/rpcs3/Emu/Cell/SPUThread.cpp +++ b/rpcs3/Emu/Cell/SPUThread.cpp @@ -2795,7 +2795,6 @@ void do_cell_atomic_128_store(u32 addr, const void* to_write) shared_mem = addr; } - if (g_use_rtm) [[likely]] { auto& sdata = *vm::get_super_ptr(addr); auto& res = *utils::bless>(vm::g_reservations + (addr & 0xff80) / 2); @@ -2861,12 +2860,22 @@ void do_cell_atomic_128_store(u32 addr, const void* to_write) } } - u64 result = 0; + u64 result = 1; if (cpu->state & cpu_flag::pause) { result = 0; } + else if (!g_use_rtm) + { + // Provoke page fault + vm::_ref>(addr) += 0; + + // Hard lock + vm::writer_lock lock(addr); + mov_rdata(sdata, *static_cast(to_write)); + vm::reservation_acquire(addr) += 32; + } else if (cpu->id_type() != 2) { u64 stx, ftx; @@ -2896,22 +2905,6 @@ void do_cell_atomic_128_store(u32 addr, const void* to_write) static_cast(cpu->test_stopped()); } - else - { - auto& data = vm::_ref(addr); - auto [res, time0] = vm::reservation_lock(addr); - - *reinterpret_cast*>(&data) += 0; - - auto& super_data = *vm::get_super_ptr(addr); - { - // Full lock (heavyweight) - // TODO: vm::check_addr - vm::writer_lock lock(addr); - mov_rdata(super_data, *static_cast(to_write)); - res += 64; - } - } } void spu_thread::do_putlluc(const spu_mfc_cmd& args) @@ -3945,7 +3938,7 @@ s64 spu_thread::get_ch_value(u32 ch) state += cpu_flag::wait; using resrv_ptr = std::add_pointer_t; - + resrv_ptr resrv_mem = vm::get_super_ptr(raddr); std::shared_ptr rdata_shm;