Skip to content

JIT: Expand casts for unsealed exact-class candidates - #136308

Merged
EgorBo merged 2 commits into
dotnet:mainfrom
EgorBo:jit-expand-unsealed-cast-candidates
Oct 23, 2026
Merged

EgorBo merged 2 commits into
dotnet:mainfrom
EgorBo:jit-expand-unsealed-cast-candidates

Conversation

@EgorBo

@EgorBo EgorBo commented Oct 22, 2026

Copy link
Copy Markdown
Member

Fixes #136302.

Remove the redundant isExactType check on cast candidates returned by getExactClasses. The API already supplies the complete set of possible runtime types, including base classes with subclasses in that set. Requiring each candidate to be sealed prevents NativeAOT from expanding these casts into method-table comparisons.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: 474803a8-11ce-496c-a351-ff85e990bedc
@github-actions github-actions Bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Oct 22, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 5 pipeline(s).
11 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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

…mentations

Co-authored-by: Copilot <[email protected]>
Copilot-Session: 474803a8-11ce-496c-a351-ff85e990bedc
@EgorBo

EgorBo commented Oct 22, 2026

Copy link
Copy Markdown
Member Author

PTAL @MichalStrehovsky, copilot found no issues. This cast expansion logic was written by me, but I don't remember why I added that conservative check.

Small size regressions in rt-rz as expected (cast expansion with multiple guesses is bigger than call to cast-helper).

@MichalStrehovsky

Copy link
Copy Markdown
Member

/azp run runtime-nativeaot-outerloop

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@MichalStrehovsky MichalStrehovsky left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm starting to be scared of this code, we had many bugs. I guess it's early enough we can try!

@EgorBo

EgorBo commented Oct 23, 2026

Copy link
Copy Markdown
Member Author

/ba-g failure is #136386

@EgorBo

EgorBo commented Oct 23, 2026

Copy link
Copy Markdown
Member Author

I'm starting to be scared of this code, we had many bugs.

I am not remembering any (at least on the JIT side). Here we just depend on ILC to give us exhaustive list of classes for given base.

@EgorBo
EgorBo merged commit 27123d2 into dotnet:main Oct 23, 2026
151 of 155 checks passed
@EgorBo
EgorBo deleted the jit-expand-unsealed-cast-candidates branch October 23, 2026 21:54
@MichalStrehovsky

Copy link
Copy Markdown
Member

I'm starting to be scared of this code, we had many bugs.

I am not remembering any (at least on the JIT side). Here we just depend on ILC to give us exhaustive list of classes for given base.

Yes the bugs were all in the whole program analysis.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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: missed devirtualization for isinst

2 participants