Skip to content

Commit

Permalink
Fixed a bug with method inlineing, fixed #766
Browse files Browse the repository at this point in the history
  • Loading branch information
liiir1985 committed Dec 29, 2023
1 parent f5b1d95 commit af53891
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions ILRuntime/Runtime/Intepreter/RegisterVM/Optimizer.InlineMethod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ partial class Optimizer
public static void InlineMethod(CodeBasicBlock block, ILMethod method, RegisterVMSymbolLink symbolLink, ref Dictionary<int, int[]> jumpTables, short baseRegIdx, bool hasReturn)
{
var ins = block.FinalInstructions;
var body = method.BodyRegister;
var body = method.BodyRegister.ToArray();
OpCodeR start = new OpCodeR();
start.Code = OpCodeREnum.InlineStart;
ins.Add(start);
Expand Down Expand Up @@ -69,23 +69,30 @@ public static void InlineMethod(CodeBasicBlock block, ILMethod method, RegisterV
{
if (needMove)
{
for (int j = branchStart; j < ins.Count; j++)
for (int j = branchStart; j < body.Length + branchStart; j++)
{
var op2 = ins[j];
bool isPendingIns = j >= ins.Count;
var op2 = isPendingIns ? body[j - branchStart] : ins[j];
if (IsBranching(op2.Code))
{
if (op2.Operand > i)
{
op2.Operand++;
ins[j] = op2;
if (!isPendingIns)
ins[j] = op2;
else
body[j - branchStart] = op2;
}
}
else if (IsIntermediateBranching(op2.Code))
{
if (op2.Operand4 > i)
{
op2.Operand4++;
ins[j] = op2;
if (!isPendingIns)
ins[j] = op2;
else
body[j - branchStart] = op2;
}
}
else if(op2.Code == OpCodeREnum.Switch)
Expand Down

0 comments on commit af53891

Please sign in to comment.