diff --git a/Core/MIPS/x86/X64IRCompALU.cpp b/Core/MIPS/x86/X64IRCompALU.cpp index 9132ce5b05..e1621b3049 100644 --- a/Core/MIPS/x86/X64IRCompALU.cpp +++ b/Core/MIPS/x86/X64IRCompALU.cpp @@ -64,7 +64,7 @@ void X64JitBackend::CompIR_Arith(IRInst inst) { case IROp::Sub: regs_.Map(inst); - if (inst.dest == inst.src2 && inst.dest == inst.src1) { + if (inst.src1 == inst.src2) { regs_.SetGPRImm(inst.dest, 0); } else if (inst.dest == inst.src2) { NEG(32, regs_.R(inst.src2)); diff --git a/Core/MIPS/x86/X64IRJit.cpp b/Core/MIPS/x86/X64IRJit.cpp index c7db4077d7..75b11b4ceb 100644 --- a/Core/MIPS/x86/X64IRJit.cpp +++ b/Core/MIPS/x86/X64IRJit.cpp @@ -29,9 +29,10 @@ namespace MIPSComp { using namespace Gen; using namespace X64IRJitConstants; -// This should be enough for exits and invalidations. -static constexpr int MIN_BLOCK_NORMAL_LEN = 16; -static constexpr int MIN_BLOCK_EXIT_LEN = 16; +// Invalidations just need a MOV and JMP. +static constexpr int MIN_BLOCK_NORMAL_LEN = 10; +// As long as we can fit a JMP, we should be fine. +static constexpr int MIN_BLOCK_EXIT_LEN = 5; X64JitBackend::X64JitBackend(JitOptions &jitopt, IRBlockCache &blocks) : IRNativeBackend(blocks), jo(jitopt), regs_(&jo) { @@ -109,7 +110,7 @@ bool X64JitBackend::CompileBlock(IRBlock *block, int block_num, bool preload) { int len = (int)GetOffset(GetCodePointer()) - block->GetTargetOffset(); if (len < MIN_BLOCK_NORMAL_LEN) { - // We need at least 16 bytes to invalidate blocks with, but larger doesn't need to align. + // We need at least 10 bytes to invalidate blocks with. ReserveCodeSpace(MIN_BLOCK_NORMAL_LEN - len); } @@ -198,6 +199,7 @@ void X64JitBackend::OverwriteExit(int srcOffset, int len, int block_num) { XEmitter emitter(writable); emitter.JMP(GetBasePtr() + nativeBlock->checkedOffset, true); int bytesWritten = (int)(emitter.GetWritableCodePtr() - writable); + _dbg_assert_(bytesWritten <= MIN_BLOCK_EXIT_LEN); if (bytesWritten < len) emitter.ReserveCodeSpace(len - bytesWritten);