summaryrefslogtreecommitdiff
path: root/src/core/core_cpu.cpp
diff options
context:
space:
mode:
authorGravatar Lioncash2019-02-14 12:42:58 -0500
committerGravatar Lioncash2019-02-15 21:50:25 -0500
commitbd983414f643b734a1f8bebe3183723733344f72 (patch)
treebda0421458439e25cba9d772a6a79b56e473d72e /src/core/core_cpu.cpp
parentMerge pull request #2113 from ReinUsesLisp/vulkan-base (diff)
downloadyuzu-bd983414f643b734a1f8bebe3183723733344f72.tar.gz
yuzu-bd983414f643b734a1f8bebe3183723733344f72.tar.xz
yuzu-bd983414f643b734a1f8bebe3183723733344f72.zip
core_timing: Convert core timing into a class
Gets rid of the largest set of mutable global state within the core. This also paves a way for eliminating usages of GetInstance() on the System class as a follow-up. Note that no behavioral changes have been made, and this simply extracts the functionality into a class. This also has the benefit of making dependencies on the core timing functionality explicit within the relevant interfaces.
Diffstat (limited to 'src/core/core_cpu.cpp')
-rw-r--r--src/core/core_cpu.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/core/core_cpu.cpp b/src/core/core_cpu.cpp
index 452366250..54aa21a3a 100644
--- a/src/core/core_cpu.cpp
+++ b/src/core/core_cpu.cpp
@@ -49,17 +49,18 @@ bool CpuBarrier::Rendezvous() {
49 return false; 49 return false;
50} 50}
51 51
52Cpu::Cpu(ExclusiveMonitor& exclusive_monitor, CpuBarrier& cpu_barrier, std::size_t core_index) 52Cpu::Cpu(Timing::CoreTiming& core_timing, ExclusiveMonitor& exclusive_monitor,
53 : cpu_barrier{cpu_barrier}, core_index{core_index} { 53 CpuBarrier& cpu_barrier, std::size_t core_index)
54 : cpu_barrier{cpu_barrier}, core_timing{core_timing}, core_index{core_index} {
54 if (Settings::values.use_cpu_jit) { 55 if (Settings::values.use_cpu_jit) {
55#ifdef ARCHITECTURE_x86_64 56#ifdef ARCHITECTURE_x86_64
56 arm_interface = std::make_unique<ARM_Dynarmic>(exclusive_monitor, core_index); 57 arm_interface = std::make_unique<ARM_Dynarmic>(core_timing, exclusive_monitor, core_index);
57#else 58#else
58 arm_interface = std::make_unique<ARM_Unicorn>(); 59 arm_interface = std::make_unique<ARM_Unicorn>();
59 LOG_WARNING(Core, "CPU JIT requested, but Dynarmic not available"); 60 LOG_WARNING(Core, "CPU JIT requested, but Dynarmic not available");
60#endif 61#endif
61 } else { 62 } else {
62 arm_interface = std::make_unique<ARM_Unicorn>(); 63 arm_interface = std::make_unique<ARM_Unicorn>(core_timing);
63 } 64 }
64 65
65 scheduler = std::make_unique<Kernel::Scheduler>(*arm_interface); 66 scheduler = std::make_unique<Kernel::Scheduler>(*arm_interface);
@@ -93,14 +94,14 @@ void Cpu::RunLoop(bool tight_loop) {
93 94
94 if (IsMainCore()) { 95 if (IsMainCore()) {
95 // TODO(Subv): Only let CoreTiming idle if all 4 cores are idling. 96 // TODO(Subv): Only let CoreTiming idle if all 4 cores are idling.
96 Timing::Idle(); 97 core_timing.Idle();
97 Timing::Advance(); 98 core_timing.Advance();
98 } 99 }
99 100
100 PrepareReschedule(); 101 PrepareReschedule();
101 } else { 102 } else {
102 if (IsMainCore()) { 103 if (IsMainCore()) {
103 Timing::Advance(); 104 core_timing.Advance();
104 } 105 }
105 106
106 if (tight_loop) { 107 if (tight_loop) {