diff options
| author | 2019-02-14 12:42:58 -0500 | |
|---|---|---|
| committer | 2019-02-15 21:50:25 -0500 | |
| commit | bd983414f643b734a1f8bebe3183723733344f72 (patch) | |
| tree | bda0421458439e25cba9d772a6a79b56e473d72e /src/core/arm | |
| parent | Merge pull request #2113 from ReinUsesLisp/vulkan-base (diff) | |
| download | yuzu-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/arm')
| -rw-r--r-- | src/core/arm/dynarmic/arm_dynarmic.cpp | 12 | ||||
| -rw-r--r-- | src/core/arm/dynarmic/arm_dynarmic.h | 8 | ||||
| -rw-r--r-- | src/core/arm/unicorn/arm_unicorn.cpp | 6 | ||||
| -rw-r--r-- | src/core/arm/unicorn/arm_unicorn.h | 8 |
4 files changed, 24 insertions, 10 deletions
diff --git a/src/core/arm/dynarmic/arm_dynarmic.cpp b/src/core/arm/dynarmic/arm_dynarmic.cpp index f28951f8a..9b7ca4030 100644 --- a/src/core/arm/dynarmic/arm_dynarmic.cpp +++ b/src/core/arm/dynarmic/arm_dynarmic.cpp | |||
| @@ -112,14 +112,14 @@ public: | |||
| 112 | // Always execute at least one tick. | 112 | // Always execute at least one tick. |
| 113 | amortized_ticks = std::max<u64>(amortized_ticks, 1); | 113 | amortized_ticks = std::max<u64>(amortized_ticks, 1); |
| 114 | 114 | ||
| 115 | Timing::AddTicks(amortized_ticks); | 115 | parent.core_timing.AddTicks(amortized_ticks); |
| 116 | num_interpreted_instructions = 0; | 116 | num_interpreted_instructions = 0; |
| 117 | } | 117 | } |
| 118 | u64 GetTicksRemaining() override { | 118 | u64 GetTicksRemaining() override { |
| 119 | return std::max(Timing::GetDowncount(), 0); | 119 | return std::max(parent.core_timing.GetDowncount(), 0); |
| 120 | } | 120 | } |
| 121 | u64 GetCNTPCT() override { | 121 | u64 GetCNTPCT() override { |
| 122 | return Timing::GetTicks(); | 122 | return parent.core_timing.GetTicks(); |
| 123 | } | 123 | } |
| 124 | 124 | ||
| 125 | ARM_Dynarmic& parent; | 125 | ARM_Dynarmic& parent; |
| @@ -172,8 +172,10 @@ void ARM_Dynarmic::Step() { | |||
| 172 | cb->InterpreterFallback(jit->GetPC(), 1); | 172 | cb->InterpreterFallback(jit->GetPC(), 1); |
| 173 | } | 173 | } |
| 174 | 174 | ||
| 175 | ARM_Dynarmic::ARM_Dynarmic(ExclusiveMonitor& exclusive_monitor, std::size_t core_index) | 175 | ARM_Dynarmic::ARM_Dynarmic(Timing::CoreTiming& core_timing, ExclusiveMonitor& exclusive_monitor, |
| 176 | : cb(std::make_unique<ARM_Dynarmic_Callbacks>(*this)), core_index{core_index}, | 176 | std::size_t core_index) |
| 177 | : cb(std::make_unique<ARM_Dynarmic_Callbacks>(*this)), inner_unicorn{core_timing}, | ||
| 178 | core_index{core_index}, core_timing{core_timing}, | ||
| 177 | exclusive_monitor{dynamic_cast<DynarmicExclusiveMonitor&>(exclusive_monitor)} { | 179 | exclusive_monitor{dynamic_cast<DynarmicExclusiveMonitor&>(exclusive_monitor)} { |
| 178 | ThreadContext ctx{}; | 180 | ThreadContext ctx{}; |
| 179 | inner_unicorn.SaveContext(ctx); | 181 | inner_unicorn.SaveContext(ctx); |
diff --git a/src/core/arm/dynarmic/arm_dynarmic.h b/src/core/arm/dynarmic/arm_dynarmic.h index 512bf8ce9..6cc458296 100644 --- a/src/core/arm/dynarmic/arm_dynarmic.h +++ b/src/core/arm/dynarmic/arm_dynarmic.h | |||
| @@ -16,6 +16,10 @@ namespace Memory { | |||
| 16 | struct PageTable; | 16 | struct PageTable; |
| 17 | } | 17 | } |
| 18 | 18 | ||
| 19 | namespace Core::Timing { | ||
| 20 | class CoreTiming; | ||
| 21 | } | ||
| 22 | |||
| 19 | namespace Core { | 23 | namespace Core { |
| 20 | 24 | ||
| 21 | class ARM_Dynarmic_Callbacks; | 25 | class ARM_Dynarmic_Callbacks; |
| @@ -23,7 +27,8 @@ class DynarmicExclusiveMonitor; | |||
| 23 | 27 | ||
| 24 | class ARM_Dynarmic final : public ARM_Interface { | 28 | class ARM_Dynarmic final : public ARM_Interface { |
| 25 | public: | 29 | public: |
| 26 | ARM_Dynarmic(ExclusiveMonitor& exclusive_monitor, std::size_t core_index); | 30 | ARM_Dynarmic(Timing::CoreTiming& core_timing, ExclusiveMonitor& exclusive_monitor, |
| 31 | std::size_t core_index); | ||
| 27 | ~ARM_Dynarmic(); | 32 | ~ARM_Dynarmic(); |
| 28 | 33 | ||
| 29 | void MapBackingMemory(VAddr address, std::size_t size, u8* memory, | 34 | void MapBackingMemory(VAddr address, std::size_t size, u8* memory, |
| @@ -62,6 +67,7 @@ private: | |||
| 62 | ARM_Unicorn inner_unicorn; | 67 | ARM_Unicorn inner_unicorn; |
| 63 | 68 | ||
| 64 | std::size_t core_index; | 69 | std::size_t core_index; |
| 70 | Timing::CoreTiming& core_timing; | ||
| 65 | DynarmicExclusiveMonitor& exclusive_monitor; | 71 | DynarmicExclusiveMonitor& exclusive_monitor; |
| 66 | 72 | ||
| 67 | Memory::PageTable* current_page_table = nullptr; | 73 | Memory::PageTable* current_page_table = nullptr; |
diff --git a/src/core/arm/unicorn/arm_unicorn.cpp b/src/core/arm/unicorn/arm_unicorn.cpp index c36c15c02..a542a098b 100644 --- a/src/core/arm/unicorn/arm_unicorn.cpp +++ b/src/core/arm/unicorn/arm_unicorn.cpp | |||
| @@ -72,7 +72,7 @@ static bool UnmappedMemoryHook(uc_engine* uc, uc_mem_type type, u64 addr, int si | |||
| 72 | return {}; | 72 | return {}; |
| 73 | } | 73 | } |
| 74 | 74 | ||
| 75 | ARM_Unicorn::ARM_Unicorn() { | 75 | ARM_Unicorn::ARM_Unicorn(Timing::CoreTiming& core_timing) : core_timing{core_timing} { |
| 76 | CHECKED(uc_open(UC_ARCH_ARM64, UC_MODE_ARM, &uc)); | 76 | CHECKED(uc_open(UC_ARCH_ARM64, UC_MODE_ARM, &uc)); |
| 77 | 77 | ||
| 78 | auto fpv = 3 << 20; | 78 | auto fpv = 3 << 20; |
| @@ -177,7 +177,7 @@ void ARM_Unicorn::Run() { | |||
| 177 | if (GDBStub::IsServerEnabled()) { | 177 | if (GDBStub::IsServerEnabled()) { |
| 178 | ExecuteInstructions(std::max(4000000, 0)); | 178 | ExecuteInstructions(std::max(4000000, 0)); |
| 179 | } else { | 179 | } else { |
| 180 | ExecuteInstructions(std::max(Timing::GetDowncount(), 0)); | 180 | ExecuteInstructions(std::max(core_timing.GetDowncount(), 0)); |
| 181 | } | 181 | } |
| 182 | } | 182 | } |
| 183 | 183 | ||
| @@ -190,7 +190,7 @@ MICROPROFILE_DEFINE(ARM_Jit_Unicorn, "ARM JIT", "Unicorn", MP_RGB(255, 64, 64)); | |||
| 190 | void ARM_Unicorn::ExecuteInstructions(int num_instructions) { | 190 | void ARM_Unicorn::ExecuteInstructions(int num_instructions) { |
| 191 | MICROPROFILE_SCOPE(ARM_Jit_Unicorn); | 191 | MICROPROFILE_SCOPE(ARM_Jit_Unicorn); |
| 192 | CHECKED(uc_emu_start(uc, GetPC(), 1ULL << 63, 0, num_instructions)); | 192 | CHECKED(uc_emu_start(uc, GetPC(), 1ULL << 63, 0, num_instructions)); |
| 193 | Timing::AddTicks(num_instructions); | 193 | core_timing.AddTicks(num_instructions); |
| 194 | if (GDBStub::IsServerEnabled()) { | 194 | if (GDBStub::IsServerEnabled()) { |
| 195 | if (last_bkpt_hit) { | 195 | if (last_bkpt_hit) { |
| 196 | uc_reg_write(uc, UC_ARM64_REG_PC, &last_bkpt.address); | 196 | uc_reg_write(uc, UC_ARM64_REG_PC, &last_bkpt.address); |
diff --git a/src/core/arm/unicorn/arm_unicorn.h b/src/core/arm/unicorn/arm_unicorn.h index 75761950b..dbd6955ea 100644 --- a/src/core/arm/unicorn/arm_unicorn.h +++ b/src/core/arm/unicorn/arm_unicorn.h | |||
| @@ -9,12 +9,17 @@ | |||
| 9 | #include "core/arm/arm_interface.h" | 9 | #include "core/arm/arm_interface.h" |
| 10 | #include "core/gdbstub/gdbstub.h" | 10 | #include "core/gdbstub/gdbstub.h" |
| 11 | 11 | ||
| 12 | namespace Core::Timing { | ||
| 13 | class CoreTiming; | ||
| 14 | } | ||
| 15 | |||
| 12 | namespace Core { | 16 | namespace Core { |
| 13 | 17 | ||
| 14 | class ARM_Unicorn final : public ARM_Interface { | 18 | class ARM_Unicorn final : public ARM_Interface { |
| 15 | public: | 19 | public: |
| 16 | ARM_Unicorn(); | 20 | explicit ARM_Unicorn(Timing::CoreTiming& core_timing); |
| 17 | ~ARM_Unicorn(); | 21 | ~ARM_Unicorn(); |
| 22 | |||
| 18 | void MapBackingMemory(VAddr address, std::size_t size, u8* memory, | 23 | void MapBackingMemory(VAddr address, std::size_t size, u8* memory, |
| 19 | Kernel::VMAPermission perms) override; | 24 | Kernel::VMAPermission perms) override; |
| 20 | void UnmapMemory(VAddr address, std::size_t size) override; | 25 | void UnmapMemory(VAddr address, std::size_t size) override; |
| @@ -43,6 +48,7 @@ public: | |||
| 43 | 48 | ||
| 44 | private: | 49 | private: |
| 45 | uc_engine* uc{}; | 50 | uc_engine* uc{}; |
| 51 | Timing::CoreTiming& core_timing; | ||
| 46 | GDBStub::BreakpointAddress last_bkpt{}; | 52 | GDBStub::BreakpointAddress last_bkpt{}; |
| 47 | bool last_bkpt_hit; | 53 | bool last_bkpt_hit; |
| 48 | }; | 54 | }; |