From 51927bc9dc191165403203a146bd21fecd704691 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 30 Jan 2020 18:19:21 -0500 Subject: [PATCH 1/3] kernel/physical_core: Remove unused kernel reference member variable This isn't used within the class, so it can be removed to simplify the overall interface. While we're in the same area, we can simplify a unique_ptr reset() call. --- src/core/hle/kernel/kernel.cpp | 8 ++++---- src/core/hle/kernel/physical_core.cpp | 5 ++--- src/core/hle/kernel/physical_core.h | 5 +---- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index 0cf3c8f70..edd4c4259 100644 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp @@ -101,7 +101,7 @@ struct KernelCore::Impl { void Initialize(KernelCore& kernel) { Shutdown(); - InitializePhysicalCores(kernel); + InitializePhysicalCores(); InitializeSystemResourceLimit(kernel); InitializeThreads(); InitializePreemption(); @@ -131,14 +131,14 @@ struct KernelCore::Impl { } cores.clear(); - exclusive_monitor.reset(nullptr); + exclusive_monitor.reset(); } - void InitializePhysicalCores(KernelCore& kernel) { + void InitializePhysicalCores() { exclusive_monitor = Core::MakeExclusiveMonitor(system.Memory(), global_scheduler.CpuCoresCount()); for (std::size_t i = 0; i < global_scheduler.CpuCoresCount(); i++) { - cores.emplace_back(system, kernel, i, *exclusive_monitor); + cores.emplace_back(system, i, *exclusive_monitor); } } diff --git a/src/core/hle/kernel/physical_core.cpp b/src/core/hle/kernel/physical_core.cpp index 896a1a87a..e96d063fd 100644 --- a/src/core/hle/kernel/physical_core.cpp +++ b/src/core/hle/kernel/physical_core.cpp @@ -10,16 +10,15 @@ #include "core/arm/exclusive_monitor.h" #include "core/arm/unicorn/arm_unicorn.h" #include "core/core.h" -#include "core/hle/kernel/kernel.h" #include "core/hle/kernel/physical_core.h" #include "core/hle/kernel/scheduler.h" #include "core/hle/kernel/thread.h" namespace Kernel { -PhysicalCore::PhysicalCore(Core::System& system, KernelCore& kernel, std::size_t id, +PhysicalCore::PhysicalCore(Core::System& system, std::size_t id, Core::ExclusiveMonitor& exclusive_monitor) - : core_index{id}, kernel{kernel} { + : core_index{id} { #ifdef ARCHITECTURE_x86_64 arm_interface = std::make_shared(system, exclusive_monitor, core_index); #else diff --git a/src/core/hle/kernel/physical_core.h b/src/core/hle/kernel/physical_core.h index fbef0801f..7dca97d1b 100644 --- a/src/core/hle/kernel/physical_core.h +++ b/src/core/hle/kernel/physical_core.h @@ -21,9 +21,7 @@ namespace Kernel { class PhysicalCore { public: - PhysicalCore(Core::System& system, KernelCore& kernel, std::size_t id, - Core::ExclusiveMonitor& exclusive_monitor); - + PhysicalCore(Core::System& system, std::size_t id, Core::ExclusiveMonitor& exclusive_monitor); ~PhysicalCore(); /// Execute current jit state @@ -66,7 +64,6 @@ public: private: std::size_t core_index; - KernelCore& kernel; std::shared_ptr arm_interface; std::shared_ptr scheduler; }; From 16e7b7b83d5a812cb389f808049ede3a75b8bdc3 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 30 Jan 2020 18:21:10 -0500 Subject: [PATCH 2/3] core/cpu_manager: Remove unused includes Nothing from these headers are used within this source file, so we can remove them. --- src/core/cpu_manager.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/core/cpu_manager.cpp b/src/core/cpu_manager.cpp index 752534868..70ddbdcca 100644 --- a/src/core/cpu_manager.cpp +++ b/src/core/cpu_manager.cpp @@ -2,14 +2,12 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. -#include "common/assert.h" #include "core/arm/exclusive_monitor.h" #include "core/core.h" #include "core/core_manager.h" #include "core/core_timing.h" #include "core/cpu_manager.h" #include "core/gdbstub/gdbstub.h" -#include "core/settings.h" namespace Core { From 2de2bb980e8b032aeb6413adaaed6701e76e73f7 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 30 Jan 2020 18:38:28 -0500 Subject: [PATCH 3/3] kernel/physical_core: Make use of std::unique_ptr shared_ptr was used in 2d1984c20c75e03ec79eeb3806b12efa1679b977 due to a misunderstanding of how the language generates move constructors and move assignment operators. If a destructor is user-provided, then the compiler won't generate the move constructor and move assignment operators by default--they must be explicitly opted into. The reason for the compilation errors is due to the fact that the language will fall back to attempting to use the copy constructor/copy assignment operators if the respective move constructor or move assignment operator is unavailable. Given that we explicitly opt into them now, the the move constructor and move assignment operators will be generated as expected. --- src/core/hle/kernel/physical_core.cpp | 4 ++-- src/core/hle/kernel/physical_core.h | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/core/hle/kernel/physical_core.cpp b/src/core/hle/kernel/physical_core.cpp index e96d063fd..9303dd273 100644 --- a/src/core/hle/kernel/physical_core.cpp +++ b/src/core/hle/kernel/physical_core.cpp @@ -20,13 +20,13 @@ PhysicalCore::PhysicalCore(Core::System& system, std::size_t id, Core::ExclusiveMonitor& exclusive_monitor) : core_index{id} { #ifdef ARCHITECTURE_x86_64 - arm_interface = std::make_shared(system, exclusive_monitor, core_index); + arm_interface = std::make_unique(system, exclusive_monitor, core_index); #else arm_interface = std::make_shared(system); LOG_WARNING(Core, "CPU JIT requested, but Dynarmic not available"); #endif - scheduler = std::make_shared(system, *arm_interface, core_index); + scheduler = std::make_unique(system, *arm_interface, core_index); } PhysicalCore::~PhysicalCore() = default; diff --git a/src/core/hle/kernel/physical_core.h b/src/core/hle/kernel/physical_core.h index 7dca97d1b..4c32c0f1b 100644 --- a/src/core/hle/kernel/physical_core.h +++ b/src/core/hle/kernel/physical_core.h @@ -24,6 +24,12 @@ public: PhysicalCore(Core::System& system, std::size_t id, Core::ExclusiveMonitor& exclusive_monitor); ~PhysicalCore(); + PhysicalCore(const PhysicalCore&) = delete; + PhysicalCore& operator=(const PhysicalCore&) = delete; + + PhysicalCore(PhysicalCore&&) = default; + PhysicalCore& operator=(PhysicalCore&&) = default; + /// Execute current jit state void Run(); /// Execute a single instruction in current jit. @@ -64,8 +70,8 @@ public: private: std::size_t core_index; - std::shared_ptr arm_interface; - std::shared_ptr scheduler; + std::unique_ptr arm_interface; + std::unique_ptr scheduler; }; } // namespace Kernel