mirror of
https://gitlab.com/suyu-emu/suyu.git
synced 2024-03-15 23:15:44 +00:00
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.
This commit is contained in:
parent
e22ad52cdb
commit
f3d4d4eaa8
|
@ -132,7 +132,7 @@ public:
|
||||||
u64 tpidr_el0 = 0;
|
u64 tpidr_el0 = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::unique_ptr<Dynarmic::A64::Jit> ARM_Dynarmic::MakeJit(Common::PageTable& page_table,
|
std::shared_ptr<Dynarmic::A64::Jit> ARM_Dynarmic::MakeJit(Common::PageTable& page_table,
|
||||||
std::size_t address_space_bits) const {
|
std::size_t address_space_bits) const {
|
||||||
Dynarmic::A64::UserConfig config;
|
Dynarmic::A64::UserConfig config;
|
||||||
|
|
||||||
|
@ -159,7 +159,7 @@ std::unique_ptr<Dynarmic::A64::Jit> ARM_Dynarmic::MakeJit(Common::PageTable& pag
|
||||||
// Unpredictable instructions
|
// Unpredictable instructions
|
||||||
config.define_unpredictable_behaviour = true;
|
config.define_unpredictable_behaviour = true;
|
||||||
|
|
||||||
return std::make_unique<Dynarmic::A64::Jit>(config);
|
return std::make_shared<Dynarmic::A64::Jit>(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
MICROPROFILE_DEFINE(ARM_Jit_Dynarmic, "ARM JIT", "Dynarmic", MP_RGB(255, 64, 64));
|
MICROPROFILE_DEFINE(ARM_Jit_Dynarmic, "ARM JIT", "Dynarmic", MP_RGB(255, 64, 64));
|
||||||
|
@ -267,7 +267,14 @@ void ARM_Dynarmic::ClearExclusiveState() {
|
||||||
|
|
||||||
void ARM_Dynarmic::PageTableChanged(Common::PageTable& page_table,
|
void ARM_Dynarmic::PageTableChanged(Common::PageTable& page_table,
|
||||||
std::size_t new_address_space_size_in_bits) {
|
std::size_t new_address_space_size_in_bits) {
|
||||||
|
auto key = std::make_pair(&page_table, new_address_space_size_in_bits);
|
||||||
|
auto iter = jit_cache.find(key);
|
||||||
|
if (iter != jit_cache.end()) {
|
||||||
|
jit = iter->second;
|
||||||
|
return;
|
||||||
|
}
|
||||||
jit = MakeJit(page_table, new_address_space_size_in_bits);
|
jit = MakeJit(page_table, new_address_space_size_in_bits);
|
||||||
|
jit_cache.emplace(key, jit);
|
||||||
}
|
}
|
||||||
|
|
||||||
DynarmicExclusiveMonitor::DynarmicExclusiveMonitor(Memory::Memory& memory_, std::size_t core_count)
|
DynarmicExclusiveMonitor::DynarmicExclusiveMonitor(Memory::Memory& memory_, std::size_t core_count)
|
||||||
|
|
|
@ -5,9 +5,12 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
#include <dynarmic/A64/a64.h>
|
#include <dynarmic/A64/a64.h>
|
||||||
#include <dynarmic/A64/exclusive_monitor.h>
|
#include <dynarmic/A64/exclusive_monitor.h>
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
|
#include "common/hash.h"
|
||||||
#include "core/arm/arm_interface.h"
|
#include "core/arm/arm_interface.h"
|
||||||
#include "core/arm/exclusive_monitor.h"
|
#include "core/arm/exclusive_monitor.h"
|
||||||
#include "core/arm/unicorn/arm_unicorn.h"
|
#include "core/arm/unicorn/arm_unicorn.h"
|
||||||
|
@ -22,6 +25,10 @@ class ARM_Dynarmic_Callbacks;
|
||||||
class DynarmicExclusiveMonitor;
|
class DynarmicExclusiveMonitor;
|
||||||
class System;
|
class System;
|
||||||
|
|
||||||
|
using JitCacheKey = std::pair<Common::PageTable*, std::size_t>;
|
||||||
|
using JitCacheType =
|
||||||
|
std::unordered_map<JitCacheKey, std::shared_ptr<Dynarmic::A64::Jit>, Common::PairHash>;
|
||||||
|
|
||||||
class ARM_Dynarmic final : public ARM_Interface {
|
class ARM_Dynarmic final : public ARM_Interface {
|
||||||
public:
|
public:
|
||||||
ARM_Dynarmic(System& system, ExclusiveMonitor& exclusive_monitor, std::size_t core_index);
|
ARM_Dynarmic(System& system, ExclusiveMonitor& exclusive_monitor, std::size_t core_index);
|
||||||
|
@ -53,12 +60,13 @@ public:
|
||||||
std::size_t new_address_space_size_in_bits) override;
|
std::size_t new_address_space_size_in_bits) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<Dynarmic::A64::Jit> MakeJit(Common::PageTable& page_table,
|
std::shared_ptr<Dynarmic::A64::Jit> MakeJit(Common::PageTable& page_table,
|
||||||
std::size_t address_space_bits) const;
|
std::size_t address_space_bits) const;
|
||||||
|
|
||||||
friend class ARM_Dynarmic_Callbacks;
|
friend class ARM_Dynarmic_Callbacks;
|
||||||
std::unique_ptr<ARM_Dynarmic_Callbacks> cb;
|
std::unique_ptr<ARM_Dynarmic_Callbacks> cb;
|
||||||
std::unique_ptr<Dynarmic::A64::Jit> jit;
|
JitCacheType jit_cache;
|
||||||
|
std::shared_ptr<Dynarmic::A64::Jit> jit;
|
||||||
ARM_Unicorn inner_unicorn;
|
ARM_Unicorn inner_unicorn;
|
||||||
|
|
||||||
std::size_t core_index;
|
std::size_t core_index;
|
||||||
|
|
Loading…
Reference in a new issue