Repository navigation
Eagerly resolve intrinsic ReadyToRun type handles and arrays - #135806
Merged
davidwrighton merged 5 commits intoOct 19, 2026
Merged
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Azure Pipelines: Successfully started running 4 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. |
Contributor
|
Tagging subscribers to this area: @dotnet/crossgen-contrib |
davidwrighton
marked this pull request as ready for review
October 14, 2026 22:16
davidwrighton
requested review from
jtschuster
and
a balanced review from Copilot
October 14, 2026 22:16
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Eager array resolution can violate the VM’s type-loading guard and assert during non-CoreLib module loading on Checked/Debug runtimes.
1 open finding
What changed in this PR
Moves intrinsic ReadyToRun type-handle imports, including arrays, from per-method fixups to module-eager resolution in crossgen2.
Changes:
- Selects eager imports for intrinsic types and nested arrays.
- Adds optimized/unoptimized and regular/composite image-validation coverage.
- Documents eager import placement and dependency retention.
Builds and runtime tests were not run during this review.
| File | Description |
|---|---|
| src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRunSymbolNodeFactory.cs | Selects eager intrinsic type-handle imports. |
| src/coreclr/tools/aot/ILCompiler.ReadyToRun.Tests/TestCases/Webcil/WasmWebcilModule.cs | Adds intrinsic and token-dependent type fixtures. |
| src/coreclr/tools/aot/ILCompiler.ReadyToRun.Tests/TestCases/R2RTestSuites.cs | Verifies import placement, uniqueness, and method fixups. |
| docs/design/coreclr/botr/readytorun-format.md | Documents the eager type-handle rule. |
🧠 Review effort: Balanced
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
jkotas
reviewed
Oct 15, 2026
This was referenced Oct 15, 2026
Only eagerly resolve direct SZ arrays over intrinsic elements in images that compile CoreLib. Leave multidimensional and jagged arrays lazy. Check each expected type's import and method fixup independently so legitimate RuntimeTypeHandle signature fixups do not fail the unoptimized theory cases. Extend array-shape coverage. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
jkotas
approved these changes
Oct 15, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: d46c9015-c682-46e1-ba8d-4c38af3c6c05
jkotas
approved these changes
Oct 19, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 10d80301-646f-4535-ade2-60e9b5364796
jkotas
approved these changes
Oct 19, 2026
This was referenced Oct 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Description
Extract the independent eager intrinsic type-handle change from #135553 onto
main.Place concrete
TYPE_HANDLEimports for built-in types encoded directly byCorElementType, includingstring,object, andTypedReference, in module-eager import sections. Apply the same rule to arrays of those types, including multidimensional and nested arrays. Enums, other token-dependent types, pointers, and byrefs retain their existing handling.Only imports reached by the final dependency traversal are emitted; this does not root a predefined inventory of intrinsic types. Eager cells are resolved at module load instead of appearing in per-method fixup lists.
Current main already provides the supporting behavior:
classMustBeLoadedBeforeCodeIsRunretains eager type handles through additional dependencies, and the eager import section disables precode emission for relocation-derived method fixups. No two-phase/transitive-fixup machinery or extra dependency adaptation is needed for this extraction.This changes common crossgen2 import selection, not just Wasm. Add a regression theory covering optimized/unoptimized and regular/composite compilation, checking exact intrinsic import placement and uniqueness, omission from method fixup lists, and retention of non-eager token-dependent type fixups. Document the eager type-handle rule.
Source commit:
eaec645e68f16afacf80aecb3941edd93d3e69f1. This PR does not include two-phase compilation, direct calls, or the prolog/frame-identity changes.Historical size measurements and tradeoff
These matched before/after Wasm measurements were collected on the original development branch, not on this newly extracted/rebased PR. The recorded JIT hashes and input hashes match between baseline and updated builds. Brotli used quality 11 and window 22.
These are historical size measurements, not throughput benchmarks or a guarantee of equivalent savings on current main. This trades per-method fixup work and storage for module-eager type resolution; no new startup-latency measurements were collected for this extraction.
Validation
git diff --check upstream/main...split/r2r-intrinsic-eager— passed.This remains a draft; build and runtime validation on the independent branch are outstanding.
Note
This PR was prepared with GitHub Copilot.