diff options
author | MerryMage <MerryMage@users.noreply.github.com> | 2017-09-24 23:44:13 +0200 |
---|---|---|
committer | MerryMage <MerryMage@users.noreply.github.com> | 2017-09-25 00:08:25 +0200 |
commit | 67a70bd9e1655dfd705550c1d561f3ba444360c8 (patch) | |
tree | 18f0720a18d9d878a7699c755bf167af8564b776 /src/core/arm/dynarmic/arm_dynarmic.cpp | |
parent | memory: Remove GetCurrentPageTablePointers (diff) | |
download | yuzu-67a70bd9e1655dfd705550c1d561f3ba444360c8.tar yuzu-67a70bd9e1655dfd705550c1d561f3ba444360c8.tar.gz yuzu-67a70bd9e1655dfd705550c1d561f3ba444360c8.tar.bz2 yuzu-67a70bd9e1655dfd705550c1d561f3ba444360c8.tar.lz yuzu-67a70bd9e1655dfd705550c1d561f3ba444360c8.tar.xz yuzu-67a70bd9e1655dfd705550c1d561f3ba444360c8.tar.zst yuzu-67a70bd9e1655dfd705550c1d561f3ba444360c8.zip |
Diffstat (limited to 'src/core/arm/dynarmic/arm_dynarmic.cpp')
-rw-r--r-- | src/core/arm/dynarmic/arm_dynarmic.cpp | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/core/arm/dynarmic/arm_dynarmic.cpp b/src/core/arm/dynarmic/arm_dynarmic.cpp index 34c5aa381..42ae93ae8 100644 --- a/src/core/arm/dynarmic/arm_dynarmic.cpp +++ b/src/core/arm/dynarmic/arm_dynarmic.cpp @@ -41,7 +41,7 @@ static bool IsReadOnlyMemory(u32 vaddr) { } static Dynarmic::UserCallbacks GetUserCallbacks( - const std::shared_ptr<ARMul_State>& interpeter_state) { + const std::shared_ptr<ARMul_State>& interpeter_state, Memory::PageTable* current_page_table) { Dynarmic::UserCallbacks user_callbacks{}; user_callbacks.InterpreterFallback = &InterpreterFallback; user_callbacks.user_arg = static_cast<void*>(interpeter_state.get()); @@ -56,16 +56,14 @@ static Dynarmic::UserCallbacks GetUserCallbacks( user_callbacks.memory.Write16 = &Memory::Write16; user_callbacks.memory.Write32 = &Memory::Write32; user_callbacks.memory.Write64 = &Memory::Write64; - // TODO(Subv): Re-add the page table pointers once dynarmic supports switching page tables at - // runtime. - user_callbacks.page_table = nullptr; + user_callbacks.page_table = ¤t_page_table->pointers; user_callbacks.coprocessors[15] = std::make_shared<DynarmicCP15>(interpeter_state); return user_callbacks; } ARM_Dynarmic::ARM_Dynarmic(PrivilegeMode initial_mode) { interpreter_state = std::make_shared<ARMul_State>(initial_mode); - jit = std::make_unique<Dynarmic::Jit>(GetUserCallbacks(interpreter_state)); + PageTableChanged(); } void ARM_Dynarmic::SetPC(u32 pc) { @@ -136,6 +134,7 @@ void ARM_Dynarmic::AddTicks(u64 ticks) { MICROPROFILE_DEFINE(ARM_Jit, "ARM JIT", "ARM JIT", MP_RGB(255, 64, 64)); void ARM_Dynarmic::ExecuteInstructions(int num_instructions) { + ASSERT(Memory::GetCurrentPageTable() == current_page_table); MICROPROFILE_SCOPE(ARM_Jit); std::size_t ticks_executed = jit->Run(static_cast<unsigned>(num_instructions)); @@ -178,3 +177,16 @@ void ARM_Dynarmic::PrepareReschedule() { void ARM_Dynarmic::ClearInstructionCache() { jit->ClearCache(); } + +void ARM_Dynarmic::PageTableChanged() { + current_page_table = Memory::GetCurrentPageTable(); + + auto iter = jits.find(current_page_table); + if (iter != jits.end()) { + jit = iter->second.get(); + return; + } + + jit = new Dynarmic::Jit(GetUserCallbacks(interpreter_state, current_page_table)); + jits.emplace(current_page_table, std::unique_ptr<Dynarmic::Jit>(jit)); +} |