Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
2 tasks done
LeVladIonescu opened this issue Mar 13, 2023 · 2 comments
Assignees
Labels
area-Codegen-AOT-mono tracking This issue is tracking the completion of other related issues.
Milestone

Comments

@LeVladIonescu
Copy link
Contributor

LeVladIonescu commented Mar 13, 2023

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
@LeVladIonescu LeVladIonescu added area-Codegen-JIT-mono area-Codegen-AOT-mono tracking This issue is tracking the completion of other related issues. labels Mar 13, 2023
@LeVladIonescu LeVladIonescu added this to the 8.0.0 milestone Mar 13, 2023
@LeVladIonescu LeVladIonescu self-assigned this Mar 13, 2023
@LeVladIonescu
Copy link
Contributor Author

Related to #78889

@LeVladIonescu
Copy link
Contributor Author

AOT virtual delegates wrappers enabled by #85643.

@ghost ghost locked as resolved and limited conversation to collaborators Jun 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-Codegen-AOT-mono tracking This issue is tracking the completion of other related issues.
Projects
None yet
Development

No branches or pull requests

2 participants