Skip to content

Fix R2R detected layout issues#128275

Open
davidwrighton wants to merge 2 commits into
dotnet:mainfrom
davidwrighton:fix_r2r_detected_layout_issues
Open

Fix R2R detected layout issues#128275
davidwrighton wants to merge 2 commits into
dotnet:mainfrom
davidwrighton:fix_r2r_detected_layout_issues

Conversation

@davidwrighton
Copy link
Copy Markdown
Member

Note

This PR description was generated with AI assistance.

This PR fixes two R2R layout issues:

  1. SupportAlign8 on Wasm: Two places in R2R hardcoded an Arm check when they should be checking against SupportsAlign8. This now handles Wasm the same way as Arm.

  2. Incorrectly constructed GCRefMap: GCRefMap/ArgIterator construction was confused — reflection invocation added a ret buf parameter to the arg iteration that didn't respect 16 byte alignment correctly, and Crossgen2 ArgIterator incorrectly merged in the WasmLowering code for struct args and returns.

- There were two places in R2R which hardcoded an Arm check when they should be checking against SupportsAlign8
- GCRefMap/ArgIterator construction was fairly confused
  - Reflection invocation added a "ret buf parameter to the arg iteration that didn't respect 16 byte alignment correctly
  - Crossgen2 ArgIterator incorrectly merged in the WasmLowering code for struct args and returns
Copilot AI review requested due to automatic review settings May 16, 2026 00:20
@github-actions github-actions Bot added the area-crossgen2-coreclr only use for closed issues label May 16, 2026
Copy link
Copy Markdown
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 adjusts WebAssembly R2R/interpreter calling-convention handling so layout, alignment, return buffers, and GC ref maps are computed consistently for Wasm-specific interpreter transition blocks.

Changes:

  • Uses SupportsAlign8 instead of hardcoded ARM checks for layout/alignment decisions.
  • Separates Wasm interpreter transition-block layout from Wasm ABI struct lowering in ReadyToRun thunk generation.
  • Updates reflection invocation and CallDescr handling so large Wasm struct returns use an explicit return buffer outside the normal argument stream.

Reviewed changes

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

Show a summary per file
File Description
src/coreclr/vm/wasm/calldescrworkerwasm.cpp Uses explicit Wasm return-buffer metadata instead of rewriting argument slots.
src/coreclr/vm/reflectioninvocation.cpp Computes Wasm return-buffer needs independently and passes the buffer separately.
src/coreclr/vm/callingconvention.h Removes Wasm retbuf args from the normal ArgIterator stream.
src/coreclr/vm/callhelpers.h Adds Wasm-specific return-buffer pointer storage.
src/coreclr/tools/Common/TypeSystem/Common/MetadataFieldLayoutAlgorithm.cs Generalizes alignment layout logic from ARM to SupportsAlign8.
src/coreclr/tools/Common/JitInterface/WasmLowering.cs Makes Wasm lowering partial for ReadyToRun-specific helpers.
src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs Generalizes class alignment requirement from ARM to SupportsAlign8.
src/coreclr/tools/aot/ILCompiler.ReadyToRun/JitInterface/WasmLowering.ReadyToRun.cs Adds helper to identify Wasm ABI byref-lowered struct arguments.
src/coreclr/tools/aot/ILCompiler.ReadyToRun/ILCompiler.ReadyToRun.csproj Includes the new ReadyToRun Wasm lowering helper file.
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/WasmR2RToInterpreterThunkNode.cs Uses Wasm ABI lowering helper for indirect struct arguments.
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/WasmInterpreterToR2RThunkNode.cs Uses Wasm ABI lowering helper for interpreter-to-R2R argument reconstruction.
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/WasmImportThunk.cs Uses Wasm ABI lowering helper when saving/restoring import thunk arguments.
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/TransitionBlock.cs Makes Wasm TransitionBlock follow interpreter layout instead of ABI byref/retbuf lowering.
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/ArgIterator.cs Reworks Wasm argument offset computation to use interpreter stack alignment/layout.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-crossgen2-coreclr only use for closed issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants