You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 3d26705
Browse filesBrowse the repository at this point in the historyBrowse files
<!-- -->
Fixes browser-Wasm CoreCLR ReadyToRun failures introduced after #133218
while preserving shared `U`, `UG`, and `UM` unboxing stubs and almost
all of their binary-size benefit.
## Corrected root-cause analysis
The initial version of this PR replaced `U`/`UG` with per-method managed
thunks based on an ABI-mismatch hypothesis. That approach and its
portable-prestub changes have been removed. The revised patch does not
change the shared-stub calling conventions or lookup keys.
NESM inspection stopped immediately before the failing Test23
`call_indirect`: the call expected five `i32` parameters, but the
selected table slot was zero (a null function reference). The expected
parameter count alone did not establish a `U` versus `UG` mismatch. The
observed delay-load fixup resolved to a non-unboxing shared target
requiring a generic context, whose portable entrypoint lacked an
R2R-to-interpreter adapter such as `IvTiS1p`.
Replacing a compiled per-method unboxing thunk with a structural
assembly stub lost dependencies previously introduced by compiling the
thunk's managed body. There are two distinct transitions:
- **Interpreter -> unboxing stub:** needs an `M` adapter for the full
managed unboxing signature, for example `MS56Tp`.
- **Unboxing stub -> target:** needs an `I` adapter for the target
signature, including its generic context where applicable, for example
`IS56Tip` or `IvTiS1p`, so its portable entrypoint is callable before
the target's native body is published.
Structural sharing also allows the runtime to find a shared stub for a
generic instantiation Crossgen2 never compiled. A matching Wasm function
shape does not imply that the exact managed transition cookie exists:
different struct sizes can share the same structural stub but require
different interpreter adapters. The actual `GitHub_19361` execution
exposed this case with a missing `MS56Tp` cookie.
## Changes
- Add a per-target dependency node retaining the shared stub, compiled
target, interpreter-to-R2R adapter for the unboxing signature, and
R2R-to-interpreter adapter for the target signature.
- Keep these dependencies per managed target rather than on the
structurally shared node, so signatures with the same Wasm shape but
different managed layouts retain their distinct adapters.
- Before publishing a shared unboxing stub, require the exact incoming
interpreter cookie and callable code in the target portable entrypoint.
An installed R2R-to-interpreter adapter counts as callable code; this
does not require a precompiled native target body.
- If either transition is unavailable, use the existing interpreted
IL-stub fallback. R2R callers independently root their call-signature
`I` adapters through the existing call-site recording machinery.
- Extend the existing Wasm generic-dispatch tests with a 56-byte struct
return alongside the 16-byte case, checking distinct adapters while
retaining the original shared-stub assertions.
## Evidence and validation
Browser-Wasm **Release CoreCLR under Node.js 26.4.0**, with explicitly
regenerated and Wasm-validated CoreLib, LINQ, and test images:
| Runtime case | Actual execution evidence | Result |
|---|---|---|
| `LoaderClassloaderGenerics`, `DisplayName~genrecur.dll` | `Test23 OK`,
matching `Passed test` line | Exit 100 |
| `Regressions`, `DisplayName~genrecur.dll` | `Test23 OK`, matching
`Passed test` line | Exit 100 |
| `Regression_NoOptimize_r_1`, `Repro.Program.TestEntryPoint` |
`Starting stress loop`, `Result: Completed Normally`, matching `Passed
test` line | Exit 100 |
The earlier `GitHub_19361` name filter matched no test; earlier success
claims using that filter were invalid. The results above use the actual
fully qualified method name and confirm that the stress loop executed.
Earlier stale CoreLib images were also replaced explicitly rather than
relying on layout generation to refresh them.
Additional validation:
- Browser Release runtime and corerun build: succeeded.
- Wasm `ILCompiler.ReadyToRun.Tests`: 75 passed, 37 target-inapplicable
skips.
- Host macOS arm64 generic-dispatch tests: 3 passed, 2 Wasm-only skips.
- Negative dependency checks: removing only `I(target)` fails on missing
`IS16Tip`; removing only `M(unboxing)` fails on missing `MS56Tp`.
Restoring both passes.
The full CI outer-loop matrix and a browser-hosted run have not been
rerun locally.
## Binary size
Optimized browser `System.Private.CoreLib` images using `--optimize
--generate-unboxing-stubs` in the local comparison:
| Variant | Bytes |
|---|---:|
| Earlier fully shared prototype | 26,991,640 |
| Revised shared stubs with transition dependencies | 26,993,234 |
| Superseded per-method `U`/`UG` fallback | 27,387,567 |
The revised image adds **1,594 bytes** over the earlier fully shared
prototype and saves **394,333 bytes** compared with the superseded
fallback, retaining approximately **99.6%** of the size reduction in
that comparison. This supersedes the initial description's claim that
the fix gives back nearly the entire saving.
Fixes#133491
> [!NOTE]
> This pull request description and investigation summary were generated
with GitHub Copilot.
---------
Co-authored-by: Copilot App <[email protected]>
Copy file name to clipboardExpand all lines: src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/WasmUnboxingStubNode.cs
0 commit comments