From 4ec3e968ff87bcc700f0fa9f2e62aaa519afd756 Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Sun, 25 Aug 2019 17:27:38 +0300 Subject: [PATCH] Use g_fxo for jit_core_allocator --- rpcs3/Emu/Cell/PPUThread.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/rpcs3/Emu/Cell/PPUThread.cpp b/rpcs3/Emu/Cell/PPUThread.cpp index 84e7f2ae55..d08c8468da 100644 --- a/rpcs3/Emu/Cell/PPUThread.cpp +++ b/rpcs3/Emu/Cell/PPUThread.cpp @@ -1445,11 +1445,14 @@ extern void ppu_initialize(const ppu_module& info) struct jit_core_allocator { - ::semaphore<0x7fffffff> sem; + const s32 thread_count = g_cfg.core.llvm_threads ? std::min(g_cfg.core.llvm_threads, limit()) : limit(); - jit_core_allocator(s32 arg) - : sem(arg) + // Initialize global semaphore with the max number of threads + ::semaphore<0x7fffffff> sem{std::max(thread_count, 1)}; + + static s32 limit() { + return static_cast(std::thread::hardware_concurrency()); } }; @@ -1462,10 +1465,8 @@ extern void ppu_initialize(const ppu_module& info) // Compiler mutex (global) static shared_mutex jmutex; - // 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(); - const auto jcores = fxm::get_always(std::max(thread_count, 1)); + // Get jit core allocator instance + const auto jcores = g_fxo->get(); // Worker threads std::vector jthreads;