Skip to content

JIT: always home register params on wasm#130446

Merged
AndyAyersMS merged 6 commits into
dotnet:mainfrom
AndyAyersMS:wasm-home-register-params
Jul 12, 2026
Merged

JIT: always home register params on wasm#130446
AndyAyersMS merged 6 commits into
dotnet:mainfrom
AndyAyersMS:wasm-home-register-params

Conversation

@AndyAyersMS

@AndyAyersMS AndyAyersMS commented Jul 10, 2026

Copy link
Copy Markdown
Member

Always home the live params on Wasm (we do not produce or rely on the calleeRegArgMaskLiveIn). Initialize this anyways to avoid random behavior in case somebody does look at it.

Addresses the caller-side this-drop blocker in #129850.

SuperPMI (corelib crossgen2, browser): +28 bytes / 4 contexts / 0.00%.

Note

This change was authored with the assistance of GitHub Copilot.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 10, 2026 00:13
@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 Jul 10, 2026

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 fixes a wasm-specific prolog correctness issue where register-parameter homing could be skipped due to calleeRegArgMaskLiveIn not being populated on wasm (since wasm uses WasmRegAlloc rather than LSRA). The change makes wasm always invoke genHomeRegisterParams during prolog generation and updates wasm’s homing filter to use ref-counts instead of entry liveness.

Changes:

  • In genFnProlog, always call genHomeRegisterParams under TARGET_WASM instead of gating on calleeRegArgMaskLiveIn.
  • In wasm genHomeRegisterParams, switch the “spill / don’t spill” decision from fgFirstBB->bbLiveIn to lvRefCnt().

Reviewed changes

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

File Description
src/coreclr/jit/codegenwasm.cpp Changes wasm parameter-homing eligibility check to use ref-counts rather than entry liveness.
src/coreclr/jit/codegencommon.cpp Makes wasm prolog always home register params, bypassing the calleeRegArgMaskLiveIn gate used for LSRA-based targets.

Comment thread src/coreclr/jit/codegencommon.cpp Outdated
Comment thread src/coreclr/jit/codegenwasm.cpp Outdated
…wasm

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 10, 2026 00:40

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

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

@AndyAyersMS AndyAyersMS requested a review from adamperlin July 10, 2026 00:49
@AndyAyersMS

Copy link
Copy Markdown
Member Author

@adamperlin PTAL
@dotnet/wasm-contrib FYI

This gets us bit farther through SPC bring up.

Comment thread src/coreclr/jit/codegencommon.cpp Outdated
@pavelsavara pavelsavara added the arch-wasm WebAssembly architecture label Jul 10, 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.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

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

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

Comment thread src/coreclr/jit/codegencommon.cpp
Comment thread src/coreclr/jit/codegenwasm.cpp Outdated
Comment thread src/coreclr/jit/codegenwasm.cpp Outdated
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 10, 2026 18:17

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

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

Comment thread src/coreclr/jit/codegenwasm.cpp
Comment thread src/coreclr/jit/codegencommon.cpp
@AndyAyersMS

Copy link
Copy Markdown
Member Author

Looks like we still have some older versions of node out there?

Console log: 'Directed_2' from job baee6d6c-7469-4026-9784-a026a91fe247 (azurelinux.3.amd64.open.rt) using docker image mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-26.04-helix-webassembly-amd64@sha256:3ef1314b50ac039078f6406d649d5ac72715deccd07bcbfe3dd43fa438be3fbd on a00LCE7
...
Running: node --stack-size=8192 /root/helix/work/correlation/corerun.js -c /root/helix/work/correlation /root/helix/work/workitem/e/JIT/Directed/Directed_2/Directed_2.dll
failed to asynchronously prepare wasm: CompileError: WebAssembly.instantiate(): invalid value type 'exn', enable with --experimental-wasm-exnref @+58
warning: Loading from a file URI (file:///root/helix/work/correlation/corerun.wasm) is not supported in most browsers. See https://emscripten.org/docs/getting_started/FAQ.html#how-do-i-run-a-local-webserver-for-testing-why-does-my-program-stall-in-downloading-or-preparing
Aborted(CompileError: WebAssembly.instantiate(): invalid value type 'exn', enable with --experimental-wasm-exnref @+58)
file:///root/helix/work/correlation/corerun.js:461
  /** @suppress {checkTypes} */ var e = new WebAssembly.RuntimeError(what);
                                        ^

RuntimeError: Aborted(CompileError: WebAssembly.instantiate(): invalid value type 'exn', enable with --experimental-wasm-exnref @+58)
    at abort (file:///root/helix/work/correlation/corerun.js:461:41)
    at instantiateArrayBuffer (file:///root/helix/work/correlation/corerun.js:530:5)
    at async createWasm (file:///root/helix/work/correlation/corerun.js:608:16)
    at async createDotnetRuntime (file:///root/helix/work/correlation/corerun.js:7517:15)

Node.js v23.11.1

Copilot AI review requested due to automatic review settings July 11, 2026 14:43

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

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

Comment thread src/coreclr/jit/codegencommon.cpp
Comment thread src/coreclr/jit/codegencommon.cpp
@pavelsavara

Copy link
Copy Markdown
Member

invalid value type 'exn', enable with --experimental-wasm-exnref @+58)
Node.js v23.11.1

Node version seems ok, we just need to pass --experimental-wasm-exnref in more scripts
#130550

Copilot AI review requested due to automatic review settings July 11, 2026 18:09

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

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

Comment thread src/coreclr/jit/codegenwasm.cpp
Comment thread src/coreclr/jit/codegencommon.cpp
Comment thread src/coreclr/jit/codegencommon.cpp
@pavelsavara

Copy link
Copy Markdown
Member

Node version seems ok, we just need to pass --experimental-wasm-exnref in more scripts #130550

Fixed now @AndyAyersMS

Log

node version: v23.11.1
Timeout in ms: 900000
Running: node --experimental-wasm-exnref --stack-size=8192 /root/helix/work/correlation/corerun.js -c /root/helix/work/correlation /root/helix/work/workitem/e/JIT/Directed/Directed_2/Directed_2.dll
19:04:04.786 Running test: JIT/Directed/perffix/primitivevt/callconv3_d/callconv3_d.dll
PASSED

...

PASSED
19:04:05.416 Passed test: JIT/Directed/shift/uint16_ro/uint16_ro.dll
Kill watchdog with PID 46
Expected: 100
Actual: 100
END EXECUTION - PASSED

@AndyAyersMS AndyAyersMS enabled auto-merge (squash) July 11, 2026 23:20
@AndyAyersMS AndyAyersMS merged commit c9265d7 into dotnet:main Jul 12, 2026
140 checks passed
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.

7 participants