-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Open
Milestone
Description
In native AOT we build instantiating+unboxing thunks that bridge the calling convention gap when calling instance methods on shared generic valuetypes virtually:
interface IFoo { void Method(); }
struct Gen<T> : IFoo
{
// Native code for Gen<__Canon>.Method expects _reference_ to the first field of the struct as the first parameter,
// and a "generic context" (that tells the __Canon method body what the T is) as the second parameter
public void Method() => Console.WriteLine(typeof(T));
}
IFoo o = new Gen<string>();
// The callsite was set up as usual for interface method invocation so the first and only parameter
// is the `this` (`o` in this case)
o.Method();We emit these as IL and use some tricks to make it compile (dotnet/corert#2566).
For runtime async, it looks like we're out of luck with this approach because we'd need to generate a method that is runtime async (doable) that calls another runtime async method while injecting the extra instantiation parameter and passing down async resume context too.
We'll probably need a RyuJIT feature.
Metadata
Metadata
Assignees
Type
Projects
Status
No status