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
{{ message }}
Repository navigation
[mono] Change bound delegates dependency of bound_method + delegate_type to use just delegate_type #83329
using System;
using System.Runtime.InteropServices;
public class Test
{
public static int Main () {
var del = (Func<string, string>)Delegate.CreateDelegate (typeof (Func<string, string>), null, typeof (object).GetMethod ("ToString"));
Console.WriteLine (del ("FOO"));
}
}
Description
At the moment, this is creating a wrapper which depends on both the delegate type and the bounded method to make a virtual call to delegate's bounded method which can not be generated at AOT time since the AOT compiler can not determine that a particular combination of delegate type and bound method will be needed at runtime.
Approach
Instead of making a virtual call, we should make a calli instruction using a pointer to the bounded method.
In this way, AOT compiler could generate a wrapper depending just on the delegate type.
Tasks
Enable calli instruction for JIT instead of callvirt
Make WRAPPER_SUBTYPE_DELEGATE_INVOKE_VIRTUAL to be associated only with the delegate type in order to generate it at AOT time
Activity
LeVladIonescu commentedon Mar 13, 2023
Related to #78889
LeVladIonescu commentedon May 22, 2023
AOT virtual delegates wrappers enabled by #85643.