From c553c42d63daad7aafbd2996da1f05ce2a911635 Mon Sep 17 00:00:00 2001 From: Pierre Bourdon Date: Sat, 19 Jan 2013 05:09:00 +0100 Subject: [PATCH] Implement backpatch support for 16 bit loads --- Source/Core/Core/Src/PowerPC/JitCommon/JitBackpatch.cpp | 7 +++++-- Source/Core/Core/Src/PowerPC/JitCommon/Jit_Util.cpp | 7 ++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Source/Core/Core/Src/PowerPC/JitCommon/JitBackpatch.cpp b/Source/Core/Core/Src/PowerPC/JitCommon/JitBackpatch.cpp index 9337f87b77..e2d9b50d42 100644 --- a/Source/Core/Core/Src/PowerPC/JitCommon/JitBackpatch.cpp +++ b/Source/Core/Core/Src/PowerPC/JitCommon/JitBackpatch.cpp @@ -90,6 +90,10 @@ const u8 *TrampolineCache::GetReadTrampoline(const InstructionInfo &info) case 4: CALL(thunks.ProtectFunction((void *)&Memory::Read_U32, 1)); break; + case 2: + CALL(thunks.ProtectFunction((void *)&Memory::Read_U16, 1)); + SHL(32, R(EAX), Imm8(16)); + break; } ABI_PopAllCallerSavedRegsAndAdjustStack(); if (dataReg != EAX) { @@ -176,7 +180,7 @@ const u8 *JitBase::BackPatch(u8 *codePtr, int accessType, u32 emAddress, void *c codePtr, emAddress); }*/ - if (info.operandSize != 4) { + if (info.operandSize == 1) { BackPatchError(StringFromFormat("BackPatch - no support for operand size %i", info.operandSize), codePtr, emAddress); } @@ -188,7 +192,6 @@ const u8 *JitBase::BackPatch(u8 *codePtr, int accessType, u32 emAddress, void *c PanicAlert("BackPatch : Currently only supporting reads." "\n\nAttempted to write to %08x.", emAddress); - // In the first iteration, we assume that all accesses are 32-bit. We also only deal with reads. if (accessType == 0) { XEmitter emitter(codePtr); diff --git a/Source/Core/Core/Src/PowerPC/JitCommon/Jit_Util.cpp b/Source/Core/Core/Src/PowerPC/JitCommon/Jit_Util.cpp index 4cfc3ab934..f43604fa9b 100644 --- a/Source/Core/Core/Src/PowerPC/JitCommon/Jit_Util.cpp +++ b/Source/Core/Core/Src/PowerPC/JitCommon/Jit_Util.cpp @@ -120,12 +120,13 @@ void EmuCodeBlock::SafeLoadToEAX(const Gen::OpArg & opAddress, int accessSize, s { #if defined(_M_X64) #ifdef ENABLE_MEM_CHECK - if (accessSize == 32 && !Core::g_CoreStartupParameter.bMMU && !Core::g_CoreStartupParameter.bEnableDebugging) + if (accessSize != 8 && !Core::g_CoreStartupParameter.bMMU && !Core::g_CoreStartupParameter.bEnableDebugging) #else - if (accessSize == 32 && !Core::g_CoreStartupParameter.bMMU) + if (accessSize != 8 && !Core::g_CoreStartupParameter.bMMU) #endif { - // BackPatch only supports 32-bits accesses + // We don't support 8 bit loads backpatching at the moment, but they + // are very rare. UnsafeLoadToEAX(opAddress, accessSize, offset, signExtend); } else