diff options
| author | 2018-10-15 08:53:01 -0400 | |
|---|---|---|
| committer | 2018-10-15 14:15:50 -0400 | |
| commit | aeadbfa790b11ba859605df8a9357b960084b2a0 (patch) | |
| tree | eb46f94603e38f81ccf443024357ad567d5ef15b /src | |
| parent | core: Make CPUBarrier a unique_ptr instead of a shared_ptr (diff) | |
| download | yuzu-aeadbfa790b11ba859605df8a9357b960084b2a0.tar.gz yuzu-aeadbfa790b11ba859605df8a9357b960084b2a0.tar.xz yuzu-aeadbfa790b11ba859605df8a9357b960084b2a0.zip | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/arm/dynarmic/arm_dynarmic.cpp | 7 | ||||
| -rw-r--r-- | src/core/arm/dynarmic/arm_dynarmic.h | 4 | ||||
| -rw-r--r-- | src/core/core.cpp | 5 | ||||
| -rw-r--r-- | src/core/core_cpu.cpp | 7 | ||||
| -rw-r--r-- | src/core/core_cpu.h | 5 |
5 files changed, 13 insertions, 15 deletions
diff --git a/src/core/arm/dynarmic/arm_dynarmic.cpp b/src/core/arm/dynarmic/arm_dynarmic.cpp index 0762321a9..4d2491870 100644 --- a/src/core/arm/dynarmic/arm_dynarmic.cpp +++ b/src/core/arm/dynarmic/arm_dynarmic.cpp | |||
| @@ -144,7 +144,7 @@ std::unique_ptr<Dynarmic::A64::Jit> ARM_Dynarmic::MakeJit() const { | |||
| 144 | 144 | ||
| 145 | // Multi-process state | 145 | // Multi-process state |
| 146 | config.processor_id = core_index; | 146 | config.processor_id = core_index; |
| 147 | config.global_monitor = &exclusive_monitor->monitor; | 147 | config.global_monitor = &exclusive_monitor.monitor; |
| 148 | 148 | ||
| 149 | // System registers | 149 | // System registers |
| 150 | config.tpidrro_el0 = &cb->tpidrro_el0; | 150 | config.tpidrro_el0 = &cb->tpidrro_el0; |
| @@ -171,10 +171,9 @@ void ARM_Dynarmic::Step() { | |||
| 171 | cb->InterpreterFallback(jit->GetPC(), 1); | 171 | cb->InterpreterFallback(jit->GetPC(), 1); |
| 172 | } | 172 | } |
| 173 | 173 | ||
| 174 | ARM_Dynarmic::ARM_Dynarmic(std::shared_ptr<ExclusiveMonitor> exclusive_monitor, | 174 | ARM_Dynarmic::ARM_Dynarmic(ExclusiveMonitor& exclusive_monitor, std::size_t core_index) |
| 175 | std::size_t core_index) | ||
| 176 | : cb(std::make_unique<ARM_Dynarmic_Callbacks>(*this)), core_index{core_index}, | 175 | : cb(std::make_unique<ARM_Dynarmic_Callbacks>(*this)), core_index{core_index}, |
| 177 | exclusive_monitor{std::dynamic_pointer_cast<DynarmicExclusiveMonitor>(exclusive_monitor)} { | 176 | exclusive_monitor{dynamic_cast<DynarmicExclusiveMonitor&>(exclusive_monitor)} { |
| 178 | ThreadContext ctx{}; | 177 | ThreadContext ctx{}; |
| 179 | inner_unicorn.SaveContext(ctx); | 178 | inner_unicorn.SaveContext(ctx); |
| 180 | PageTableChanged(); | 179 | PageTableChanged(); |
diff --git a/src/core/arm/dynarmic/arm_dynarmic.h b/src/core/arm/dynarmic/arm_dynarmic.h index 4ee92ee27..512bf8ce9 100644 --- a/src/core/arm/dynarmic/arm_dynarmic.h +++ b/src/core/arm/dynarmic/arm_dynarmic.h | |||
| @@ -23,7 +23,7 @@ class DynarmicExclusiveMonitor; | |||
| 23 | 23 | ||
| 24 | class ARM_Dynarmic final : public ARM_Interface { | 24 | class ARM_Dynarmic final : public ARM_Interface { |
| 25 | public: | 25 | public: |
| 26 | ARM_Dynarmic(std::shared_ptr<ExclusiveMonitor> exclusive_monitor, std::size_t core_index); | 26 | ARM_Dynarmic(ExclusiveMonitor& exclusive_monitor, std::size_t core_index); |
| 27 | ~ARM_Dynarmic(); | 27 | ~ARM_Dynarmic(); |
| 28 | 28 | ||
| 29 | void MapBackingMemory(VAddr address, std::size_t size, u8* memory, | 29 | void MapBackingMemory(VAddr address, std::size_t size, u8* memory, |
| @@ -62,7 +62,7 @@ private: | |||
| 62 | ARM_Unicorn inner_unicorn; | 62 | ARM_Unicorn inner_unicorn; |
| 63 | 63 | ||
| 64 | std::size_t core_index; | 64 | std::size_t core_index; |
| 65 | std::shared_ptr<DynarmicExclusiveMonitor> exclusive_monitor; | 65 | DynarmicExclusiveMonitor& exclusive_monitor; |
| 66 | 66 | ||
| 67 | Memory::PageTable* current_page_table = nullptr; | 67 | Memory::PageTable* current_page_table = nullptr; |
| 68 | }; | 68 | }; |
diff --git a/src/core/core.cpp b/src/core/core.cpp index 1b9b1f608..876469ee3 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp | |||
| @@ -142,7 +142,7 @@ struct System::Impl { | |||
| 142 | cpu_barrier = std::make_unique<CpuBarrier>(); | 142 | cpu_barrier = std::make_unique<CpuBarrier>(); |
| 143 | cpu_exclusive_monitor = Cpu::MakeExclusiveMonitor(cpu_cores.size()); | 143 | cpu_exclusive_monitor = Cpu::MakeExclusiveMonitor(cpu_cores.size()); |
| 144 | for (std::size_t index = 0; index < cpu_cores.size(); ++index) { | 144 | for (std::size_t index = 0; index < cpu_cores.size(); ++index) { |
| 145 | cpu_cores[index] = std::make_shared<Cpu>(cpu_exclusive_monitor, *cpu_barrier, index); | 145 | cpu_cores[index] = std::make_shared<Cpu>(*cpu_exclusive_monitor, *cpu_barrier, index); |
| 146 | } | 146 | } |
| 147 | 147 | ||
| 148 | telemetry_session = std::make_unique<Core::TelemetrySession>(); | 148 | telemetry_session = std::make_unique<Core::TelemetrySession>(); |
| @@ -245,6 +245,7 @@ struct System::Impl { | |||
| 245 | for (auto& cpu_core : cpu_cores) { | 245 | for (auto& cpu_core : cpu_cores) { |
| 246 | cpu_core.reset(); | 246 | cpu_core.reset(); |
| 247 | } | 247 | } |
| 248 | cpu_exclusive_monitor.reset(); | ||
| 248 | cpu_barrier.reset(); | 249 | cpu_barrier.reset(); |
| 249 | 250 | ||
| 250 | // Shutdown kernel and core timing | 251 | // Shutdown kernel and core timing |
| @@ -282,7 +283,7 @@ struct System::Impl { | |||
| 282 | std::unique_ptr<VideoCore::RendererBase> renderer; | 283 | std::unique_ptr<VideoCore::RendererBase> renderer; |
| 283 | std::unique_ptr<Tegra::GPU> gpu_core; | 284 | std::unique_ptr<Tegra::GPU> gpu_core; |
| 284 | std::shared_ptr<Tegra::DebugContext> debug_context; | 285 | std::shared_ptr<Tegra::DebugContext> debug_context; |
| 285 | std::shared_ptr<ExclusiveMonitor> cpu_exclusive_monitor; | 286 | std::unique_ptr<ExclusiveMonitor> cpu_exclusive_monitor; |
| 286 | std::unique_ptr<CpuBarrier> cpu_barrier; | 287 | std::unique_ptr<CpuBarrier> cpu_barrier; |
| 287 | std::array<std::shared_ptr<Cpu>, NUM_CPU_CORES> cpu_cores; | 288 | std::array<std::shared_ptr<Cpu>, NUM_CPU_CORES> cpu_cores; |
| 288 | std::array<std::unique_ptr<std::thread>, NUM_CPU_CORES - 1> cpu_core_threads; | 289 | std::array<std::unique_ptr<std::thread>, NUM_CPU_CORES - 1> cpu_core_threads; |
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() { | |||
| 49 | return false; | 49 | return false; |
| 50 | } | 50 | } |
| 51 | 51 | ||
| 52 | Cpu::Cpu(std::shared_ptr<ExclusiveMonitor> exclusive_monitor, CpuBarrier& cpu_barrier, | 52 | Cpu::Cpu(ExclusiveMonitor& exclusive_monitor, CpuBarrier& cpu_barrier, std::size_t core_index) |
| 53 | std::size_t core_index) | ||
| 54 | : cpu_barrier{cpu_barrier}, core_index{core_index} { | 53 | : cpu_barrier{cpu_barrier}, core_index{core_index} { |
| 55 | if (Settings::values.use_cpu_jit) { | 54 | if (Settings::values.use_cpu_jit) { |
| 56 | #ifdef ARCHITECTURE_x86_64 | 55 | #ifdef ARCHITECTURE_x86_64 |
| @@ -68,10 +67,10 @@ Cpu::Cpu(std::shared_ptr<ExclusiveMonitor> exclusive_monitor, CpuBarrier& cpu_ba | |||
| 68 | 67 | ||
| 69 | Cpu::~Cpu() = default; | 68 | Cpu::~Cpu() = default; |
| 70 | 69 | ||
| 71 | std::shared_ptr<ExclusiveMonitor> Cpu::MakeExclusiveMonitor(std::size_t num_cores) { | 70 | std::unique_ptr<ExclusiveMonitor> Cpu::MakeExclusiveMonitor(std::size_t num_cores) { |
| 72 | if (Settings::values.use_cpu_jit) { | 71 | if (Settings::values.use_cpu_jit) { |
| 73 | #ifdef ARCHITECTURE_x86_64 | 72 | #ifdef ARCHITECTURE_x86_64 |
| 74 | return std::make_shared<DynarmicExclusiveMonitor>(num_cores); | 73 | return std::make_unique<DynarmicExclusiveMonitor>(num_cores); |
| 75 | #else | 74 | #else |
| 76 | return nullptr; // TODO(merry): Passthrough exclusive monitor | 75 | return nullptr; // TODO(merry): Passthrough exclusive monitor |
| 77 | #endif | 76 | #endif |
diff --git a/src/core/core_cpu.h b/src/core/core_cpu.h index 68d83ac8f..3d62de7cb 100644 --- a/src/core/core_cpu.h +++ b/src/core/core_cpu.h | |||
| @@ -41,8 +41,7 @@ private: | |||
| 41 | 41 | ||
| 42 | class Cpu { | 42 | class Cpu { |
| 43 | public: | 43 | public: |
| 44 | Cpu(std::shared_ptr<ExclusiveMonitor> exclusive_monitor, CpuBarrier& cpu_barrier, | 44 | Cpu(ExclusiveMonitor& exclusive_monitor, CpuBarrier& cpu_barrier, std::size_t core_index); |
| 45 | std::size_t core_index); | ||
| 46 | ~Cpu(); | 45 | ~Cpu(); |
| 47 | 46 | ||
| 48 | void RunLoop(bool tight_loop = true); | 47 | void RunLoop(bool tight_loop = true); |
| @@ -71,7 +70,7 @@ public: | |||
| 71 | return core_index; | 70 | return core_index; |
| 72 | } | 71 | } |
| 73 | 72 | ||
| 74 | static std::shared_ptr<ExclusiveMonitor> MakeExclusiveMonitor(std::size_t num_cores); | 73 | static std::unique_ptr<ExclusiveMonitor> MakeExclusiveMonitor(std::size_t num_cores); |
| 75 | 74 | ||
| 76 | private: | 75 | private: |
| 77 | void Reschedule(); | 76 | void Reschedule(); |