-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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
[NativeAOT] Missed devirtualization opportunities due to Unsafe.As #85906
Comments
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch Issue DetailsIn the below program we miss a devirtualization opportunity in
using System;
using System.Runtime.CompilerServices;
interface IFace
{
void Frob();
}
class Program : IFace
{
public static IFace s_inst = new Program();
public object inst;
public Program() => inst = s_inst;
public void Frob() { }
[MethodImpl(MethodImplOptions.NoInlining)]
public void Method() => Unsafe.As<IFace>(inst).Frob();
static void Main()
{
new Program().Method();
}
} I noticed this in the pattern from here as I was looking why interface dispatch is so hot (2.7% of samples spent in runtime/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/ValueTask.cs Line 719 in 05a3d36
Cc @EgorBo
|
Dup of #84377 Currently |
Will keep it open since it also involves single-impl devirtualization |
In the below program we miss a devirtualization opportunity in
Method
due to theUnsafe.As
.IFace
has a single implementor but RyuJIT doesn't even ask for it.I noticed this in the pattern from here as I was looking why interface dispatch is so hot (2.7% of samples spent in
RhpInterfaceDispatch1
alone) in BasicMinimalApis:runtime/src/libraries/System.Private.CoreLib/src/System/Threading/Tasks/ValueTask.cs
Line 719 in 05a3d36
Cc @EgorBo
The text was updated successfully, but these errors were encountered: