Skip to content

JIT: Normalize small unmanaged args on wasm - #133511

Merged
AndyAyersMS merged 3 commits into
dotnet:mainfrom
AndyAyersMS:fix-wasm-small-arg-extension
Sep 10, 2026
Merged

AndyAyersMS merged 3 commits into
dotnet:mainfrom
AndyAyersMS:fix-wasm-small-arg-extension

Conversation

@AndyAyersMS

@AndyAyersMS AndyAyersMS commented Sep 9, 2026 •

Copy link
Copy Markdown
Member

Fixes #133506

Wasm follows the Basic C ABI requirement that small integer arguments are extended to 32 bits. Include wasm in the existing unmanaged-call normalization used for ARM32 and Apple ARM64.

The existing Runtime_101046 test now generates i32.load16_s instead of passing the result of i32.load16_u directly to the native call.

Note

This PR description was generated with GitHub Copilot.

Copilot AI lite review requested due to automatic review settings September 9, 2026 17:16
@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 Sep 9, 2026
@AndyAyersMS

Copy link
Copy Markdown
Member Author

fyi @dotnet/wasm-contrib

@azure-pipelines

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

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

@pavelsavara pavelsavara added the arch-wasm WebAssembly architecture label Sep 9, 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.

🔵 Needs a closer look

It changes wasm unmanaged ABI-related normalization in JIT import logic, and correctness depends on platform ABI/codegen semantics best validated by a human reviewer and targeted wasm/R2R testing results.

Pull request overview

This PR updates CoreCLR JIT argument-import logic to apply the existing “small unmanaged integer argument normalization” (zero/sign extension to 32-bit) when targeting WebAssembly, aligning wasm with the same handling already used for ARM32 and Apple ARM64 unmanaged calls.

Changes:

  • Extend the unmanaged-call small-integer normalization condition to include TargetArchitecture::IsWasm.
  • Add TargetArchitecture::IsWasm to the shared target architecture feature flags to enable that check in the JIT codebase.
File summaries
File Description
src/coreclr/jit/importercalls.cpp Applies small-integer widening/normalization for wasm unmanaged-call arguments (same normalization pattern as ARM32/Apple ARM64).
src/coreclr/inc/targetosarch.h Introduces TargetArchitecture::IsWasm compile-time flag keyed off TARGET_WASM.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Lite

Copilot AI review requested due to automatic review settings September 10, 2026 00:01

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.

🔵 Needs a closer look

It changes wasm unmanaged-call ABI-related argument normalization in the JIT, which has broad behavioral impact and should get final confirmation from a human reviewer with wasm ABI/codegen context.

Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@AndyAyersMS

Copy link
Copy Markdown
Member Author

/ba-g build insights seems stuck

@AndyAyersMS
AndyAyersMS merged commit 4a29be7 into dotnet:main Sep 10, 2026
142 of 143 checks passed
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Sep 14, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 15, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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.

[wasm][R2R] Runtime_101046 returns incorrect sign extension

5 participants