Skip to content

Commit

Permalink
.NET 3.0 builds properly, serious performance regressions though
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin-montrose committed Mar 22, 2013
1 parent 037ff58 commit 7c30e21
Show file tree
Hide file tree
Showing 62 changed files with 223 additions and 193 deletions.
2 changes: 1 addition & 1 deletion Sigil/Emit.ArgumentList.cs
Expand Up @@ -23,7 +23,7 @@ public Emit<DelegateType> ArgumentList()
throw new InvalidOperationException("ArgumentList can only be called in VarArgs methods");
}

UpdateState(OpCodes.Arglist, StackTransition.Push<NativeIntType>().Wrap("ArgumentList"));
UpdateState(OpCodes.Arglist, Wrap(StackTransition.Push<NativeIntType>(), "ArgumentList"));

return this;
}
Expand Down
4 changes: 2 additions & 2 deletions Sigil/Emit.Arithmetic.cs
Expand Up @@ -42,7 +42,7 @@ private void VerifyAndDoArithmetic(string name, OpCode addOp, bool allowReferenc
};
}

UpdateState(addOp, transitions.Wrap(name));
UpdateState(addOp, Wrap(transitions, name));
}

/// <summary>
Expand Down Expand Up @@ -202,7 +202,7 @@ public Emit<DelegateType> Negate()
new StackTransition(new [] { typeof(double) }, new [] { typeof(double) })
};

UpdateState(OpCodes.Neg, transitions.Wrap("Negate"));
UpdateState(OpCodes.Neg, Wrap(transitions, "Negate"));

return this;
}
Expand Down
6 changes: 3 additions & 3 deletions Sigil/Emit.Bitwise.cs
Expand Up @@ -16,7 +16,7 @@ private void VerifyAndBinaryBitwise(string name, OpCode op)
new StackTransition(new [] { typeof(NativeIntType), typeof(NativeIntType) }, new [] { typeof(NativeIntType) }),
};

UpdateState(op, transitions.Wrap(name));
UpdateState(op, Wrap(transitions, name));
}

/// <summary>
Expand Down Expand Up @@ -62,7 +62,7 @@ public Emit<DelegateType> Not()
new StackTransition(new [] { typeof(NativeIntType) }, new [] { typeof(NativeIntType) }),
};

UpdateState(OpCodes.Not, transitions.Wrap("Not"));
UpdateState(OpCodes.Not, Wrap(transitions, "Not"));

return this;
}
Expand All @@ -80,7 +80,7 @@ private void VerifyAndShift(string name, OpCode op)
new StackTransition(new [] { typeof(int), typeof(long) }, new [] { typeof(long) })
};

UpdateState(op, transitions.Wrap(name));
UpdateState(op, Wrap(transitions, name));
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion Sigil/Emit.Box.cs
Expand Up @@ -41,7 +41,7 @@ public Emit<DelegateType> Box(Type valueType)
new StackTransition(new [] { valueType }, new [] { typeof(object) })
};

UpdateState(OpCodes.Box, valueType, transitions.Wrap("Box"));
UpdateState(OpCodes.Box, valueType, Wrap(transitions, "Box"));

return this;
}
Expand Down
33 changes: 18 additions & 15 deletions Sigil/Emit.Branch.cs
Expand Up @@ -24,7 +24,7 @@ public Emit<DelegateType> Branch(Label label)
UnusedLabels.Remove(label);

UpdateOpCodeDelegate update;
UpdateState(OpCodes.Br, label, StackTransition.None().Wrap("Branch"), out update);
UpdateState(OpCodes.Br, label, Wrap(StackTransition.None(), "Branch"), out update);

CurrentVerifier.Branch(label);
CheckBranchesAndLabels("Branch", label);
Expand Down Expand Up @@ -75,7 +75,7 @@ public Emit<DelegateType> BranchIfEqual(Label label)


UpdateOpCodeDelegate update;
UpdateState(OpCodes.Beq, label, transitions.Wrap("BranchIfEqual"), out update);
UpdateState(OpCodes.Beq, label, Wrap(transitions, "BranchIfEqual"), out update);

CurrentVerifier.Branch(label);
CheckBranchesAndLabels("BranchIfEqual", label);
Expand Down Expand Up @@ -123,7 +123,7 @@ public Emit<DelegateType> UnsignedBranchIfNotEqual(Label label)
};

UpdateOpCodeDelegate update;
UpdateState(OpCodes.Bne_Un, label, transitions.Wrap("UnsignedBranchIfNotEqual"), out update);
UpdateState(OpCodes.Bne_Un, label, Wrap(transitions, "UnsignedBranchIfNotEqual"), out update);

CurrentVerifier.Branch(label);
CheckBranchesAndLabels("UnsignedBranchIfNotEqual", label);
Expand All @@ -150,16 +150,19 @@ public Emit<DelegateType> UnsignedBranchIfNotEqual(string name)
private TransitionWrapper BranchComparableTransitions(string name)
{
return
new[]
{
new StackTransition(new [] { typeof(int), typeof(int) }, Type.EmptyTypes),
new StackTransition(new [] { typeof(int), typeof(NativeIntType) }, Type.EmptyTypes),
new StackTransition(new [] { typeof(NativeIntType), typeof(int) }, Type.EmptyTypes),
new StackTransition(new [] { typeof(NativeIntType), typeof(NativeIntType) }, Type.EmptyTypes),
new StackTransition(new [] { typeof(long), typeof(long) }, Type.EmptyTypes),
new StackTransition(new [] { typeof(float), typeof(float) }, Type.EmptyTypes),
new StackTransition(new [] { typeof(double), typeof(double) }, Type.EmptyTypes)
}.Wrap(name);
Wrap(
new[]
{
new StackTransition(new [] { typeof(int), typeof(int) }, Type.EmptyTypes),
new StackTransition(new [] { typeof(int), typeof(NativeIntType) }, Type.EmptyTypes),
new StackTransition(new [] { typeof(NativeIntType), typeof(int) }, Type.EmptyTypes),
new StackTransition(new [] { typeof(NativeIntType), typeof(NativeIntType) }, Type.EmptyTypes),
new StackTransition(new [] { typeof(long), typeof(long) }, Type.EmptyTypes),
new StackTransition(new [] { typeof(float), typeof(float) }, Type.EmptyTypes),
new StackTransition(new [] { typeof(double), typeof(double) }, Type.EmptyTypes)
},
name
);
}

/// <summary>
Expand Down Expand Up @@ -525,7 +528,7 @@ public Emit<DelegateType> BranchIfFalse(Label label)
};

UpdateOpCodeDelegate update;
UpdateState(OpCodes.Brfalse, label, transitions.Wrap("BranchIfFalse"), out update);
UpdateState(OpCodes.Brfalse, label, Wrap(transitions, "BranchIfFalse"), out update);

CurrentVerifier.Branch(label);
CheckBranchesAndLabels("BranchIfFalse", label);
Expand Down Expand Up @@ -577,7 +580,7 @@ public Emit<DelegateType> BranchIfTrue(Label label)
};

UpdateOpCodeDelegate update;
UpdateState(OpCodes.Brtrue, label, transitions.Wrap("BranchIfTrue"), out update);
UpdateState(OpCodes.Brtrue, label, Wrap(transitions, "BranchIfTrue"), out update);

CurrentVerifier.Branch(label);
CheckBranchesAndLabels("BranchIfTrue", label);
Expand Down
2 changes: 1 addition & 1 deletion Sigil/Emit.Break.cs
Expand Up @@ -10,7 +10,7 @@ public partial class Emit<DelegateType>
/// </summary>
public Emit<DelegateType> Break()
{
UpdateState(OpCodes.Break, StackTransition.None().Wrap("Break"));
UpdateState(OpCodes.Break, Wrap(StackTransition.None(), "Break"));

return this;
}
Expand Down
2 changes: 1 addition & 1 deletion Sigil/Emit.Call.cs
Expand Up @@ -120,7 +120,7 @@ public Emit<DelegateType> Call(MethodInfo method, Type[] arglist = null)
};
}

UpdateState(OpCodes.Call, method, transitions.Wrap("Call"), firstParamIsThis: firstParamIsThis, arglist: arglist);
UpdateState(OpCodes.Call, method, Wrap(transitions, "Call"), firstParamIsThis: firstParamIsThis, arglist: arglist);

return this;
}
Expand Down
2 changes: 1 addition & 1 deletion Sigil/Emit.CallIndirect.cs
Expand Up @@ -388,7 +388,7 @@ public Emit<DelegateType> CallIndirect(CallingConventions callConventions, Type
}
}

UpdateState(OpCodes.Calli, callConventions, returnType, parameterTypes, transitions.Wrap("CallIndirect"), arglist);
UpdateState(OpCodes.Calli, callConventions, returnType, parameterTypes, Wrap(transitions, "CallIndirect"), arglist);

return this;
}
Expand Down
4 changes: 2 additions & 2 deletions Sigil/Emit.CallVirtual.cs
Expand Up @@ -59,7 +59,7 @@ public Emit<DelegateType> CallVirtual(MethodInfo method, Type constrained = null
// Shove the constrained prefix in if it's supplied
if (constrained != null)
{
UpdateState(OpCodes.Constrained, constrained, StackTransition.None().Wrap("CallVirtual"));
UpdateState(OpCodes.Constrained, constrained, Wrap(StackTransition.None(), "CallVirtual"));
}

IEnumerable<StackTransition> transitions;
Expand All @@ -81,7 +81,7 @@ public Emit<DelegateType> CallVirtual(MethodInfo method, Type constrained = null
};
}

UpdateState(OpCodes.Callvirt, method, transitions.Wrap("CallVirtual"), arglist: arglist);
UpdateState(OpCodes.Callvirt, method, Wrap(transitions, "CallVirtual"), arglist: arglist);

return this;
}
Expand Down
2 changes: 1 addition & 1 deletion Sigil/Emit.CastClass.cs
Expand Up @@ -68,7 +68,7 @@ public Emit<DelegateType> CastClass(Type referenceType)
new StackTransition(new [] { typeof(object) }, new [] { referenceType }, before: before)
};

UpdateState(OpCodes.Castclass, referenceType, transitions.Wrap("CastClass"));
UpdateState(OpCodes.Castclass, referenceType, Wrap(transitions, "CastClass"));

return this;
}
Expand Down
2 changes: 1 addition & 1 deletion Sigil/Emit.CheckFinite.cs
Expand Up @@ -20,7 +20,7 @@ public Emit<DelegateType> CheckFinite()
};

// ckfinite leaves the value on the stack, oddly enough
UpdateState(OpCodes.Ckfinite, transitions.Wrap("CheckFinite"));
UpdateState(OpCodes.Ckfinite, Wrap(transitions, "CheckFinite"));

return this;
}
Expand Down
21 changes: 12 additions & 9 deletions Sigil/Emit.Compare.cs
Expand Up @@ -8,14 +8,17 @@ public partial class Emit<DelegateType>
private TransitionWrapper ValidateComparable(string method)
{
return
new[]
{
new StackTransition(new [] { typeof(int), typeof(int) }, new [] { typeof(int) }),
new StackTransition(new [] { typeof(NativeIntType), typeof(NativeIntType) }, new [] { typeof(int) }),
new StackTransition(new [] { typeof(long), typeof(long) }, new [] { typeof(int) }),
new StackTransition(new [] { typeof(float), typeof(float) }, new [] { typeof(int) }),
new StackTransition(new [] { typeof(double), typeof(double) }, new [] { typeof(int) }),
}.Wrap(method);
Wrap(
new[]
{
new StackTransition(new [] { typeof(int), typeof(int) }, new [] { typeof(int) }),
new StackTransition(new [] { typeof(NativeIntType), typeof(NativeIntType) }, new [] { typeof(int) }),
new StackTransition(new [] { typeof(long), typeof(long) }, new [] { typeof(int) }),
new StackTransition(new [] { typeof(float), typeof(float) }, new [] { typeof(int) }),
new StackTransition(new [] { typeof(double), typeof(double) }, new [] { typeof(int) }),
},
method
);
}

/// <summary>
Expand All @@ -31,7 +34,7 @@ public Emit<DelegateType> CompareEqual()
new StackTransition(new [] { typeof(WildcardType), typeof(WildcardType) }, new [] { typeof(int) })
};

UpdateState(OpCodes.Ceq, transitions.Wrap("CompareEqual"));
UpdateState(OpCodes.Ceq, Wrap(transitions, "CompareEqual"));

