Browse Source

CachedDelegateInitialization: use less aggressive inlining

pull/124/head
Daniel Grunwald 14 years ago
parent
commit
15f5c7a0b4
  1. 16
      ICSharpCode.Decompiler/ILAst/PeepholeTransform.cs

16
ICSharpCode.Decompiler/ILAst/PeepholeTransform.cs

@ -174,7 +174,7 @@ namespace ICSharpCode.Decompiler.ILAst
if (parent.Arguments[j].Code == ILCode.Ldsfld && ((FieldReference)parent.Arguments[j].Operand).ResolveWithinSameModule() == field) { if (parent.Arguments[j].Code == ILCode.Ldsfld && ((FieldReference)parent.Arguments[j].Operand).ResolveWithinSameModule() == field) {
parent.Arguments[j] = newObj; parent.Arguments[j] = newObj;
block.Body.RemoveAt(i); block.Body.RemoveAt(i);
i -= new ILInlining(method).InlineInto(block.Body, i, aggressive: true); i -= new ILInlining(method).InlineInto(block.Body, i, aggressive: false);
return; return;
} }
} }
@ -229,6 +229,7 @@ namespace ICSharpCode.Decompiler.ILAst
ILVariable storedVar; ILVariable storedVar;
ILExpression storedExpr; ILExpression storedExpr;
if (storeBlock.Body[j].Match(ILCode.Stloc, out storedVar, out storedExpr) && storedVar == v && storedExpr.Match(ILCode.Ldnull)) { if (storeBlock.Body[j].Match(ILCode.Stloc, out storedVar, out storedExpr) && storedVar == v && storedExpr.Match(ILCode.Ldnull)) {
// Remove the instruction
storeBlock.Body.RemoveAt(j); storeBlock.Body.RemoveAt(j);
if (storeBlock == block && j < i) if (storeBlock == block && j < i)
i--; i--;
@ -237,16 +238,9 @@ namespace ICSharpCode.Decompiler.ILAst
} }
} }
foreach (ILExpression parent in followingNode.GetSelfAndChildrenRecursive<ILExpression>()) { block.Body[i] = stloc; // remove the 'if (v==null)'
for (int j = 0; j < parent.Arguments.Count; j++) { inlining = new ILInlining(method);
if (parent.Arguments[j].Code == ILCode.Ldloc && (ILVariable)parent.Arguments[j].Operand == v) { inlining.InlineIfPossible(block.Body, ref i);
parent.Arguments[j] = newObj;
block.Body.RemoveAt(i);
i -= new ILInlining(method).InlineInto(block.Body, i, aggressive: true);
return;
}
}
}
} }
} }
#endregion #endregion

Loading…
Cancel
Save