You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// <summary>Compiles lambda expression to delegate. Use ifFastFailedReturnNull parameter to Not fallback to Expression.Compile, useful for testing.</summary>
closure = new DebugArrayClosure(constantsAndNestedLambdas, debugExpr);
515
515
}
516
516
517
+
// todo: @slow this is what System.Compiles does and which makes the compilation significally slower 10x, but the invocation become faster by a single branch instruction
518
+
// var method = new DynamicMethod(string.Empty, returnType, closurePlusParamTypes, true);
519
+
// this is FEC way, significantly faster compilation, but +1 branch instruction in the invocation
517
520
var method = new DynamicMethod(string.Empty, returnType, closurePlusParamTypes, typeof(ArrayClosure), true);
518
521
519
522
// todo: @perf can we just count the Expressions in the TryCollect phase and use it as N * 4 or something?
FEC creates the DynamicMethod with `owner` param, but System compile uses the different overload without owner and internally with `transparentMethod: true`.
62
+
Using this latter (System) overload drastically slows down the compilation but removes the additional branch instruction in the invocation, making a super simple delegates faster.
63
+
But for the delegates doing actual/more work, having additional branch instruction is neglegible and usually does not show in the invocation performance.
0 commit comments