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

Convert asserts in CEEInfo::getStaticFieldContent() to 'if' checks #100320

Merged
merged 5 commits into from
Mar 27, 2024

Conversation

BruceForstall
Copy link
Member

Do some code cleanup as well.

In fgGetStaticFieldSeqAndAddress, if we have a static field address
altered by a tree of ADD CNS_INS nodes, the field sequence we find
might not be the actual field with a specific "add tree" offset, after
shared constant CSE kicks in (e.g., under OptRepeat), where the
sequence of ADDs might be the alter an arbitrary constant address from
one type into the address of the static field of a different type.
This led to the asserts in question being hit. Change the asserts to if
checks and fail the request to get static field content if the checks fail.

In `fgGetStaticFieldSeqAndAddress`, if we have a static field address
altered by a tree of `ADD CNS_INS` nodes, we need to verify that the
address is within the found field sequence. It might not be after
shared constant CSE kicks in (e.g., under OptRepeat), where the
sequence of ADDs might be the alter an arbitrary constant address from
one type into the address of the static field of a different type.
So we can't use the FieldSeq of the base address when considering
the full offset.
1. Use `eeGetFieldName` / `eeGetClassName` return pointer
2. Only query extra metadata under `verbose || JitConfig.EnableExtraSuperPmiQueries()`
@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 Mar 27, 2024
Copy link
Contributor

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

@BruceForstall
Copy link
Member Author

This is an alternative implementation to #99845, which does more validity checks in the JIT before calling the getStaticFieldContent API.

BruceForstall added a commit to BruceForstall/runtime that referenced this pull request Mar 27, 2024
@BruceForstall
Copy link
Member Author

@EgorBo PTAL
cc @dotnet/jit-contrib

This is an alternative to #99845

@BruceForstall BruceForstall merged commit c4796a3 into dotnet:main Mar 27, 2024
110 checks passed
@BruceForstall BruceForstall deleted the FixStaticFieldSeq2 branch March 27, 2024 20:36
@github-actions github-actions bot locked and limited conversation to collaborators Apr 27, 2024
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.

3 participants