KEMBAR78
JIT: Optimize boxing for Nullable<> in "box+isinst+br" pattern by EgorBo · Pull Request #50997 · dotnet/runtime · GitHub
Skip to content

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

@ghost ghost 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