Skip to content

[Wasm RyuJIT] Call signatures#125153

Merged
kg merged 14 commits intodotnet:mainfrom
kg:wasm-callsigs-1
Mar 9, 2026
Merged

[Wasm RyuJIT] Call signatures#125153
kg merged 14 commits intodotnet:mainfrom
kg:wasm-callsigs-1

Conversation

@kg
Copy link
Member

@kg kg commented Mar 3, 2026

This gets us generating valid modules for my set of test scenarios by generating correct call signatures.

EDIT: With this PR, the generated code for i.e. a gc write barrier helper call looks like:

@1075  2004           ..get_local 4 ; i32 local0
@1077  4100           ..i32_const 0
@1079  6A             ..i32_add
@1080  2005           ..get_local 5 ; i32 local1
@1082  4100           ..i32_const 0
@1084  6A             ..i32_add
@1085  2301           ..get_global 1 ; i32 env.__r2r_start
@1087  41B8818802     ..i32_const 0x004200B8 ; 4325560
@1092  6A             ..i32_add
@1093  280000         ..i32_load +0
@1096  11818080800000 ..call_indirect 1 tables[0] ; v(ii)

Note that we're missing support for address relocations in crossgen so I just emit the raw truncated helper address value as a displacement against __r2r_start.

Copilot AI review requested due to automatic review settings March 3, 2026 23:12
@kg kg added arch-wasm WebAssembly architecture area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI labels Mar 3, 2026
@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the WASM RyuJIT emitter to provide real call-indirect signatures by deriving argument lowering from method handles and by hard-coding signatures for certain runtime helpers, then passing those signatures to the JIT↔EE getWasmTypeSymbol API.

Changes:

  • Build a CorInfoWasmType signature array for emitIns_Call when params.methHnd is available.
  • Special-case a set of helper calls (detected via eeGetHelperNum) with hard-coded signatures.
  • Use the computed signature to obtain a CORINFO_WASM_TYPE_SYMBOL_HANDLE for call_indirect.

Copilot AI review requested due to automatic review settings March 4, 2026 22:12
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.

@kg kg force-pushed the wasm-callsigs-1 branch from 849e123 to 89ec13b Compare March 5, 2026 20:48
Copilot AI review requested due to automatic review settings March 5, 2026 20:53
@kg kg marked this pull request as ready for review March 5, 2026 20:54
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

@kg
Copy link
Member Author

kg commented Mar 5, 2026

Found an oversight, working on it.
EDIT: Addressed it

@kg
Copy link
Member Author

kg commented Mar 5, 2026

@dotnet/jit-contrib I think this is ready for review now and gets us generating valid modules for all the cases I've tested. It also gets us closer to generating the right code.

Copy link
Contributor

@SingleAccretion SingleAccretion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM modulo comments.

Copilot AI review requested due to automatic review settings March 6, 2026 15:56
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Copy link
Contributor

@adamperlin adamperlin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me, just two questions!

@kg kg merged commit d19b7ca into dotnet:main Mar 9, 2026
131 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arch-wasm WebAssembly architecture area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants