From 611a43ee0f672adbac3e25dc77731843a3d10cf1 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Tue, 14 Apr 2015 10:33:30 +0100 Subject: [delegate] Replace multicast delegate implementation Replace the reversed linked implementation by an array based implementation. This will improve Combine performance, as well as ease delegate to virtual function optimization. --- mcs/class/corlib/System/Delegate.cs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'mcs/class/corlib/System/Delegate.cs') diff --git a/mcs/class/corlib/System/Delegate.cs b/mcs/class/corlib/System/Delegate.cs index bd2835cae43..c2f92a7f73b 100644 --- a/mcs/class/corlib/System/Delegate.cs +++ b/mcs/class/corlib/System/Delegate.cs @@ -123,9 +123,6 @@ namespace System [MethodImplAttribute (MethodImplOptions.InternalCall)] internal static extern Delegate CreateDelegate_internal (Type type, object target, MethodInfo info, bool throwOnBindFailure); - [MethodImplAttribute (MethodImplOptions.InternalCall)] - internal extern void SetMulticastInvoke (); - private static bool arg_type_match (Type delArgType, Type argType) { bool match = delArgType == argType; @@ -186,11 +183,12 @@ namespace System MethodInfo invoke = type.GetMethod ("Invoke"); - if (!return_type_match (invoke.ReturnType, method.ReturnType)) + if (!return_type_match (invoke.ReturnType, method.ReturnType)) { if (throwOnBindFailure) throw new ArgumentException ("method return type is incompatible"); else return null; + } ParameterInfo[] delargs = invoke.GetParametersInternal (); ParameterInfo[] args = method.GetParametersInternal (); @@ -224,11 +222,12 @@ namespace System argLengthMatch = args.Length == delargs.Length + 1; } } - if (!argLengthMatch) + if (!argLengthMatch) { if (throwOnBindFailure) throw new ArgumentException ("method argument length mismatch"); else return null; + } bool argsMatch; DelegateData delegate_data = new DelegateData (); @@ -274,11 +273,12 @@ namespace System } } - if (!argsMatch) + if (!argsMatch) { if (throwOnBindFailure) throw new ArgumentException ("method arguments are incompatible"); else return null; + } Delegate d = CreateDelegate_internal (type, target, method, throwOnBindFailure); if (d != null) @@ -614,5 +614,9 @@ namespace System { return CreateDelegate_internal (type, firstArgument, method, true); } + + /* Internal call largely inspired from MS Delegate.InternalAllocLike */ + [MethodImplAttribute(MethodImplOptions.InternalCall)] + internal extern static MulticastDelegate AllocDelegateLike_internal (Delegate d); } } -- cgit v1.2.3