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