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
ReadyToRun Wasm images contain many methods with exactly identical emitted function bodies. Emitting each copy independently increases download size and leaves no shared compiler representation that could later support broader folding.
A recent retail System.Private.CoreLib.wasm measurement found 1,879 signature-compatible exact-body groups containing 7,568 redundant bodies, representing roughly 342 KB of Code-section bytes before accounting for method-identity constraints.
Proposed change
Add exact method-body deduplication at the ReadyToRun dependency-analysis layer rather than in the Wasm object writer.
The initial implementation should fold only methods whose emitted body, relocations, signature requirements, and runtime identity requirements are exactly compatible. The abstraction should permit future extension to methods with equivalent GC information; placing the decision in the object writer would make that substantially harder.
The design must preserve required R2R method-index, entrypoint, stack-walking, EH, and MethodDesc behavior.
Validation
Add focused dependency-analysis tests where practical.
Build CoreCLR browser/Wasm in Release.
Verify folded methods share the intended implementation without losing required method metadata.
Compare function counts, Code-section size, startup, and focused execution.
Activity
dotnet-policy-service commentedon Sep 24, 2026
Tagging subscribers to this area: @dotnet/crossgen-contrib
See info in area-owners.md if you want to be subscribed.
Deduplicate identical Wasm method bodies (#134623)