Skip to content

Require matching WASM function types when folding method bodies - #135949

Merged
MichalStrehovsky merged 3 commits into
dotnet:mainfrom
MichalStrehovsky:nativeaot-wasm-method-folding
Oct 19, 2026
Merged

MichalStrehovsky merged 3 commits into
dotnet:mainfrom
MichalStrehovsky:nativeaot-wasm-method-folding

Conversation

@MichalStrehovsky

Copy link
Copy Markdown
Member

Summary

Require matching lowered WASM function types before folding NativeAOT method bodies.

Identical instruction bytes do not imply identical WASM signatures: methods can have different unused parameters. An address-taken method's forwarding stub passes its parameters to the folded target, making the module invalid if the target's function type differs.

Compare the lowered function types, including hidden ABI parameters, as part of method-body equality on WASM. Existing body/relocation comparisons and non-WASM behavior are unchanged.

Validation

On the combined local NativeAOT WASI bringup tree, including other unmerged enablement:

  • .\build.cmd clr.tools -rc Checked -lc Release -os wasi -arch wasm passed.
  • Forced regeneration of AttributeTrimming and Determinism passed; both executed under Wasmtime with exit code 100.
  • Determinism's parallel and single-threaded compiler outputs were identical.

This branch contains only this cherry-picked commit from main; it was not built independently. The smoke tests are not a claim of general WASM runtime correctness.

Note

This PR description was generated by GitHub Copilot.

Identical bodies can have different WASM function types when parameters
are unused. An address-taken method's jump stub forwards its parameters
to the folded body, producing invalid WASM if their signatures differ.

Compare lowered function types before folding on WASM. This accounts for
hidden ABI parameters and leaves other architectures unchanged.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: a6f3a617-acae-4f4f-95d3-20b2a0bac43c
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara
See info in area-owners.md if you want to be subscribed.

1 similar comment
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara
See info in area-owners.md if you want to be subscribed.

@azure-pipelines

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

@MichalStrehovsky
MichalStrehovsky merged commit 28214e7 into dotnet:main Oct 19, 2026
100 of 102 checks passed
@MichalStrehovsky
MichalStrehovsky deleted the nativeaot-wasm-method-folding branch October 19, 2026 10:57
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arch-wasm WebAssembly architecture area-NativeAOT-coreclr

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants