Repository navigation
Description
Description
Under profile-guided partial compilation (--partial), browser CoreCLR ReadyToRun composites leave out every managed JIT helper that the profile doesn't list. That breaks the rule @jkotas set out in #136050 (comment):
- R2R code outside CoreLib can be used only when CoreLib is R2R too
- CoreLib R2R image must contain code for all JIT helpers
Since #134356, browser publishes pass --partial whenever PublishReadyToRunPgoFiles is non-empty, which includes the default StandardOptimizationData.mibc. When the restriction is set, ReadyToRunSingleAssemblyCompilationModuleGroup.ContainsMethodBodyCore rejects every method missing from the profile. On no-JIT targets the only exemption is HardwareIntrinsicHelpers.IsHardwareIntrinsic. As a result, the helpers rooted by ReadyToRunJitHelperRootProvider are dropped.
In a default CI-style publish of System.Runtime.Intrinsics.Tests (browser-wasm CoreCLR, Release, TestWasmReadyToRun=true, aggressive trimming, default MIBC + --partial), crossgen2's --map output shows the composite compiles 1,229 CoreLib methods but none of the 70 managed JIT helpers. Among them:
CastHelpers.*SpanHelpers.Memmove/Fill/ClearWithoutReferences- the
StaticsHelpersstatics-base helpers RuntimeTypeHandle.GetRuntimeTypeFromHandleInitHelpers.*Mathdivision and overflow helpers
Memmove and ClearWithoutReferences are even called through DelayLoad_MethodCall imports.
R2R code reaches these through helper cells. The runtime resolves them to the helper's interpreter PortableEntryPoint, which works only if some loaded image happens to supply an R2R-to-interpreter thunk for that signature. When none does, _pActualCode stays null and the call traps.
Reproduction Steps
- Build the browser baseline:
./build.sh -arch wasm -os browser -s clr+libs+host+packs -c Release. - Use
dotnet-pgo create-mibc-from-method-listto build a profile containing onlySystem.Runtime.Intrinsics.Wasm.Tests.PackedSimdTests.PackedSimdIsSupported. - Publish and run that test with
/p:UseMibcProjectReference=falseand/p:PublishReadyToRunCrossgen2ExtraArgs=--partial;--mibc:<that file>, using the same browser R2R settings as above.
Expected behavior
CoreLib's R2R image contains code for every managed JIT helper, whatever the profile says, and the test runs.
Actual behavior
The test fails with RuntimeError: null function at the first call_indirect in PackedSimdIsSupported. That call goes through the eager READYTORUN_HELPER_GetRuntimeTypeHandle cell for typeof(PackedSimd). At the trap, the helper's PortableEntryPoint has:
_pActualCode= 0_pInterpreterDatasetkPrefersInterpreterEntryPointset
The image has no WasmR2RToInterpreterThunk(iTip), and the method stays on the runtime's pending-thunk list. Adding System.RuntimeTypeHandle.GetRuntimeTypeFromHandle to the profile makes the test pass.
The default profile doesn't hit this today, but only because the thunks it needs happen to be generated for other call sites.
Regression?
Yes, starting with #134356 (profile-guided partial ReadyToRun for browser CoreCLR). Before that change browser publishes didn't use --partial, so the profile restriction was never set and the rooted helpers were compiled.
Known Workarounds
Disable PGO (/p:EnableNgenOptimization=false), or list the needed helpers in the profile.
Configuration
browser-wasm, CoreCLR, Release, composite ReadyToRun with --partial. The same filter applies to any no-JIT target using partial compilation.
Other information
Suggested fix: on targets that can't JIT, exempt the managed JIT helper methods (those from ReadyToRunJitHelperRootProvider) from the partial-profile restriction in ContainsMethodBodyCore, the same way hardware intrinsics are exempt today. The fix should also confirm BubbleIncludesCoreModule holds for these composites, since the helper root provider is only added then.
Generating helper-signature R2R-to-interpreter thunks in crossgen2 instead was considered and dropped in #136050 in favor of the rule above.
Related: #138182 / #138183 add a similar partial-profile exemption for the Vector*.IsHardwareAccelerated getters.
Note
This issue was drafted with GitHub Copilot.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
dotnet-policy-service commentedon Nov 24, 2026
Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara
See info in area-owners.md if you want to be subscribed.
Compile managed JIT helpers in partial no-JIT compilations
dotnet-policy-service commentedon Nov 24, 2026
Tagging subscribers to this area: @dotnet/crossgen-contrib
See info in area-owners.md if you want to be subscribed.
Compile managed JIT helpers in partial no-JIT ReadyToRun compilations (…