Skip to content

Conversation

@AndyAyersMS
Copy link
Member

Create emitter labels for places Wasm will branch to, and display the instr group branch targets as comments when dumping out disassembly.

Create emitter labels for places Wasm will branch to, and display the
instr group branch targets as comments when dumping out disassembly.
Copilot AI review requested due to automatic review settings December 9, 2025 02:48
@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 9, 2025
@AndyAyersMS
Copy link
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 br_if below.

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

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 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_J function to emit jump instructions with target block information
  • Introduced _idJump bitfield 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

@am11 am11 added the arch-wasm WebAssembly architecture label Dec 9, 2025
Copy link
Member

@JulieLeeMSFT JulieLeeMSFT left a comment

Choose a reason for hiding this comment

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

LGTM.

@AndyAyersMS
Copy link
Member Author

spmi failures

Running: git fetch --depth=500 origin main
fatal: unable to access 'https://github.com/dotnet/runtime/': Connection timed out after 300046 milliseconds

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