VERY experimental Nintendo Switch 2 emulator
C++
[dynarmic] fix sign extension and optimize vaddr lookups for 64bit on x64 systems (#4446)
Exverge4fe5f62c38e7
diff --git a/src/dynarmic/src/dynarmic/backend/x64/emit_x64_memory.h b/src/dynarmic/src/dynarmic/backend/x64/emit_x64_memory.hindex 5d98d47564..b78c14f6b7 100644--- a/src/dynarmic/src/dynarmic/backend/x64/emit_x64_memory.h+++ b/src/dynarmic/src/dynarmic/backend/x64/emit_x64_memory.h@@ -161,8 +161,12 @@ template<>code.jnz(abort, code.T_NEAR);}- code.shl(tmp, int(ctx.conf.page_table_log2_stride));- code.mov(page, qword[r14 + tmp]);+ if (ctx.conf.page_table_log2_stride > 3) {+ code.shl(tmp, int(ctx.conf.page_table_log2_stride));+ code.mov(page, qword[r14 + tmp.cvt64()]);+ } else {+ code.mov(page, qword[r14 + tmp.cvt64() * int(1 << ctx.conf.page_table_log2_stride)]);+ }// check for marked bit, use as unmapped if markedif (ctx.conf.page_table_marked_bit) {@@ -178,9 +182,10 @@ template<>code.mov(tmp, ctx.conf.page_table_pointer_mask);code.and_(page, tmp);}+ // check for sign bit, apply sign extension as neededif (ctx.conf.page_table_sign_extension) {- code.shl(page, *ctx.conf.page_table_sign_extension);- code.sar(page, *ctx.conf.page_table_sign_extension);+ code.shl(page, 63 - int(*ctx.conf.page_table_sign_extension));+ code.sar(page, 63 - int(*ctx.conf.page_table_sign_extension));}code.jz(abort, code.T_NEAR);