Skip to content

Conversation

davidwrighton
Copy link
Member

  • Arguments are up to 16 byte aligned
  • Handle this in the call stub generator, and call emission. (We already did this in the argument input processing in the interpreter

We need to align these at 16byte boundaries as the various ABIs tend to have a hard requirement around 16 byte alignment, when they don't have such a requirement around 32 or 64 byte alignment.

…ures in the interpreter

- Arguments are up to 16 byte aligned
- Handle this in the call stub generator, and call emission. (We already did this in the argument input processing in the interpreter

We need to align these at 16byte boundaries as the various ABIs tend to have a hard requirement around 16 byte alignment, when they don't have such a requirement around 32 or 64 byte alignment.
@Copilot Copilot AI review requested due to automatic review settings October 14, 2025 20:58
Copy link
Contributor

@Copilot 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 fixes argument alignment of 16-byte or greater aligned structures in the CLR interpreter to properly handle structures that require 16-byte alignment boundaries as mandated by various ABIs.

Key Changes

  • Updated call stub generator to allocate space for alignment injection routines (3x args instead of 2x)
  • Added alignment logic in call stub computation to handle 16-byte aligned value types
  • Implemented InjectInterpStackAlign assembly routines across x64 and ARM64 platforms

Reviewed Changes

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

Show a summary per file
File Description
src/tests/Interop/PInvoke/Int128/Int128Test.cs Removed FIXME comment indicating the interpreter issue is now resolved
src/coreclr/vm/callstubgenerator.h Updated comment and allocation size calculation for call stub routines array
src/coreclr/vm/callstubgenerator.cpp Added alignment logic and InjectInterpStackAlign function declaration
src/coreclr/vm/arm64/asmhelpers.asm Added ARM64 assembly implementation of InjectInterpStackAlign
src/coreclr/vm/arm64/asmhelpers.S Added ARM64 Unix assembly implementation of InjectInterpStackAlign
src/coreclr/vm/amd64/asmhelpers.S Added x64 Unix assembly implementation of InjectInterpStackAlign
src/coreclr/vm/amd64/AsmHelpers.asm Added x64 Windows assembly implementation of InjectInterpStackAlign
src/coreclr/interpreter/compileropt.cpp Added alignment logic for variable allocation in interpreter
src/coreclr/interpreter/compiler.cpp Added alignment constraint and fixed stack type for unbox operation

Copy link
Contributor

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

@kg
Copy link
Member

kg commented Oct 14, 2025

Thanks for figuring this out and fixing it - that test failure had me stumped!

@davidwrighton davidwrighton enabled auto-merge (squash) October 14, 2025 22:59
@davidwrighton davidwrighton merged commit 4f50696 into dotnet:main Oct 15, 2025
99 of 103 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants