diff options
| author | 2020-02-26 15:53:47 -0400 | |
|---|---|---|
| committer | 2020-02-26 15:53:47 -0400 | |
| commit | f3d4d4eaa82d8a66f77c814c21f9d75d108de445 (patch) | |
| tree | dca3684caabc7bc100551a0897bf4d95a9584ce4 | |
| parent | Merge pull request #3425 from ReinUsesLisp/layered-framebuffer (diff) | |
| download | yuzu-f3d4d4eaa82d8a66f77c814c21f9d75d108de445.tar.gz yuzu-f3d4d4eaa82d8a66f77c814c21f9d75d108de445.tar.xz yuzu-f3d4d4eaa82d8a66f77c814c21f9d75d108de445.zip | |
ARM_Interface: Cache the JITs instead of deleting/recreating.
This was a bug inherited from citra which was fixed by then at some
time. This commit corrects such bug and ensures JITs are correctly
recycled.
Diffstat (limited to '')
| -rw-r--r-- | src/core/arm/dynarmic/arm_dynarmic.cpp | 11 | ||||
| -rw-r--r-- | src/core/arm/dynarmic/arm_dynarmic.h | 12 |
2 files changed, 19 insertions, 4 deletions
diff --git a/src/core/arm/dynarmic/arm_dynarmic.cpp b/src/core/arm/dynarmic/arm_dynarmic.cpp index 29eaf74e5..7c9d59ab8 100644 --- a/src/core/arm/dynarmic/arm_dynarmic.cpp +++ b/src/core/arm/dynarmic/arm_dynarmic.cpp | |||
| @@ -132,7 +132,7 @@ public: | |||
| 132 | u64 tpidr_el0 = 0; | 132 | u64 tpidr_el0 = 0; |
| 133 | }; | 133 | }; |
| 134 | 134 | ||
| 135 | std::unique_ptr<Dynarmic::A64::Jit> ARM_Dynarmic::MakeJit(Common::PageTable& page_table, | 135 | std::shared_ptr<Dynarmic::A64::Jit> ARM_Dynarmic::MakeJit(Common::PageTable& page_table, |
| 136 | std::size_t address_space_bits) const { | 136 | std::size_t address_space_bits) const { |
| 137 | Dynarmic::A64::UserConfig config; | 137 | Dynarmic::A64::UserConfig config; |
| 138 | 138 | ||
| @@ -159,7 +159,7 @@ std::unique_ptr<Dynarmic::A64::Jit> ARM_Dynarmic::MakeJit(Common::PageTable& pag | |||
| 159 | // Unpredictable instructions | 159 | // Unpredictable instructions |
| 160 | config.define_unpredictable_behaviour = true; | 160 | config.define_unpredictable_behaviour = true; |
| 161 | 161 | ||
| 162 | return std::make_unique<Dynarmic::A64::Jit>(config); | 162 | return std::make_shared<Dynarmic::A64::Jit>(config); |
| 163 | } | 163 | } |
| 164 | 164 | ||
| 165 | MICROPROFILE_DEFINE(ARM_Jit_Dynarmic, "ARM JIT", "Dynarmic", MP_RGB(255, 64, 64)); | 165 | MICROPROFILE_DEFINE(ARM_Jit_Dynarmic, "ARM JIT", "Dynarmic", MP_RGB(255, 64, 64)); |
| @@ -267,7 +267,14 @@ void ARM_Dynarmic::ClearExclusiveState() { | |||
| 267 | 267 | ||
| 268 | void ARM_Dynarmic::PageTableChanged(Common::PageTable& page_table, | 268 | void ARM_Dynarmic::PageTableChanged(Common::PageTable& page_table, |
| 269 | std::size_t new_address_space_size_in_bits) { | 269 | std::size_t new_address_space_size_in_bits) { |
| 270 | auto key = std::make_pair(&page_table, new_address_space_size_in_bits); | ||
| 271 | auto iter = jit_cache.find(key); | ||
| 272 | if (iter != jit_cache.end()) { | ||
| 273 | jit = iter->second; | ||
| 274 | return; | ||
| 275 | } | ||
| 270 | jit = MakeJit(page_table, new_address_space_size_in_bits); | 276 | jit = MakeJit(page_table, new_address_space_size_in_bits); |
| 277 | jit_cache.emplace(key, jit); | ||
| 271 | } | 278 | } |
| 272 | 279 | ||
| 273 | DynarmicExclusiveMonitor::DynarmicExclusiveMonitor(Memory::Memory& memory_, std::size_t core_count) | 280 | DynarmicExclusiveMonitor::DynarmicExclusiveMonitor(Memory::Memory& memory_, std::size_t core_count) |
diff --git a/src/core/arm/dynarmic/arm_dynarmic.h b/src/core/arm/dynarmic/arm_dynarmic.h index 9cd475cfb..ffbb69d76 100644 --- a/src/core/arm/dynarmic/arm_dynarmic.h +++ b/src/core/arm/dynarmic/arm_dynarmic.h | |||
| @@ -5,9 +5,12 @@ | |||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <memory> | 7 | #include <memory> |
| 8 | #include <unordered_map> | ||
| 9 | |||
| 8 | #include <dynarmic/A64/a64.h> | 10 | #include <dynarmic/A64/a64.h> |
| 9 | #include <dynarmic/A64/exclusive_monitor.h> | 11 | #include <dynarmic/A64/exclusive_monitor.h> |
| 10 | #include "common/common_types.h" | 12 | #include "common/common_types.h" |
| 13 | #include "common/hash.h" | ||
| 11 | #include "core/arm/arm_interface.h" | 14 | #include "core/arm/arm_interface.h" |
| 12 | #include "core/arm/exclusive_monitor.h" | 15 | #include "core/arm/exclusive_monitor.h" |
| 13 | #include "core/arm/unicorn/arm_unicorn.h" | 16 | #include "core/arm/unicorn/arm_unicorn.h" |
| @@ -22,6 +25,10 @@ class ARM_Dynarmic_Callbacks; | |||
| 22 | class DynarmicExclusiveMonitor; | 25 | class DynarmicExclusiveMonitor; |
| 23 | class System; | 26 | class System; |
| 24 | 27 | ||
| 28 | using JitCacheKey = std::pair<Common::PageTable*, std::size_t>; | ||
| 29 | using JitCacheType = | ||
| 30 | std::unordered_map<JitCacheKey, std::shared_ptr<Dynarmic::A64::Jit>, Common::PairHash>; | ||
| 31 | |||
| 25 | class ARM_Dynarmic final : public ARM_Interface { | 32 | class ARM_Dynarmic final : public ARM_Interface { |
| 26 | public: | 33 | public: |
| 27 | ARM_Dynarmic(System& system, ExclusiveMonitor& exclusive_monitor, std::size_t core_index); | 34 | ARM_Dynarmic(System& system, ExclusiveMonitor& exclusive_monitor, std::size_t core_index); |
| @@ -53,12 +60,13 @@ public: | |||
| 53 | std::size_t new_address_space_size_in_bits) override; | 60 | std::size_t new_address_space_size_in_bits) override; |
| 54 | 61 | ||
| 55 | private: | 62 | private: |
| 56 | std::unique_ptr<Dynarmic::A64::Jit> MakeJit(Common::PageTable& page_table, | 63 | std::shared_ptr<Dynarmic::A64::Jit> MakeJit(Common::PageTable& page_table, |
| 57 | std::size_t address_space_bits) const; | 64 | std::size_t address_space_bits) const; |
| 58 | 65 | ||
| 59 | friend class ARM_Dynarmic_Callbacks; | 66 | friend class ARM_Dynarmic_Callbacks; |
| 60 | std::unique_ptr<ARM_Dynarmic_Callbacks> cb; | 67 | std::unique_ptr<ARM_Dynarmic_Callbacks> cb; |
| 61 | std::unique_ptr<Dynarmic::A64::Jit> jit; | 68 | JitCacheType jit_cache; |
| 69 | std::shared_ptr<Dynarmic::A64::Jit> jit; | ||
| 62 | ARM_Unicorn inner_unicorn; | 70 | ARM_Unicorn inner_unicorn; |
| 63 | 71 | ||
| 64 | std::size_t core_index; | 72 | std::size_t core_index; |