Skip to content

Compile managed JIT helpers in partial no-JIT ReadyToRun compilations - #138188

Merged
lewing merged 4 commits into
dotnet:mainfrom
lewing:lewing-partial-r2r-managed-jit-helpers
Nov 24, 2026
Merged

lewing merged 4 commits into
dotnet:mainfrom
lewing:lewing-partial-r2r-managed-jit-helpers

Conversation

@lewing

@lewing lewing commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

Under --partial, ReadyToRunSingleAssemblyCompilationModuleGroup.ContainsMethodBodyCore rejects every method missing from the profile. ReadyToRunJitHelperRootProvider roots the managed JIT helpers through AddCompilationRoot, which only keeps a root that passes ContainsMethodBody, so on browser composites all 70 helpers were silently dropped. That breaks the rule that the CoreLib R2R image must contain code for all JIT helpers (comment). Unprofiled helper calls then resolve to interpreter entry points with no code and trap with RuntimeError: null function.

Changes:

  • ReadyToRunJitHelperRootProvider.GetManagedHelpers builds the helper set once. It keeps the existing ARM/ARM64 and single-threaded thread-statics exclusions, and both rooting and the new check use it.
  • On targets without runtime codegen, managed JIT helpers are exempt from the partial-profile restriction, alongside hardware intrinsics and the IsHardwareAccelerated getters. The exemption only applies when the version bubble includes CoreLib.
  • Regression test PartialNoJitCompilationContainsManagedJitHelpers.

Validation (browser-wasm, Release):

  • ILCompiler.ReadyToRun.Tests: 440 total, 397 passed, 0 failed, 43 skipped. The new test fails (70/70 helpers rejected) without the fix.
  • System.Runtime.Intrinsics.Tests with a profile containing only PackedSimdTests.PackedSimdIsSupported plus --partial: crashes with RuntimeError: null function before the fix and passes after.
  • Full System.Runtime.Intrinsics.Tests with the default profile, run before the CoreLib-bubble guard was added: 13346 passed, 0 failed, 1 skipped. All 70 helpers appear in the --map output.
  • Composite image size: 801,987 → 795,991 bytes with the default profile, and 89,961 → 116,269 bytes with the caller-only profile.

Resolves #138187

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).
12 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: @dotnet/crossgen-contrib
See info in area-owners.md if you want to be subscribed.

@lewing
lewing requested review from pavelsavara and a balanced review from Copilot November 24, 2026 03:53

Copilot AI 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.

🟢 Approval recommended

There are no active review issues for the change preserving required managed JIT helpers in partial ReadyToRun compilations.

No open issues 🎉

What changed in this PR

This PR keeps managed JIT helpers in partial ReadyToRun compilations on targets without runtime code generation, preventing required helpers from being dropped when absent from the profile. It builds on the vector-acceleration changes in #138183.

Changes:

  • Shares managed-helper discovery between rooting and compilation filtering, preserving existing platform exclusions.
  • Exempts managed helpers from partial-profile filtering when runtime code generation is unavailable and the version bubble includes CoreLib.
  • Adds regression coverage for unprofiled helpers while checking that ordinary unprofiled methods remain excluded.
File Description
src/​coreclr/​tools/​aot/​ILCompiler.ReadyToRun/​Compiler/​ReadyToRunSingleAssemblyCompilationModuleGroup.cs Adds guarded helper exemption with a lazily cached helper set.
src/​coreclr/​tools/​aot/​ILCompiler.ReadyToRun/​Compiler/​ReadyToRunJitHelperRootProvider.cs Extracts shared discovery of distinct managed helpers.
src/​coreclr/​tools/​aot/​ILCompiler.ReadyToRun/​Compiler/​ReadyToRunHardwareIntrinsicRootProvider.cs Contains vector-query rooting inherited from #138183, outside this PR’s requested scope.
src/​coreclr/​tools/​aot/​ILCompiler.ReadyToRun.Tests/​ReadyToRunLibraryRootProviderTests.cs Adds managed-helper regression coverage and shared partial-compilation setup.

Review effort: Balanced

lewing and others added 2 commits November 24, 2026 11:14
Exempt the managed JIT helpers rooted by ReadyToRunJitHelperRootProvider from the
partial-profile restriction on targets without runtime codegen, so CoreLib's R2R
image always contains code for every JIT helper.

Fixes dotnet#138187

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@lewing
lewing force-pushed the lewing-partial-r2r-managed-jit-helpers branch from f5c7d9d to bf3dd61 Compare November 24, 2026 17:15
@lewing
lewing requested a review from jkotas November 24, 2026 17:22
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@lewing
lewing enabled auto-merge (squash) November 24, 2026 18:56
@lewing
lewing merged commit 70a7d51 into dotnet:main Nov 24, 2026
99 of 101 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

crossgen2 --partial omits managed JIT helpers from CoreLib R2R image on no-JIT targets

3 participants