return this;
}
Expand Down
29 changes: 16 additions & 13 deletions Sigil/Emit.Convert.cs
Expand Up @@ -9,20 +9,23 @@ public partial class Emit<DelegateType>
private TransitionWrapper CheckConvertible(string method, Type toType)
{
return
new[]
{
new StackTransition(new [] { typeof(int) }, new [] { toType }),
new StackTransition(new [] { typeof(NativeIntType) }, new [] { toType }),
new StackTransition(new [] { typeof(long) }, new [] { toType }),
new StackTransition(new [] { typeof(float) }, new [] { toType }),
new StackTransition(new [] { typeof(double) }, new [] { toType }),
new StackTransition(new [] { typeof(AnyPointerType) }, new [] { toType }),
new StackTransition(new [] { typeof(AnyPointerType) }, new [] { toType }),
new StackTransition(new [] { typeof(AnyPointerType) }, new [] { toType }),
new StackTransition(new [] { typeof(AnyPointerType) }, new [] { toType }),
new StackTransition(new [] { typeof(AnyPointerType) }, new [] { toType })
Wrap(
new[]
{
new StackTransition(new [] { typeof(int) }, new [] { toType }),
new StackTransition(new [] { typeof(NativeIntType) }, new [] { toType }),
new StackTransition(new [] { typeof(long) }, new [] { toType }),
new StackTransition(new [] { typeof(float) }, new [] { toType }),
new StackTransition(new [] { typeof(double) }, new [] { toType }),
new StackTransition(new [] { typeof(AnyPointerType) }, new [] { toType }),
new StackTransition(new [] { typeof(AnyPointerType) }, new [] { toType }),
new StackTransition(new [] { typeof(AnyPointerType) }, new [] { toType }),
new StackTransition(new [] { typeof(AnyPointerType) }, new [] { toType }),
new StackTransition(new [] { typeof(AnyPointerType) }, new [] { toType })

}.Wrap(method);
},
method
);
}

/// <summary>
Expand Down
6 changes: 3 additions & 3 deletions Sigil/Emit.CopyBlock.cs
Expand Up @@ -25,12 +25,12 @@ public Emit<DelegateType> CopyBlock(bool isVolatile = false, int? unaligned = nu

if (isVolatile)
{
UpdateState(OpCodes.Volatile, StackTransition.None().Wrap("CopyBlock"));
UpdateState(OpCodes.Volatile, Wrap(StackTransition.None(),"CopyBlock"));
}

if (unaligned.HasValue)
{
UpdateState(OpCodes.Unaligned, (byte)unaligned.Value, StackTransition.None().Wrap("CopyBlock"));
UpdateState(OpCodes.Unaligned, (byte)unaligned.Value, Wrap(StackTransition.None(), "CopyBlock"));
}

var transition =
Expand All @@ -47,7 +47,7 @@ public Emit<DelegateType> CopyBlock(bool isVolatile = false, int? unaligned = nu
new StackTransition(new[] { typeof(int), typeof(byte).MakeByRefType(), typeof(byte).MakeByRefType() }, Type.EmptyTypes)
};

UpdateState(OpCodes.Cpblk, transition.Wrap("CopyBlock"));
UpdateState(OpCodes.Cpblk, Wrap(transition, "CopyBlock"));

return this;
}
Expand Down
2 changes: 1 addition & 1 deletion Sigil/Emit.CopyObject.cs
Expand Up @@ -48,7 +48,7 @@ public Emit<DelegateType> CopyObject(Type valueType)
new StackTransition(new [] { valueType.MakeByRefType(), valueType.MakeByRefType() }, Type.EmptyTypes),
};

UpdateState(OpCodes.Cpobj, valueType, transitions.Wrap("CopyObject"));
UpdateState(OpCodes.Cpobj, valueType, Wrap(transitions, "CopyObject"));

