Repository navigation
Add support for generalized variable length wasm instructions to the emitter - #125862
Merged
davidwrighton merged 2 commits intoMar 23, 2026
Merged
davidwrighton merged 2 commits into
davidwrighton merged 2 commits into
Conversation
Contributor
|
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the WASM JIT instruction encoding to support spec-style prefixed opcodes with variable-length (ULEB128) sub-opcodes, enabling instruction definitions to match the WebAssembly opcode format rather than a packed 2-byte representation.
Changes:
- Introduce an
INST2(prefix, opcode)instruction-table form for WASM prefixed instructions. - Update the WASM emitter to output prefixed opcodes as
prefix-byte + ULEB128(subopcode)and size them accordingly. - Wire
INST2through existing instruction enum/name/info/format/opcode tables.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/coreclr/jit/instrswasm.h | Adds INST2 usage for prefixed WASM instructions (e.g., 0xFC-prefixed ops) and enforces INST2 definition. |
| src/coreclr/jit/instr.h | Extends WASM instruction enum generation to accept INST2. |
| src/coreclr/jit/instr.cpp | Extends WASM instruction name table generation to accept INST2. |
| src/coreclr/jit/emitwasm.cpp | Adds prefix/subopcode tables and emits prefixed opcodes as prefix + ULEB128; updates sizing and an emission site to use the new opcode output helper. |
AndyAyersMS
approved these changes
Mar 20, 2026
AndyAyersMS
left a comment
Member
There was a problem hiding this comment.
LGTM, just one comment you might consider.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
My previous fix only made 2 byte instructions work, but in theory wasm can have larger variable sized instructions. This change allows us to define the instructions in the same format that the spec defines them, and supports emitting any of them (as long as the variable sized opcode fits in a uint16_t which should be good enough for now.