Skip to content

Conversation

@AndyAyersMS
Copy link
Member

No description provided.

Copilot AI review requested due to automatic review settings December 10, 2025 16:30
@AndyAyersMS
Copy link
Member Author

@dotnet/jit-contrib PTAL

@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 10, 2025
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!

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 adds support for local variable stores in the WebAssembly RyuJIT backend by implementing the GT_STORE_LCL_VAR operation. It introduces new WASM instructions for storing values (i32.store, i64.store, f32.store, f64.store) and the local.set instruction for register candidates.

Key changes:

  • Added WASM store instructions and local.set instruction definition
  • Implemented ins_Store function for WASM to map types to appropriate store instructions
  • Implemented genCodeForStoreLclVar to generate code for storing to local variables

Reviewed changes

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

File Description
src/coreclr/jit/instrswasm.h Adds instruction definitions for local.set and memory store instructions (i32.store, i64.store, f32.store, f64.store) with correct WASM opcodes
src/coreclr/jit/instr.cpp Implements WASM-specific ins_Store function to map variable types to appropriate store instructions
src/coreclr/jit/codegenwasm.cpp Adds GT_STORE_LCL_VAR case handler and implements genCodeForStoreLclVar to emit appropriate instructions for both register candidates and stack-based variables

@jkotas jkotas added the arch-wasm WebAssembly architecture label Dec 10, 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.

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.

I was too hasty to approve here, apologies. I was forgetting that the emitIns_S encoding will not work for stores. As SingleAccretion pointed out, the stack must be:

<target>
<value> <- top

and the store itself (I believe) should just be encoded as a single opcode. @SingleAccretion could you potentially explain a bit more how RA will handle the placement of store arguments on the stack?

@AndyAyersMS
Copy link
Member Author

Guessing we'll rewrite this during RA as a different OP that will have two operands so we can get the stack ordering right.

@SingleAccretion
Copy link
Contributor

Guessing we'll rewrite this during RA as a different OP that will have two operands so we can get the stack ordering right.

Correct. It'll rewrite STORE_LCL_VAR to STOREIND(LCL_VAR_ADDR, value).

@AndyAyersMS
Copy link
Member Author

Speaking of RA, seems like this is something we'll need fairly soonish if we want to run even simple examples. Given the "unlimited" register set of Wasm, it also seems like (parts of it) should be relatively straightforward. @SingleAccretion is this something on your todo list...?

@SingleAccretion
Copy link
Contributor

is this something on your todo list...?

Yes, I am working on it. A lot of time spent on reviews though :).

@AndyAyersMS
Copy link
Member Author

@adamperlin you ok with this now? You need to approve.

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. I just had a question about the relationship between being a register candidate and a wasm local, but I don't think that's blocking!

@AndyAyersMS AndyAyersMS merged commit 1981b5f into dotnet:main Dec 11, 2025
123 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Jan 11, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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