diff options
| author | 2020-11-03 19:54:53 -0500 | |
|---|---|---|
| committer | 2020-11-03 20:22:05 -0500 | |
| commit | fc6db97a09e2de5eff10131ddcab9cf8fb2f736c (patch) | |
| tree | 32a7b408286eb84360bcaff2961dbaa874f5a5d3 /src/core/arm/dynarmic | |
| parent | Merge pull request #4887 from lioncash/common-build (diff) | |
| download | yuzu-fc6db97a09e2de5eff10131ddcab9cf8fb2f736c.tar.gz yuzu-fc6db97a09e2de5eff10131ddcab9cf8fb2f736c.tar.xz yuzu-fc6db97a09e2de5eff10131ddcab9cf8fb2f736c.zip | |
core: Remove usage of unicorn
Unicorn long-since lost most of its use, due to dynarmic gaining support
for handling most instructions. At this point any further issues
encountered should be used to make dynarmic better.
This also allows us to remove our dependency on Python.
Diffstat (limited to 'src/core/arm/dynarmic')
| -rw-r--r-- | src/core/arm/dynarmic/arm_dynarmic_32.cpp | 1 | ||||
| -rw-r--r-- | src/core/arm/dynarmic/arm_dynarmic_64.cpp | 29 | ||||
| -rw-r--r-- | src/core/arm/dynarmic/arm_dynarmic_64.h | 2 |
3 files changed, 9 insertions, 23 deletions
diff --git a/src/core/arm/dynarmic/arm_dynarmic_32.cpp b/src/core/arm/dynarmic/arm_dynarmic_32.cpp index b5f28a86e..6dc03f3b1 100644 --- a/src/core/arm/dynarmic/arm_dynarmic_32.cpp +++ b/src/core/arm/dynarmic/arm_dynarmic_32.cpp | |||
| @@ -7,6 +7,7 @@ | |||
| 7 | #include <dynarmic/A32/a32.h> | 7 | #include <dynarmic/A32/a32.h> |
| 8 | #include <dynarmic/A32/config.h> | 8 | #include <dynarmic/A32/config.h> |
| 9 | #include <dynarmic/A32/context.h> | 9 | #include <dynarmic/A32/context.h> |
| 10 | #include "common/assert.h" | ||
| 10 | #include "common/logging/log.h" | 11 | #include "common/logging/log.h" |
| 11 | #include "common/page_table.h" | 12 | #include "common/page_table.h" |
| 12 | #include "core/arm/cpu_interrupt_handler.h" | 13 | #include "core/arm/cpu_interrupt_handler.h" |
diff --git a/src/core/arm/dynarmic/arm_dynarmic_64.cpp b/src/core/arm/dynarmic/arm_dynarmic_64.cpp index ce9968724..9f170a224 100644 --- a/src/core/arm/dynarmic/arm_dynarmic_64.cpp +++ b/src/core/arm/dynarmic/arm_dynarmic_64.cpp | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | #include <memory> | 6 | #include <memory> |
| 7 | #include <dynarmic/A64/a64.h> | 7 | #include <dynarmic/A64/a64.h> |
| 8 | #include <dynarmic/A64/config.h> | 8 | #include <dynarmic/A64/config.h> |
| 9 | #include "common/assert.h" | ||
| 9 | #include "common/logging/log.h" | 10 | #include "common/logging/log.h" |
| 10 | #include "common/page_table.h" | 11 | #include "common/page_table.h" |
| 11 | #include "core/arm/cpu_interrupt_handler.h" | 12 | #include "core/arm/cpu_interrupt_handler.h" |
| @@ -13,7 +14,6 @@ | |||
| 13 | #include "core/arm/dynarmic/arm_exclusive_monitor.h" | 14 | #include "core/arm/dynarmic/arm_exclusive_monitor.h" |
| 14 | #include "core/core.h" | 15 | #include "core/core.h" |
| 15 | #include "core/core_timing.h" | 16 | #include "core/core_timing.h" |
| 16 | #include "core/core_timing_util.h" | ||
| 17 | #include "core/gdbstub/gdbstub.h" | 17 | #include "core/gdbstub/gdbstub.h" |
| 18 | #include "core/hardware_properties.h" | 18 | #include "core/hardware_properties.h" |
| 19 | #include "core/hle/kernel/process.h" | 19 | #include "core/hle/kernel/process.h" |
| @@ -82,16 +82,9 @@ public: | |||
| 82 | } | 82 | } |
| 83 | 83 | ||
| 84 | void InterpreterFallback(u64 pc, std::size_t num_instructions) override { | 84 | void InterpreterFallback(u64 pc, std::size_t num_instructions) override { |
| 85 | LOG_INFO(Core_ARM, "Unicorn fallback @ 0x{:X} for {} instructions (instr = {:08X})", pc, | 85 | LOG_ERROR(Core_ARM, |
| 86 | num_instructions, MemoryReadCode(pc)); | 86 | "Unimplemented instruction @ 0x{:X} for {} instructions (instr = {:08X})", pc, |
| 87 | 87 | num_instructions, MemoryReadCode(pc)); | |
| 88 | ARM_Interface::ThreadContext64 ctx; | ||
| 89 | parent.SaveContext(ctx); | ||
| 90 | parent.inner_unicorn.LoadContext(ctx); | ||
| 91 | parent.inner_unicorn.ExecuteInstructions(num_instructions); | ||
| 92 | parent.inner_unicorn.SaveContext(ctx); | ||
| 93 | parent.LoadContext(ctx); | ||
| 94 | num_interpreted_instructions += num_instructions; | ||
| 95 | } | 88 | } |
| 96 | 89 | ||
| 97 | void ExceptionRaised(u64 pc, Dynarmic::A64::Exception exception) override { | 90 | void ExceptionRaised(u64 pc, Dynarmic::A64::Exception exception) override { |
| @@ -127,18 +120,17 @@ public: | |||
| 127 | if (parent.uses_wall_clock) { | 120 | if (parent.uses_wall_clock) { |
| 128 | return; | 121 | return; |
| 129 | } | 122 | } |
| 123 | |||
| 130 | // Divide the number of ticks by the amount of CPU cores. TODO(Subv): This yields only a | 124 | // Divide the number of ticks by the amount of CPU cores. TODO(Subv): This yields only a |
| 131 | // rough approximation of the amount of executed ticks in the system, it may be thrown off | 125 | // rough approximation of the amount of executed ticks in the system, it may be thrown off |
| 132 | // if not all cores are doing a similar amount of work. Instead of doing this, we should | 126 | // if not all cores are doing a similar amount of work. Instead of doing this, we should |
| 133 | // device a way so that timing is consistent across all cores without increasing the ticks 4 | 127 | // device a way so that timing is consistent across all cores without increasing the ticks 4 |
| 134 | // times. | 128 | // times. |
| 135 | u64 amortized_ticks = | 129 | u64 amortized_ticks = ticks / Core::Hardware::NUM_CPU_CORES; |
| 136 | (ticks - num_interpreted_instructions) / Core::Hardware::NUM_CPU_CORES; | ||
| 137 | // Always execute at least one tick. | 130 | // Always execute at least one tick. |
| 138 | amortized_ticks = std::max<u64>(amortized_ticks, 1); | 131 | amortized_ticks = std::max<u64>(amortized_ticks, 1); |
| 139 | 132 | ||
| 140 | parent.system.CoreTiming().AddTicks(amortized_ticks); | 133 | parent.system.CoreTiming().AddTicks(amortized_ticks); |
| 141 | num_interpreted_instructions = 0; | ||
| 142 | } | 134 | } |
| 143 | 135 | ||
| 144 | u64 GetTicksRemaining() override { | 136 | u64 GetTicksRemaining() override { |
| @@ -156,7 +148,6 @@ public: | |||
| 156 | } | 148 | } |
| 157 | 149 | ||
| 158 | ARM_Dynarmic_64& parent; | 150 | ARM_Dynarmic_64& parent; |
| 159 | std::size_t num_interpreted_instructions = 0; | ||
| 160 | u64 tpidrro_el0 = 0; | 151 | u64 tpidrro_el0 = 0; |
| 161 | u64 tpidr_el0 = 0; | 152 | u64 tpidr_el0 = 0; |
| 162 | static constexpr u64 minimum_run_cycles = 1000U; | 153 | static constexpr u64 minimum_run_cycles = 1000U; |
| @@ -248,12 +239,8 @@ ARM_Dynarmic_64::ARM_Dynarmic_64(System& system, CPUInterrupts& interrupt_handle | |||
| 248 | bool uses_wall_clock, ExclusiveMonitor& exclusive_monitor, | 239 | bool uses_wall_clock, ExclusiveMonitor& exclusive_monitor, |
| 249 | std::size_t core_index) | 240 | std::size_t core_index) |
| 250 | : ARM_Interface{system, interrupt_handlers, uses_wall_clock}, | 241 | : ARM_Interface{system, interrupt_handlers, uses_wall_clock}, |
| 251 | cb(std::make_unique<DynarmicCallbacks64>(*this)), inner_unicorn{system, interrupt_handlers, | 242 | cb(std::make_unique<DynarmicCallbacks64>(*this)), core_index{core_index}, |
| 252 | uses_wall_clock, | 243 | exclusive_monitor{dynamic_cast<DynarmicExclusiveMonitor&>(exclusive_monitor)} {} |
| 253 | ARM_Unicorn::Arch::AArch64, | ||
| 254 | core_index}, | ||
| 255 | core_index{core_index}, exclusive_monitor{ | ||
| 256 | dynamic_cast<DynarmicExclusiveMonitor&>(exclusive_monitor)} {} | ||
| 257 | 244 | ||
| 258 | ARM_Dynarmic_64::~ARM_Dynarmic_64() = default; | 245 | ARM_Dynarmic_64::~ARM_Dynarmic_64() = default; |
| 259 | 246 | ||
diff --git a/src/core/arm/dynarmic/arm_dynarmic_64.h b/src/core/arm/dynarmic/arm_dynarmic_64.h index 403c55961..28e11a17d 100644 --- a/src/core/arm/dynarmic/arm_dynarmic_64.h +++ b/src/core/arm/dynarmic/arm_dynarmic_64.h | |||
| @@ -12,7 +12,6 @@ | |||
| 12 | #include "common/hash.h" | 12 | #include "common/hash.h" |
| 13 | #include "core/arm/arm_interface.h" | 13 | #include "core/arm/arm_interface.h" |
| 14 | #include "core/arm/exclusive_monitor.h" | 14 | #include "core/arm/exclusive_monitor.h" |
| 15 | #include "core/arm/unicorn/arm_unicorn.h" | ||
| 16 | 15 | ||
| 17 | namespace Core::Memory { | 16 | namespace Core::Memory { |
| 18 | class Memory; | 17 | class Memory; |
| @@ -71,7 +70,6 @@ private: | |||
| 71 | std::unique_ptr<DynarmicCallbacks64> cb; | 70 | std::unique_ptr<DynarmicCallbacks64> cb; |
| 72 | JitCacheType jit_cache; | 71 | JitCacheType jit_cache; |
| 73 | std::shared_ptr<Dynarmic::A64::Jit> jit; | 72 | std::shared_ptr<Dynarmic::A64::Jit> jit; |
| 74 | ARM_Unicorn inner_unicorn; | ||
| 75 | 73 | ||
| 76 | std::size_t core_index; | 74 | std::size_t core_index; |
| 77 | DynarmicExclusiveMonitor& exclusive_monitor; | 75 | DynarmicExclusiveMonitor& exclusive_monitor; |