return this;
}
Expand Down
2 changes: 1 addition & 1 deletion Sigil/Emit.Duplicate.cs
Expand Up @@ -10,7 +10,7 @@ public partial class Emit<DelegateType>
/// </summary>
public Emit<DelegateType> Duplicate()
{
UpdateState(OpCodes.Dup, (new [] { new StackTransition(isDuplicate: true) }).Wrap("Duplicate"));
UpdateState(OpCodes.Dup, Wrap(new [] { new StackTransition(isDuplicate: true) }, "Duplicate"));

return this;
}
Expand Down
6 changes: 3 additions & 3 deletions Sigil/Emit.InitializeBlock.cs
Expand Up @@ -25,12 +25,12 @@ public Emit<DelegateType> InitializeBlock(bool isVolatile = false, int? unaligne

if(isVolatile)
{
UpdateState(OpCodes.Volatile, StackTransition.None().Wrap("InitializeBlock"));
UpdateState(OpCodes.Volatile, Wrap(StackTransition.None(), "InitializeBlock"));
}

if (unaligned.HasValue)
{
UpdateState(OpCodes.Unaligned, (byte)unaligned.Value, StackTransition.None().Wrap("InitializeBlock"));
UpdateState(OpCodes.Unaligned, (byte)unaligned.Value, Wrap(StackTransition.None(), "InitializeBlock"));
}

var transition =
Expand All @@ -43,7 +43,7 @@ public Emit<DelegateType> InitializeBlock(bool isVolatile = false, int? unaligne
new StackTransition(new [] { typeof(int), typeof(NativeIntType), typeof(byte).MakeByRefType() }, Type.EmptyTypes)
};

UpdateState(OpCodes.Initblk, transition.Wrap("InitializeBlock"));
UpdateState(OpCodes.Initblk, Wrap(transition, "InitializeBlock"));

return this;
}
Expand Down
2 changes: 1 addition & 1 deletion Sigil/Emit.InitializeObject.cs
Expand Up @@ -36,7 +36,7 @@ public Emit<DelegateType> InitializeObject(Type valueType)
new StackTransition(new [] { valueType.MakeByRefType() }, Type.EmptyTypes),
};

UpdateState(OpCodes.Initobj, valueType, transitions.Wrap("InitializeObject"));
UpdateState(OpCodes.Initobj, valueType, Wrap(transitions, "InitializeObject"));

return this;
}
Expand Down
2 changes: 1 addition & 1 deletion Sigil/Emit.IsInstance.cs
Expand Up @@ -52,7 +52,7 @@ public Emit<DelegateType> IsInstance(Type type)
new StackTransition(new[] { typeof(WildcardType) }, new [] { type }, before)
};

UpdateState(OpCodes.Isinst, type, transitions.Wrap("IsInstance"));
UpdateState(OpCodes.Isinst, type, Wrap(transitions, "IsInstance"));

return this;
}
Expand Down
4 changes: 2 additions & 2 deletions Sigil/Emit.Jump.cs
Expand Up @@ -55,7 +55,7 @@ public Emit<DelegateType> Jump(MethodInfo method)
throw new InvalidOperationException("Jump cannot transfer control from an exception block");
}

UpdateState((new [] {new StackTransition(0) }).Wrap("Jump"));
UpdateState(Wrap(new[] { new StackTransition(0) }, "Jump"));

for (var i = 0; i < paras.Length; i++)
{
Expand All @@ -68,7 +68,7 @@ public Emit<DelegateType> Jump(MethodInfo method)
}
}

UpdateState(OpCodes.Jmp, method, StackTransition.None().Wrap("Jump"));
UpdateState(OpCodes.Jmp, method, Wrap(StackTransition.None(), "Jump"));

return this;
}
Expand Down
2 changes: 1 addition & 1 deletion Sigil/Emit.Leave.cs
Expand Up @@ -32,7 +32,7 @@ public Emit<DelegateType> Leave(Label label)

// Note that Leave *always* nuked the stack; nothing survies exiting an exception block
UpdateOpCodeDelegate update;
UpdateState(OpCodes.Leave, label, new[] { new StackTransition(new [] { typeof(PopAllType) }, Type.EmptyTypes) }.Wrap("Leave"), out update);
UpdateState(OpCodes.Leave, label, Wrap(new[] { new StackTransition(new [] { typeof(PopAllType) }, Type.EmptyTypes) }, "Leave"), out update);

CheckBranchesAndLabels("Leave", label);

Expand Down
2 changes: 1 addition & 1 deletion Sigil/Emit.LoadArgument.cs
Expand Up @@ -21,7 +21,7 @@ public Emit<DelegateType> LoadArgument(ushort index)
throw new ArgumentException("index must be between 0 and " + (ParameterTypes.Length - 1) + ", inclusive");
}

var transitions = StackTransition.Push(ParameterTypes[index]).Wrap("LoadArgument");
var transitions = Wrap(StackTransition.Push(ParameterTypes[index]), "LoadArgument");

switch (index)
{
Expand Down

0 comments on commit 7c30e21

Please sign in to comment.