Skip to content

[mono] Change bound delegates dependency of bound_method + delegate_type to use just delegate_type #83329

Closed
@LeVladIonescu

Description

@LeVladIonescu

Description

Testcase

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

Metadata

Metadata

Assignees

Labels

area-Codegen-AOT-monotrackingThis issue is tracking the completion of other related issues.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions