Skip nullcheck frozen object in unbox optimization#121709
Skip nullcheck frozen object in unbox optimization#121709MichalStrehovsky merged 1 commit intodotnet:mainfrom
Conversation
Fixes the build crash in dotnet#121697. Since with TrimMode=partial, we consider all static fields targets of reflection, we cannot allow inlining their contents. With full trimming allowed, the optimization is unlocked and we hit an assert when trying to nullcheck a constant.
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a build crash (#121697) that occurs when trying to perform null checks on frozen objects during unbox optimization. The issue arises with full trimming enabled, where static field contents can be inlined, and the JIT encounters an assertion failure when attempting to null-check constants (frozen/preinitialized objects).
- Conditionally generates null checks only when
fgAddrCouldBeNullreturns true - Skips null checks for frozen/preinitialized objects that cannot be null
- Adds explanatory comment for the optimization
What assert? |
gtNewNullCheck asserts that the value can be null. |
EgorBo
left a comment
There was a problem hiding this comment.
Interesting, I can see why we never hit it on CoreCLR before
Fixes the build crash in #121697.
Since with TrimMode=partial, we consider all static fields targets of reflection, we cannot allow inlining their contents. With full trimming allowed, the optimization is unlocked and we hit an assert when trying to nullcheck a constant.