This repository was archived by the owner on Nov 1, 2020. It is now read-only.
Inline access to non-GC static fields #5131
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
An alternate approach to what was attempted in #3962 (and dotnet/coreclr#12420), this time leveraging preexisting infrastructure in RyuJIT built for accessing RVA static fields. This is limited to non-GC statics, since that's what RyuJIT has.
It feels a bit more natural to how JitInterface is structured (e.g. RyuJIT is calling
initClassto eliminate the need to do the cctor check in some cases). If this is something we would want to take further, the next steps would be:initClassto allow generating the inline cctor check (we currently call the ReadyToRun helper to get non-GC static base - this change doesn't affect that).CORINFO_FIELD_INFO- replaceCORINFO_CONST_LOOKUP fieldLookupwithCORINFO_LOOKUP fieldLookupso that we can also do this from shared code.I don't have plans to do the next steps anytime soon though.
The changes to the generated code look like this:
Before:
After: