Skip to content

Commit

Permalink
Implement backpatch support for 16 bit loads
Browse files Browse the repository at this point in the history
  • Loading branch information
delroth committed Jan 19, 2013
1 parent 621204f commit c553c42
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
7 changes: 5 additions & 2 deletions Source/Core/Core/Src/PowerPC/JitCommon/JitBackpatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
}

Expand All @@ -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);
Expand Down
7 changes: 4 additions & 3 deletions Source/Core/Core/Src/PowerPC/JitCommon/Jit_Util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c553c42

Please sign in to comment.