Optimization: Read page-table directly for memory access

This commit is contained in:
MerryMage 2016-09-01 00:06:40 +01:00
parent 57169ec093
commit 3b5c43b427
5 changed files with 219 additions and 27 deletions

View file

@ -12,11 +12,12 @@
#include "backend_x64/block_of_code.h"
#include "backend_x64/jitstate.h"
#include "common/assert.h"
#include "dynarmic/callbacks.h"
namespace Dynarmic {
namespace BackendX64 {
BlockOfCode::BlockOfCode() : Xbyak::CodeGenerator(128 * 1024 * 1024) {
BlockOfCode::BlockOfCode(UserCallbacks cb) : Xbyak::CodeGenerator(128 * 1024 * 1024), cb(cb) {
ClearCache(false);
}
@ -27,6 +28,7 @@ void BlockOfCode::ClearCache(bool poison_memory) {
GenConstants();
GenRunCode();
GenReturnFromRunCode();
GenMemoryAccessors();
}
size_t BlockOfCode::RunCode(JitState* jit_state, CodePtr basic_block, size_t cycles_to_run) const {
@ -118,6 +120,64 @@ void BlockOfCode::GenReturnFromRunCode() {
ret();
}
void BlockOfCode::GenMemoryAccessors() {
align();
read_memory_8 = getCurr<const void*>();
ABI_PushCallerSaveRegistersAndAdjustStack(this);
CallFunction(cb.MemoryRead8);
ABI_PopCallerSaveRegistersAndAdjustStack(this);
ret();
align();
read_memory_16 = getCurr<const void*>();
ABI_PushCallerSaveRegistersAndAdjustStack(this);
CallFunction(cb.MemoryRead16);
ABI_PopCallerSaveRegistersAndAdjustStack(this);
ret();
align();
read_memory_32 = getCurr<const void*>();
ABI_PushCallerSaveRegistersAndAdjustStack(this);
CallFunction(cb.MemoryRead32);
ABI_PopCallerSaveRegistersAndAdjustStack(this);
ret();
align();
read_memory_64 = getCurr<const void*>();
ABI_PushCallerSaveRegistersAndAdjustStack(this);
CallFunction(cb.MemoryRead64);
ABI_PopCallerSaveRegistersAndAdjustStack(this);
ret();
align();
write_memory_8 = getCurr<const void*>();
ABI_PushCallerSaveRegistersAndAdjustStack(this);
CallFunction(cb.MemoryWrite8);
ABI_PopCallerSaveRegistersAndAdjustStack(this);
ret();
align();
write_memory_16 = getCurr<const void*>();
ABI_PushCallerSaveRegistersAndAdjustStack(this);
CallFunction(cb.MemoryWrite16);
ABI_PopCallerSaveRegistersAndAdjustStack(this);
ret();
align();
write_memory_32 = getCurr<const void*>();
ABI_PushCallerSaveRegistersAndAdjustStack(this);
CallFunction(cb.MemoryWrite32);
ABI_PopCallerSaveRegistersAndAdjustStack(this);
ret();
align();
write_memory_64 = getCurr<const void*>();
ABI_PushCallerSaveRegistersAndAdjustStack(this);
CallFunction(cb.MemoryWrite64);
ABI_PopCallerSaveRegistersAndAdjustStack(this);
ret();
}
void BlockOfCode::SwitchMxcsrOnEntry() {
stmxcsr(dword[r15 + offsetof(JitState, save_host_MXCSR)]);
ldmxcsr(dword[r15 + offsetof(JitState, guest_MXCSR)]);