x86jit: Reduce block link padding.

Reduces bloat a good bit.
This commit is contained in:
Unknown W. Brackets committed 2023-09-01 22:33:02 -07:00
1 parent f698623645
commit b370a89ef2
2 files changed
+7 -5

No files matched your search

+1 -1
View File
@@ -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));
+6 -4
View File
@@ -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);