[Wasm RyuJit] Codegen labels#122332
Merged
AndyAyersMS merged 3 commits intodotnet:mainfrom Dec 10, 2025
Merged
Conversation
Create emitter labels for places Wasm will branch to, and display the instr group branch targets as comments when dumping out disassembly.
Member
Author
|
@dotnet/jit-contrib PTAL Provide annotations on the various Wasm branches to indicate their target (since they just show the depth in the control flow stack). See the We might be able to get by with more "lightweight" labels since we don't need to have the emitter do any GC tracking. ; Method Program:<<Main>$>g__Foo|0_0(int,int):int (FullOpts)
G_M10749_IG01: ;; offset=0x0000
;; size=0 bbWeight=1 PerfScore 0.00
G_M10749_IG02: ;; offset=0x0000
02 | block
02 | block
28 00 04 | i32.load 1 4
41 00 | i32.const 0
4C | i32.le_s
0D 00 | br_if 0 ;; G_M10749_IG04
;; size=10 bbWeight=1 PerfScore 6.00
G_M10749_IG03: ;; offset=0x000A
28 00 00 | i32.load 1 0
41 00 | i32.const 0
4A | i32.gt_s
0D 01 | br_if 1 ;; G_M10749_IG07
0B | end
;; size=9 bbWeight=0.50 PerfScore 2.50
G_M10749_IG04: ;; offset=0x0013
28 00 04 | i32.load 1 4
28 00 00 | i32.load 1 0
6A | i32.add
;; size=7 bbWeight=0.50 PerfScore 1.50
G_M10749_IG05: ;; offset=0x001A
0F | return
;; size=1 bbWeight=0.50 PerfScore 0.50
G_M10749_IG06: ;; offset=0x001B
0B | end
;; size=1 bbWeight=0.50 PerfScore 0.50
G_M10749_IG07: ;; offset=0x001C
41 03 | i32.const 3
;; size=2 bbWeight=0.50 PerfScore 0.50
G_M10749_IG08: ;; offset=0x001E
0F | return
;; size=1 bbWeight=0.50 PerfScore 0.50
; Total bytes of code: 31 |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR implements codegen label support for WebAssembly RyuJIT. The changes enable the emitter to create and track labels for branch targets, and display branch target information as comments when dumping disassembly.
Key Changes
- Added
emitIns_Jfunction to emit jump instructions with target block information - Introduced
_idJumpbitfield flag to instrDesc for tracking jump instructions - Implemented IF_LABEL instruction format output (previously NYI_WASM)
- Enhanced disassembly display to show branch target labels as comments
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/coreclr/jit/emitwasm.h | Added declaration for new emitIns_J function |
| src/coreclr/jit/emitwasm.cpp | Implemented emitIns_J, removed NYI_WASM for IF_LABEL, added jump target display logic, fixed brace formatting |
| src/coreclr/jit/emit.h | Added _idJump bitfield and helper methods, updated bit count comments |
| src/coreclr/jit/codegenwasm.cpp | Added label marking for loops and block ends, updated calls to use emitIns_J, fixed comment typo |
SingleAccretion
approved these changes
Dec 9, 2025
Member
Author
|
spmi failures |
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.
Create emitter labels for places Wasm will branch to, and display the instr group branch targets as comments when dumping out disassembly.