diff --git a/rpcs3/Emu/Cell/PPUThread.cpp b/rpcs3/Emu/Cell/PPUThread.cpp index 995799ccac..71e2c120c6 100644 --- a/rpcs3/Emu/Cell/PPUThread.cpp +++ b/rpcs3/Emu/Cell/PPUThread.cpp @@ -1156,6 +1156,16 @@ extern void ppu_initialize(const ppu_module& info) std::vector funcs; }; + struct jit_core_allocator + { + ::semaphore<0x7fffffff> sem; + + jit_core_allocator(s32 arg) + : sem(arg) + { + } + }; + // Permanently loaded compiled PPU modules (name -> data) jit_module& jit_mod = fxm::get_always>()->emplace(cache_path + info.name, jit_module{}).first->second; @@ -1168,7 +1178,7 @@ extern void ppu_initialize(const ppu_module& info) // Initialize global semaphore with the max number of threads u32 max_threads = static_cast(g_cfg.core.llvm_threads); s32 thread_count = max_threads > 0 ? std::min(max_threads, std::thread::hardware_concurrency()) : std::thread::hardware_concurrency(); - static semaphore jcores(std::max(thread_count, 1)); + const auto jcores = fxm::get_always(std::max(thread_count, 1)); // Worker threads std::vector jthreads; @@ -1349,14 +1359,14 @@ extern void ppu_initialize(const ppu_module& info) } // Create worker thread for compilation - jthreads.emplace_back([&jit, obj_name = obj_name, part = std::move(part), &cache_path, fragment_sync, findex = ::size32(jthreads)]() + jthreads.emplace_back([&jit, obj_name = obj_name, part = std::move(part), &cache_path, fragment_sync, jcores, findex = ::size32(jthreads)]() { // Set low priority thread_ctrl::set_native_priority(-1); // Allocate "core" { - semaphore_lock jlock(jcores); + semaphore_lock jlock(jcores->sem); if (Emu.IsStopped()) {