diff options
Diffstat (limited to 'src/ARMJIT_x64')
-rw-r--r-- | src/ARMJIT_x64/ARMJIT_Compiler.cpp | 12 | ||||
-rw-r--r-- | src/ARMJIT_x64/ARMJIT_Compiler.h | 4 | ||||
-rw-r--r-- | src/ARMJIT_x64/ARMJIT_LoadStore.cpp | 23 |
3 files changed, 18 insertions, 21 deletions
diff --git a/src/ARMJIT_x64/ARMJIT_Compiler.cpp b/src/ARMJIT_x64/ARMJIT_Compiler.cpp index 9785ffc..076f48c 100644 --- a/src/ARMJIT_x64/ARMJIT_Compiler.cpp +++ b/src/ARMJIT_x64/ARMJIT_Compiler.cpp @@ -345,7 +345,7 @@ Compiler::Compiler() ABI_PushRegistersAndAdjustStack(CallerSavedPushRegs, 8); if (consoleType == 0) { - switch ((8 << size) | num) + switch ((8 << size) | num) { case 32: ABI_CallFunction(SlowWrite9<u32, 0>); break; case 33: ABI_CallFunction(SlowWrite7<u32, 0>); break; @@ -357,7 +357,7 @@ Compiler::Compiler() } else { - switch ((8 << size) | num) + switch ((8 << size) | num) { case 32: ABI_CallFunction(SlowWrite9<u32, 1>); break; case 33: ABI_CallFunction(SlowWrite7<u32, 1>); break; @@ -380,7 +380,7 @@ Compiler::Compiler() ABI_PushRegistersAndAdjustStack(CallerSavedPushRegs, 8); if (consoleType == 0) { - switch ((8 << size) | num) + switch ((8 << size) | num) { case 32: ABI_CallFunction(SlowRead9<u32, 0>); break; case 33: ABI_CallFunction(SlowRead7<u32, 0>); break; @@ -392,7 +392,7 @@ Compiler::Compiler() } else { - switch ((8 << size) | num) + switch ((8 << size) | num) { case 32: ABI_CallFunction(SlowRead9<u32, 1>); break; case 33: ABI_CallFunction(SlowRead7<u32, 1>); break; @@ -617,9 +617,9 @@ void Compiler::Reset() LoadStorePatches.clear(); } -bool Compiler::IsJITFault(u64 addr) +bool Compiler::IsJITFault(u8* addr) { - return addr >= (u64)CodeMemory && addr < (u64)CodeMemory + sizeof(CodeMemory); + return (u64)addr >= (u64)ResetStart && (u64)addr < (u64)ResetStart + CodeMemSize; } void Compiler::Comp_SpecialBranchBehaviour(bool taken) diff --git a/src/ARMJIT_x64/ARMJIT_Compiler.h b/src/ARMJIT_x64/ARMJIT_Compiler.h index 3e900c3..57aab7b 100644 --- a/src/ARMJIT_x64/ARMJIT_Compiler.h +++ b/src/ARMJIT_x64/ARMJIT_Compiler.h @@ -208,9 +208,9 @@ public: SetCodePtr(FarCode); } - bool IsJITFault(u64 addr); + bool IsJITFault(u8* addr); - s32 RewriteMemAccess(u64 pc); + u8* RewriteMemAccess(u8* pc); u8* FarCode; u8* NearCode; diff --git a/src/ARMJIT_x64/ARMJIT_LoadStore.cpp b/src/ARMJIT_x64/ARMJIT_LoadStore.cpp index 8b4e8fe..d80b25b 100644 --- a/src/ARMJIT_x64/ARMJIT_LoadStore.cpp +++ b/src/ARMJIT_x64/ARMJIT_LoadStore.cpp @@ -15,28 +15,24 @@ int squeezePointer(T* ptr) return truncated; } -s32 Compiler::RewriteMemAccess(u64 pc) +u8* Compiler::RewriteMemAccess(u8* pc) { - auto it = LoadStorePatches.find((u8*)pc); + auto it = LoadStorePatches.find(pc); if (it != LoadStorePatches.end()) { LoadStorePatch patch = it->second; LoadStorePatches.erase(it); - u8* curCodePtr = GetWritableCodePtr(); - u8* rewritePtr = (u8*)pc + (ptrdiff_t)patch.Offset; - SetCodePtr(rewritePtr); + //printf("rewriting memory access %p %d %d\n", (u8*)pc-ResetStart, patch.Offset, patch.Size); - CALL(patch.PatchFunc); - u32 remainingSize = patch.Size - (GetWritableCodePtr() - rewritePtr); + XEmitter emitter(pc + (ptrdiff_t)patch.Offset); + emitter.CALL(patch.PatchFunc); + ptrdiff_t remainingSize = (ptrdiff_t)patch.Size - 5; + assert(remainingSize >= 0); if (remainingSize > 0) - NOP(remainingSize); + emitter.NOP(remainingSize); - //printf("rewriting memory access %p %d %d\n", patch.PatchFunc, patch.Offset, patch.Size); - - SetCodePtr(curCodePtr); - - return patch.Offset; + return pc + (ptrdiff_t)patch.Offset; } printf("this is a JIT bug %llx\n", pc); @@ -192,6 +188,7 @@ void Compiler::Comp_MemAccess(int rd, int rn, const Op2& op2, int size, int flag u8* memopStart = GetWritableCodePtr(); LoadStorePatch patch; + assert(rdMapped.GetSimpleReg() >= 0 && rdMapped.GetSimpleReg() < 16); patch.PatchFunc = flags & memop_Store ? PatchedStoreFuncs[NDS::ConsoleType][Num][__builtin_ctz(size) - 3][rdMapped.GetSimpleReg()] : PatchedLoadFuncs[NDS::ConsoleType][Num][__builtin_ctz(size) - 3][!!(flags & memop_SignExtend)][rdMapped.GetSimpleReg()]; |