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

Fix gtGetClassHandle for static fields (R2R only) #74075

Merged
merged 6 commits into from
Oct 5, 2022

Conversation

EgorBo
Copy link
Member

@EgorBo EgorBo commented Aug 17, 2022

Closes #74000

It turns out gtGetClassHandle used to always return nullptr for such static field loads in R2R (here)

Codegen diff for sample in #74000: https://www.diffchecker.com/AjNP6YTx

@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 Aug 17, 2022
@ghost ghost assigned EgorBo Aug 17, 2022
@ghost
Copy link

ghost commented Aug 17, 2022

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

Issue Details

Closes #74000

It turns out gtGetClassHandle used to always return nullptr for such static field loads in R2R (here)

Codegen diff for sample in ttps://github.com//issues/74000: https://www.diffchecker.com/AjNP6YTx

Author: EgorBo
Assignees: -
Labels:

area-CodeGen-coreclr

Milestone: -

@JulieLeeMSFT JulieLeeMSFT added this to the 8.0.0 milestone Aug 17, 2022
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.

Is the comment you deleted no longer true?

If so, there may be other assumptions like this in the jit code.

@EgorBo
Copy link
Member Author

EgorBo commented Aug 17, 2022

Is the comment you deleted no longer true?

If so, there may be other assumptions like this in the jit code.

Looks like gtIsStaticGCBaseHelperCall is only used in one place (was added by you in dotnet/coreclr#20447) - no idea what exactly changed, maybe some refactoring or something like that but for that static field

    static IFoo theFoo = new Program();

it looks like

IND
  ADD
    CALL CORINFO_HELP_READYTORUN_STATIC_BASE
    8 [FldSeq]

so it's not really opaque and returns nullptr for gtGetClassHandle. Maybe it's NativeAOT specific?

For this PR I am waiting for SPMI to fix itself to re-run and see if there any diffs

@SingleAccretion
Copy link
Contributor

FWIW, the shape of access to static fields hasn't changed for a very long time (one exception being the attachment of field sequences to outer addresses for boxed statics, which are not relevant here).

Also, I believe the "is static base" check can be simply deleted if there's not a correctness (versioning resilience?) reason we cannot look at declared types of statics under R2R. The field sequence check should be sufficient.

@AndyAyersMS
Copy link
Member

Odd, what you have now is more or less the way I wrote it initially, long ago, but then revised it. But I can't find any notes from back then so I don't recall why I changed things.

Nothing else calls gtIsStaticGCBaseHelperCall so perhaps it can be removed.

@EgorBo
Copy link
Member Author

EgorBo commented Aug 20, 2022

/azp list

@azure-pipelines

This comment was marked as resolved.

@EgorBo
Copy link
Member Author

EgorBo commented Aug 20, 2022

/azp run runtime-coreclr r2r, runtime-coreclr crossgen2, runtime-coreclr crossgen2 outerloop, runtime-extra-platforms

@azure-pipelines
Copy link

Azure Pipelines successfully started running 4 pipeline(s).

@EgorBo
Copy link
Member Author

EgorBo commented Sep 26, 2022

Oh, forgot about this one, will address the feedback tomorrow

@EgorBo
Copy link
Member Author

EgorBo commented Oct 2, 2022

@EgorBo EgorBo merged commit 4f81bb5 into dotnet:main Oct 5, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Nov 5, 2022
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.

[NativeAot] Devirtualization opportunity around field loads
5 participants