mirror of
https://git.eden-emu.dev/eden-emu/eden
synced 2026-05-15 08:27:00 +02:00
[dynarmic] add current code page cache (#3459)
should make JIT translation a bit faster - especially for non-fastmem test if thumb still werks previously: we read 32-bits one by one, and do translation **for each u32 we read** now: one big read of 4096 bytes (aligned of course), only 1 VAddr translation Signed-off-by: lizzie <lizzie@eden-emu.dev> Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3459 Reviewed-by: DraVee <dravee@eden-emu.dev> Reviewed-by: CamilleLaVey <camillelavey99@gmail.com> Co-authored-by: lizzie <lizzie@eden-emu.dev> Co-committed-by: lizzie <lizzie@eden-emu.dev>
This commit is contained in:
parent
e46576b4c3
commit
c263b6af6f
7 changed files with 59 additions and 11 deletions
|
|
@ -1,4 +1,4 @@
|
|||
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
||||
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
|
||||
|
|
@ -10,6 +10,7 @@
|
|||
#include <boost/icl/interval_set.hpp>
|
||||
#include <dynarmic/interface/A64/a64.h>
|
||||
#include <dynarmic/interface/A64/config.h>
|
||||
#include <dynarmic/interface/code_page.h>
|
||||
|
||||
#include "common/alignment.h"
|
||||
#include "common/common_funcs.h"
|
||||
|
|
@ -46,6 +47,15 @@ public:
|
|||
: memory{memory_}, local_memory{local_memory_},
|
||||
mapped_ranges{mapped_ranges_}, parent{parent_} {}
|
||||
|
||||
std::optional<std::uint32_t> MemoryReadCode(VAddr vaddr) override {
|
||||
static_assert(Core::Memory::YUZU_PAGESIZE == Dynarmic::CODE_PAGE_SIZE);
|
||||
auto const aligned_vaddr = vaddr & ~Core::Memory::YUZU_PAGEMASK;
|
||||
if (last_code_addr != aligned_vaddr) {
|
||||
cached_code_page = ReadMemory<Dynarmic::CodePage>(aligned_vaddr);
|
||||
last_code_addr = aligned_vaddr;
|
||||
}
|
||||
return cached_code_page.inst[(vaddr & Core::Memory::YUZU_PAGEMASK) / sizeof(u32)];
|
||||
}
|
||||
u8 MemoryRead8(u64 vaddr) override {
|
||||
return ReadMemory<u8>(vaddr);
|
||||
}
|
||||
|
|
@ -116,8 +126,7 @@ public:
|
|||
return 0;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
T ReadMemory(u64 vaddr) {
|
||||
template<typename T> T ReadMemory(u64 vaddr) {
|
||||
T ret{};
|
||||
if (boost::icl::contains(mapped_ranges, vaddr)) {
|
||||
memory.ReadBlock(vaddr, &ret, sizeof(T));
|
||||
|
|
@ -146,6 +155,9 @@ private:
|
|||
std::vector<u8>& local_memory;
|
||||
IntervalSet& mapped_ranges;
|
||||
JITContextImpl& parent;
|
||||
|
||||
Dynarmic::CodePage cached_code_page;
|
||||
u64 last_code_addr = 0;
|
||||
};
|
||||
|
||||
class JITContextImpl {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue