Skip to content

JIT: Remove _MAYBENULL Helper uses - #132539

Open
adamperlin wants to merge 3 commits into
dotnet:mainfrom
adamperlin:adamperlin/type-helper-null-check
Open

JIT: Remove _MAYBENULL Helper uses#132539
adamperlin wants to merge 3 commits into
dotnet:mainfrom
adamperlin:adamperlin/type-helper-null-check

Conversation

@adamperlin

@adamperlinadamperlin commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Resolves#132343 and resolves#132185; Remove requests for _MAYBENULL helper variants in the JIT for TypeHandle -> RuntimeType{Handle} conversions.

CopilotAI lite review requested due to automatic review settings August 19, 2026 22:13
@github-actionsgithub-actionsBot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Aug 19, 2026
@adamperlinadamperlin changed the title Remove _MAYBENULL Helper uses in the JIT[JIT] Remove _MAYBENULL Helper usesAug 19, 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.

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the CoreCLR JIT to stop requesting the *_MAYBENULL helper variants for TypeHandle → RuntimeType{Handle} conversions, instead using explicit null checks where needed and the non-_MAYBENULL helpers otherwise.

Changes:

  • CEE_REFANYTYPE import now emits an inline handle != 0 conditional that either returns default(RuntimeTypeHandle) or calls CORINFO_HELP_TYPEHANDLE_TO_RUNTIMETYPEHANDLE.
  • Type.GetTypeFromHandle intrinsic folding no longer rewrites to CORINFO_HELP_TYPEHANDLE_TO_RUNTIMETYPE_MAYBENULL; it assumes the non-null helper flow and rewrites to CORINFO_HELP_TYPEHANDLE_TO_RUNTIMETYPE.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

FileDescription
src/coreclr/jit/importercalls.cppSimplifies Type.GetTypeFromHandle intrinsic rewriting to always use the non-_MAYBENULLCORINFO_HELP_TYPEHANDLE_TO_RUNTIMETYPE helper when the argument is a TypeHandle→RuntimeTypeHandle helper call.
src/coreclr/jit/importer.cppReplaces CORINFO_HELP_TYPEHANDLE_TO_RUNTIMETYPEHANDLE_MAYBENULL usage in CEE_REFANYTYPE with an explicit null check and conditional default initialization.

@adamperlin
adamperlin marked this pull request as draft August 19, 2026 22:33
@adamperlinadamperlin changed the title [JIT] Remove _MAYBENULL Helper usesJIT: Remove _MAYBENULL Helper usesAug 21, 2026
@adamperlin
adamperlin marked this pull request as ready for review August 21, 2026 16:43
CopilotAI review requested due to automatic review settings August 21, 2026 16:43
@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.

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@EgorBo

Copy link
Copy Markdown
Member

Should this PR physically remove _MAYBENULL everywhere?

@adamperlin

Copy link
Copy Markdown
ContributorAuthor

Should this PR physically remove _MAYBENULL everywhere?

It's still used in the interpreter, so I thought maybe removing it in the interpreter could be a separate change? I'm happy to add that to this PR though!

@jkotas

Copy link
Copy Markdown
Member

I think it would be nice to do it all on one PR

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

Labels

area-CodeGen-coreclrCLR 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.

Cleanup: remove _MAYBENULL helpers [Wasm] Avoid requesting unsupported type-handle helpers for refanytype during R2R compilation

4 participants

@adamperlin@EgorBo@jkotas