-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
JIT: GDV does not handle delegates pointing to generic methods correctly #89495
Comments
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch Issue DetailsFor delegates, we currently retain the context from the IL (similarly to how we used to do it for delegate GDV before #87847). For example: [MethodImpl(MethodImplOptions.NoInlining)]
static string Foo(Func<string, string> test)
{
return test("abc");
}
public static int Main()
{
for (int i = 0; i < 100; i++)
{
Foo(new Runtime_87597().Id<string>);
if (i >= 30)
{
Thread.Sleep(10);
}
}
return 100;
}
private T Id<T>(T val) => val; results in Importing BB01 (PC=000) of 'Runtime_87597:Foo(System.Func`2[System.String,System.String]):System.String'
[ 0] 0 (0x000) ldarg.0
[ 1] 1 (0x001) ldstr 70000001
[ 2] 6 (0x006) callvirt 0A000001
(Implicit Tail call: prefixFlags |= PREFIX_TAILCALL_IMPLICIT)
In Compiler::impImportCall: opcode is callvirt, kind=0, callRetType is ref, structSize is 0
Considering guarded devirtualization at IL offset 6 (0x6)
Likely methods for call [000002] to method System.Func`2[System.__Canon,System.__Canon]:Invoke(System.__Canon):System.__Canon:this
1) 00007FFAF0DDB600 (Runtime_87597:Id[System.String](System.String):System.String:this) [likelihood:100%]
delegate call would invoke method Runtime_87597:Id[System.String](System.String):System.String:this
Marking call [000002] as guarded devirtualization candidate; will guess for method Runtime_87597:Id[System.String](System.String):System.String:this
info.compCompHnd->canTailCall returned false for call [000002]
CheckCanInline: fetching method info for inline candidate Id -- context 00007FFAF0E23EE9
Class context: System.Func`2[System.String,System.String]
INLINER: during 'impMarkInlineCandidate for GDV' result 'failed this callee' reason 'cannot get method info' for 'Runtime_87597:Foo(System.Func`2[System.String,System.String]):System.String' calling 'System.Func`2[System.__Canon,System.__Canon]:Invoke(System.__Canon):System.__Canon:this'
INLINER: Marking System.Func`2[System.__Canon,System.__Canon]:Invoke(System.__Canon):System.__Canon:this as NOINLINE because of cannot get method info
INLINER: during 'impMarkInlineCandidate for GDV' result 'failed this callee' reason 'cannot get method info' Beyond just resulting in us not being able to inline it presumably also is a correctness issue similar to #87847, though I'm not familiar enough with that problem to construct a test case.
|
Instead of passing through the IL context, update the method context to be the exact method that were recorded in the delegate (which will include the full instantiation). Also do a bit of clean up. Fix dotnet#89495
Instead of passing through the IL context, update the method context to be the exact method that were recorded in the delegate (which will include the full instantiation). Also do a bit of clean up. Fix #89495
For delegates, we currently retain the context from the IL (similarly to how we used to do it for type-based GDV before #87847). For example:
results in
The
Class context: System.Func`2[int,int]
is not right. This is presumably a correctness issue similar to #87847.The text was updated successfully, but these errors were encountered: