Implement 8 bit loads backpatching

This commit is contained in:
Pierre Bourdon 2013-01-19 16:52:13 +01:00
parent c553c42d63
commit 905d38827e
2 changed files with 10 additions and 9 deletions

View File

@ -94,6 +94,9 @@ const u8 *TrampolineCache::GetReadTrampoline(const InstructionInfo &info)
CALL(thunks.ProtectFunction((void *)&Memory::Read_U16, 1)); CALL(thunks.ProtectFunction((void *)&Memory::Read_U16, 1));
SHL(32, R(EAX), Imm8(16)); SHL(32, R(EAX), Imm8(16));
break; break;
case 1:
CALL(thunks.ProtectFunction((void *)&Memory::Read_U8, 1));
break;
} }
ABI_PopAllCallerSavedRegsAndAdjustStack(); ABI_PopAllCallerSavedRegsAndAdjustStack();
if (dataReg != EAX) { if (dataReg != EAX) {
@ -180,10 +183,6 @@ const u8 *JitBase::BackPatch(u8 *codePtr, int accessType, u32 emAddress, void *c
codePtr, emAddress); codePtr, emAddress);
}*/ }*/
if (info.operandSize == 1) {
BackPatchError(StringFromFormat("BackPatch - no support for operand size %i", info.operandSize), codePtr, emAddress);
}
if (info.otherReg != RBX) if (info.otherReg != RBX)
PanicAlert("BackPatch : Base reg not RBX." PanicAlert("BackPatch : Base reg not RBX."
"\n\nAttempted to access %08x.", emAddress); "\n\nAttempted to access %08x.", emAddress);

View File

@ -97,6 +97,10 @@ void EmuCodeBlock::UnsafeLoadToEAX(const Gen::OpArg & opAddress, int accessSize,
} }
#endif #endif
// Add a 2 bytes NOP to have some space for the backpatching
if (accessSize == 8)
NOP(2);
if (accessSize == 32) if (accessSize == 32)
{ {
BSWAP(32, EAX); BSWAP(32, EAX);
@ -120,13 +124,11 @@ void EmuCodeBlock::SafeLoadToEAX(const Gen::OpArg & opAddress, int accessSize, s
{ {
#if defined(_M_X64) #if defined(_M_X64)
#ifdef ENABLE_MEM_CHECK #ifdef ENABLE_MEM_CHECK
if (accessSize != 8 && !Core::g_CoreStartupParameter.bMMU && !Core::g_CoreStartupParameter.bEnableDebugging) if (!Core::g_CoreStartupParameter.bMMU && !Core::g_CoreStartupParameter.bEnableDebugging)
#else #else
if (accessSize != 8 && !Core::g_CoreStartupParameter.bMMU) if (!Core::g_CoreStartupParameter.bMMU)
#endif #endif
{ {
// We don't support 8 bit loads backpatching at the moment, but they
// are very rare.
UnsafeLoadToEAX(opAddress, accessSize, offset, signExtend); UnsafeLoadToEAX(opAddress, accessSize, offset, signExtend);
} }
else else