Skip to content

Conversation

@adamperlin
Copy link
Contributor

@adamperlin adamperlin commented Dec 11, 2025

This PR adds a new instrDesc subtype for encoding Wasm local declarations, which have the form count: u32 type:valtype, where valtype can be encoded as a single byte for number and vector types.

The PR also adds code to emit local count and local declarations as part of the prolog for a function. Some of this may need to change based on what we decide around calling convention and register (locals) allocation.

Copilot AI review requested due to automatic review settings December 11, 2025 00:53
@github-actions github-actions bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Dec 11, 2025
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 introduces support for WebAssembly local variable declarations in the JIT compiler by adding a new instruction descriptor subtype and emission logic for encoding local declarations in the function prolog.

Key Changes

  • Adds instWasmValueType enum and mapping functions to convert between JIT types and WASM types
  • Introduces instrDescLclVarDecl instruction descriptor for encoding local declarations with count and type
  • Implements local declaration emission in the function prolog via genWasmLocals()

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
src/coreclr/jit/wasmtypesdef.h New header defining WASM value types and type conversion functions
src/coreclr/jit/registeropswasm.h Removes trailing blank line
src/coreclr/jit/instrswasm.h Adds local_cnt and local_decl instructions
src/coreclr/jit/emitwasm.h Declares new emission methods for local declarations
src/coreclr/jit/emitwasm.cpp Implements local declaration emission and descriptor handling
src/coreclr/jit/emitfmtswasm.h Adds IF_LOCAL_CNT and IF_LOCAL_DECL instruction formats
src/coreclr/jit/emit.h Adds instrDescLclVarDecl structure and bitfield flag
src/coreclr/jit/codegenwasm.cpp Adds INS_end instruction to epilog
src/coreclr/jit/codegencommon.cpp Implements prolog local count and declaration emission
src/coreclr/jit/codegen.h Declares genWasmLocals() method

@am11 am11 added the arch-wasm WebAssembly architecture label Dec 17, 2025
@dotnet-policy-service
Copy link
Contributor

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

adamperlin and others added 2 commits December 16, 2025 17:56
Copy link
Member

@AndyAyersMS AndyAyersMS left a comment

Choose a reason for hiding this comment

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

Mostly looks good, just one issue with the epilog.

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.

Looking pretty good! Just a few comments.

@adamperlin
Copy link
Contributor Author

Mostly looks good, just one issue with the epilog.

@AndyAyersMS thanks for catching that. This should be fixed now if you'd like to take another look!

Copy link
Member

@AndyAyersMS AndyAyersMS left a comment

Choose a reason for hiding this comment

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

Looks good!

@AndyAyersMS
Copy link
Member

AndyAyersMS commented Dec 17, 2025

Looks like superpmi diffs is just generally broken in CI (nothing to do with this PR). Let me see if I can figure out why.

Failing log entry

[13:50:40] Using JIT/EE Version from mcs: d1188f9b-d81e-487a-b525-cedb10d15c8e
Error: JIT not found at diff_jit_path /tmp/helix/working/B83F0A11/p/diff/checked/libclrjit_unix_arm64_arm64.dylib

It should be looking for libclrjit_universal_arm64_arm64.dylib... wonder if I broke this with my SPMI script changes for wasm.

@AndyAyersMS
Copy link
Member

I am going to cherry-pick my script fix into your PR if that's ok.

@adamperlin
Copy link
Contributor Author

I am going to cherry-pick my script fix into your PR if that's ok.

Yes that is fine! Thanks for investigating that failure!

@adamperlin adamperlin merged commit 43a85ea into dotnet:main Dec 18, 2025
120 of 122 checks passed
@adamperlin adamperlin deleted the adamperlin/wasm-arg-initialization branch December 18, 2025 00:42
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.

4 participants