[Loader] Patch red-zone sites from the previous instruction when every indirect branch is resolved

This commit is contained in:
ParantezTech 2026-10-09 01:27:52 +03:00
parent 28b2f5709d
commit ee9660d81d
1 changed files with 8 additions and 2 deletions

View File

@ -310,7 +310,10 @@ internal static class GuestRedZonePatcher
canBorrowFollowingInstructions,
out span,
out refusal);
if (!forward)
var backward = !forward &&
canBorrowFollowingInstructions &&
TryBuildEnclosingPatchSpan(decoded, instructionIndex, branchTargets, out span);
if (!forward && !backward)
{
unrelocatableSites++;
refusalCounts[(int)refusal]++;
@ -335,10 +338,13 @@ internal static class GuestRedZonePatcher
shaInstructionCount += span.Instructions.Count(static instruction => ShaInstructionRewrite.CanRewrite(instruction));
}
if (!backward)
{
instructionIndex += span.Instructions.Count - 1;
}
}
}
}
result = new PatchResult
{