From c34efbbd60a41afbbab2ff17bbff999519cfb4b6 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 15 Oct 2018 08:42:06 -0400 Subject: core: Make CPUBarrier a unique_ptr instead of a shared_ptr This will always outlive the Cpu instances, since it's destroyed after we destroy the Cpu instances on shutdown, so there's no need for shared ownership semantics here. --- src/core/core_cpu.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/core/core_cpu.cpp') diff --git a/src/core/core_cpu.cpp b/src/core/core_cpu.cpp index 265f8ed9c..928262c9b 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; } -- cgit v1.2.3 From aeadbfa790b11ba859605df8a9357b960084b2a0 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 15 Oct 2018 08:53:01 -0400 Subject: core: Make the exclusive monitor a unique_ptr instead of a shared_ptr Like the barrier, this is owned entirely by the System and will always outlive the encompassing state, so shared ownership semantics aren't necessary here. --- src/core/core_cpu.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/core/core_cpu.cpp') diff --git a/src/core/core_cpu.cpp b/src/core/core_cpu.cpp index 928262c9b..9f856ca6e 100644 --- a/src/core/core_cpu.cpp +++ b/src/core/core_cpu.cpp @@ -49,8 +49,7 @@ bool CpuBarrier::Rendezvous() { return false; } -Cpu::Cpu(std::shared_ptr exclusive_monitor, CpuBarrier& cpu_barrier, - std::size_t core_index) +Cpu::Cpu(ExclusiveMonitor& 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 @@ -68,10 +67,10 @@ Cpu::Cpu(std::shared_ptr exclusive_monitor, CpuBarrier& cpu_ba Cpu::~Cpu() = default; -std::shared_ptr Cpu::MakeExclusiveMonitor(std::size_t num_cores) { +std::unique_ptr Cpu::MakeExclusiveMonitor(std::size_t num_cores) { if (Settings::values.use_cpu_jit) { #ifdef ARCHITECTURE_x86_64 - return std::make_shared(num_cores); + return std::make_unique(num_cores); #else return nullptr; // TODO(merry): Passthrough exclusive monitor #endif -- cgit v1.2.3 From 5484742fdaf036db03ac7b8c746df5004f74efad Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 15 Oct 2018 09:25:11 -0400 Subject: core_cpu: Make Cpu scheduler instances unique_ptrs instead of shared_ptrs --- src/core/core_cpu.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core/core_cpu.cpp') diff --git a/src/core/core_cpu.cpp b/src/core/core_cpu.cpp index 9f856ca6e..fffda8a99 100644 --- a/src/core/core_cpu.cpp +++ b/src/core/core_cpu.cpp @@ -62,7 +62,7 @@ Cpu::Cpu(ExclusiveMonitor& exclusive_monitor, CpuBarrier& cpu_barrier, std::size arm_interface = std::make_unique(); } - scheduler = std::make_shared(*arm_interface); + scheduler = std::make_unique(*arm_interface); } Cpu::~Cpu() = default; -- cgit v1.2.3