Skip to content

JIT: elide redundant wasm Virtual IP updates - #131688

Open
AndyAyersMS wants to merge 1 commit into
dotnet:mainfrom
AndyAyersMS:wasm-vip-dedup
Open

JIT: elide redundant wasm Virtual IP updates#131688
AndyAyersMS wants to merge 1 commit into
dotnet:mainfrom
AndyAyersMS:wasm-vip-dedup

Conversation

@AndyAyersMS

Copy link
Copy Markdown
Member

fgWasmVirtualIP stored the frame's Virtual IP at the start of every non-empty block. Most stores are redundant: consecutive blocks in the same EH region require the same value. Record the value each block requires during the region walk, then solve a forward available-Virtual-IP dataflow and emit a store only where the value is not already on the frame on every path in (cross-func EH returns and function entries force a store). Reduces the wasm R2R code section of System.Private.CoreLib by ~1.76 MB (~9.7%).

fgWasmVirtualIP stored the frame's Virtual IP at the start of every non-empty
block. Most stores are redundant: consecutive blocks in the same EH region
require the same value. Record the value each block requires during the region
walk, then solve a forward available-Virtual-IP dataflow and emit a store only
where the value is not already on the frame on every path in (cross-func EH
returns and function entries force a store). Reduces the wasm R2R code section
of System.Private.CoreLib by ~1.76 MB (~9.7%).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 89caa9c8-5b0f-4fcc-a8c4-726ac8535110
Copilot AI review requested due to automatic review settings August 1, 2026 01:02
@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 Aug 1, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 6 pipeline(s).
10 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@AndyAyersMS

Copy link
Copy Markdown
Member Author

@adamperlin PTAL
fyi @dotnet/wasm-contrib

Local testing including some contrived EH looks good. But I will probably hold off merging this until the CI testing is enabled.

@AndyAyersMS
AndyAyersMS requested a review from adamperlin August 1, 2026 01:04
@AndyAyersMS AndyAyersMS added the arch-wasm WebAssembly architecture label Aug 1, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 refines the WASM JIT “Virtual IP” update logic to avoid emitting redundant frame stores by computing, per basic block, which Virtual IP value is required and then running a forward dataflow analysis to determine whether that value is already available on all incoming paths.

Changes:

  • Records per-block required Virtual IP (and whether a store is required) while walking regions/blocks.
  • Runs a forward “available Virtual IP” dataflow merge to compute availableIn/availableOut and elide stores when the needed value is already on-frame on all incoming paths.
  • Emits Virtual IP frame updates only at blocks where availableIn != requiredVip, and invalidates the DFS tree after DataFlow::ForwardAnalysis so later WASM phases recompute their own traversal data.

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.

2 participants