diff --git a/src/core/core.cpp b/src/core/core.cpp index 32baa40dcd..1b9b1f608f 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -139,10 +139,10 @@ struct System::Impl { auto main_process = Kernel::Process::Create(kernel, "main"); kernel.MakeCurrentProcess(main_process.get()); - cpu_barrier = std::make_shared(); + cpu_barrier = std::make_unique(); cpu_exclusive_monitor = Cpu::MakeExclusiveMonitor(cpu_cores.size()); for (std::size_t index = 0; index < cpu_cores.size(); ++index) { - cpu_cores[index] = std::make_shared(cpu_exclusive_monitor, cpu_barrier, index); + cpu_cores[index] = std::make_shared(cpu_exclusive_monitor, *cpu_barrier, index); } telemetry_session = std::make_unique(); @@ -283,7 +283,7 @@ struct System::Impl { std::unique_ptr gpu_core; std::shared_ptr debug_context; std::shared_ptr cpu_exclusive_monitor; - std::shared_ptr cpu_barrier; + std::unique_ptr cpu_barrier; std::array, NUM_CPU_CORES> cpu_cores; std::array, NUM_CPU_CORES - 1> cpu_core_threads; std::size_t active_core{}; ///< Active core, only used in single thread mode diff --git a/src/core/core_cpu.cpp b/src/core/core_cpu.cpp index 265f8ed9cc..928262c9bb 100644 --- a/src/core/core_cpu.cpp +++ b/src/core/core_cpu.cpp @@ -49,10 +49,9 @@ bool CpuBarrier::Rendezvous() { return false; } -Cpu::Cpu(std::shared_ptr exclusive_monitor, - std::shared_ptr cpu_barrier, std::size_t core_index) - : cpu_barrier{std::move(cpu_barrier)}, core_index{core_index} { - +Cpu::Cpu(std::shared_ptr exclusive_monitor, CpuBarrier& cpu_barrier, + std::size_t core_index) + : cpu_barrier{cpu_barrier}, core_index{core_index} { if (Settings::values.use_cpu_jit) { #ifdef ARCHITECTURE_x86_64 arm_interface = std::make_unique(exclusive_monitor, core_index); @@ -83,7 +82,7 @@ std::shared_ptr Cpu::MakeExclusiveMonitor(std::size_t num_core void Cpu::RunLoop(bool tight_loop) { // Wait for all other CPU cores to complete the previous slice, such that they run in lock-step - if (!cpu_barrier->Rendezvous()) { + if (!cpu_barrier.Rendezvous()) { // If rendezvous failed, session has been killed return; } diff --git a/src/core/core_cpu.h b/src/core/core_cpu.h index ee7e04abc8..68d83ac8f3 100644 --- a/src/core/core_cpu.h +++ b/src/core/core_cpu.h @@ -41,8 +41,8 @@ private: class Cpu { public: - Cpu(std::shared_ptr exclusive_monitor, - std::shared_ptr cpu_barrier, std::size_t core_index); + Cpu(std::shared_ptr exclusive_monitor, CpuBarrier& cpu_barrier, + std::size_t core_index); ~Cpu(); void RunLoop(bool tight_loop = true); @@ -77,7 +77,7 @@ private: void Reschedule(); std::unique_ptr arm_interface; - std::shared_ptr cpu_barrier; + CpuBarrier& cpu_barrier; std::shared_ptr scheduler; std::atomic reschedule_pending = false;