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

JIT: Optimize boxing for Nullable<> in "box+isinst+br" pattern #50997

Merged
merged 10 commits into from
Apr 27, 2021

Conversation

EgorBo
Copy link
Member

@EgorBo EgorBo commented Apr 9, 2021

Partially fixes #50915

Namely:

private S? _ns = (S?)default(S);

public int Nullable() => CallM(_ns);

[MethodImpl(MethodImplOptions.AggressiveInlining)]
static int CallM<T>(T t)
{
    if (t is IMyInterface)
    {
        return ((IMyInterface)t).M();
    }

    return 0;
}

Codegen diff: https://www.diffchecker.com/kAJEqg83

crossgen diffs are empty, will add some tests here.
The second fix for #50915 will be handling nullable in impCastClassOrIsInstToTree

/cc @dotnet/jit-contrib

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Apr 9, 2021
@JulieLeeMSFT JulieLeeMSFT added this to the 6.0.0 milestone Apr 15, 2021
@EgorBo
Copy link
Member Author

EgorBo commented Apr 26, 2021

PTAL @dotnet/jit-contrib

Copy link
Member

@AndyAyersMS AndyAyersMS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add some JITDUMP output for these new cases?

EgorBo and others added 3 commits April 27, 2021 10:06
@EgorBo
Copy link
Member Author

EgorBo commented Apr 27, 2021

@AndyAyersMS added.

@EgorBo EgorBo merged commit 6af5918 into dotnet:main Apr 27, 2021
@ghost ghost locked as resolved and limited conversation to collaborators May 27, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Nullable<T> interface check / dispatch is comparatively very slow
3 participants