Add CORINFO_HELP_TYPEHANDLE_TO_RUNTIMETYPE_MAYBENULL to ReadyToRun - #132341
Add CORINFO_HELP_TYPEHANDLE_TO_RUNTIMETYPE_MAYBENULL to ReadyToRun#132341adamperlin wants to merge 2 commits into
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0c38eea1-912f-4411-89bc-83b71c52ac1d
…type-handle-helper-request
|
Azure Pipelines: Successfully started running 3 pipeline(s). 13 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
Pull request overview
Adds a ReadyToRun (R2R) helper/fixup kind for the CORINFO_HELP_TYPEHANDLE_TO_RUNTIMETYPE_MAYBENULL family so Crossgen2 can emit/resolve it during R2R compilation (notably for Wasm targets without a runtime JIT), avoiding RequiresRuntimeJit failures when importing patterns like refanytype + Type.GetTypeFromHandle.
Changes:
- Introduces
ReadyToRunHelper.GetRuntimeTypeHandleMaybeNull (0x57)across CoreCLR headers and tooling, and bumps the R2R minor version to 26.2. - Updates the R2R JIT-EE (
CorInfoImpl.ReadyToRun) to map*_MAYBENULLTypeHandle→RuntimeType helpers to the new R2R helper cell instead of throwingRequiresRuntimeJitException. - Extends test coverage: updates the importer IL test and adds a Wasm Webcil R2R test that ensures a
__reftype(TypedReference)path compiles into the Wasm R2R image.
Reviewed changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/tests/JIT/Directed/coverage/importer/refanytype1.il | Extends IL test to exercise non-null and default TypedReference paths and trigger the MAYBENULL helper. |
| src/coreclr/tools/Common/Internal/Runtime/ReadyToRunConstants.cs | Adds the new ReadyToRunHelper enum value used by tooling. |
| src/coreclr/tools/Common/Internal/Runtime/ModuleHeaders.cs | Bumps R2R header minor version to 26.2 for managed tooling. |
| src/coreclr/tools/aot/ILCompiler.Reflection.ReadyToRun/ReadyToRunSignature.cs | Teaches signature pretty-printer to decode/display the new helper. |
| src/coreclr/tools/aot/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs | Maps the MAYBENULL helpers to the new R2R helper cell and removes the runtime-JIT-only classification. |
| src/coreclr/tools/aot/ILCompiler.ReadyToRun.Tests/TestCases/Webcil/WasmWebcilModule.cs | Adds a method using __reftype to ensure the helper is requested during Wasm R2R compilation. |
| src/coreclr/tools/aot/ILCompiler.ReadyToRun.Tests/TestCases/R2RTestSuites.cs | Validates the new Webcil method is compiled into the Wasm R2R image. |
| src/coreclr/nativeaot/Runtime/inc/ModuleHeaders.h | Bumps R2R header minor version to 26.2 for NativeAOT runtime. |
| src/coreclr/inc/readytorunhelpers.h | Adds the new helper mapping in the CoreCLR R2R helper table. |
| src/coreclr/inc/readytorun.h | Bumps R2R minor version constant and adds the new helper enum value in native headers. |
|
Not for this PR, but I think all _MAYBENULL variants should be removed. JIT should just emit a quick nullcheck itself (we would be able to constant fold it then). e.g. |
That seems like a good idea. I opened a tracking issue! EDIT: Closed, I see you already did! |
Can we do this instead? Once we add the helper for R2R, it is going to be around forever. |
Yeah, that is a good point. It seems reasonable to do now instead of adding the helper. I'll close this and instead prioritize removing the MAYBENULL variants. |
Fixes #132185.
CORINFO_HELP_TYPEHANDLE_TO_RUNTIMETYPE_MAYBENULL does not exist on ReadyToRun and crossgen will throw a
RequiresRuntimeJitexception if the helper is requested. CORINFO_HELP_TYPEHANDLE_TO_RUNTIMETYPE (non-null handling variant) exists already though, so this PR adds a fixup kind to expose theMAYBENULLvariant for R2R for platforms like Wasm which don't have a runtime JIT.Validation
refanytype1.ilhas been updated to:CORINFO_HELP_TYPEHANDLE_TO_RUNTIMETYPEHANDLE_MAYBENULL(default(TypedReference)) = default(TypedReference)CORINFO_HELP_TYPEHANDLE_TO_RUNTIMETYPE_MAYBENULL(default(TypedReference))) = nullUse
__reftype(TypedReference)to trigger the use ofCORINFO_HELP_TYPEHANDLE_TO_RUNTIMETYPE_MAYBENULLand assert that the containing method exists in the Wasm R2R image.Note
This pull request was generated with GitHub Copilot.