Skip to content

Conversation

@davidwrighton
Copy link
Member

Windows Arm64 has a peculiar calling convention for C++ member functions.

Notably, the return buffer is passed as the second parameter to the method (not using the normal X8 return buffer argument), and like other Windows platforms, the return buffer is needed for more forms of aggregates.

Windows Arm64 has a peculiar calling convention for C++ member functions.

Notably, the return buffer is passed as the second parameter to the method (not using the normal X8 return buffer argument), and like other Windows platforms, the return buffer is needed for more forms of aggregates.
@dotnet-policy-service
Copy link
Contributor

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

Copy link
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

Adds Windows Arm64 support for unmanaged C++ member-function (“thiscall”/memberfunction) calling convention quirks in the interpreter call stub path, specifically handling return buffers being passed in an argument register slot (X1) rather than the normal ARM64 return-buffer register.

Changes:

  • Introduces a Windows-Arm64-specific ArgIterator variant for unmanaged instance-method call convs so the return-buffer is treated as “passed as first arg” (consuming an argument register slot).
  • Extends call stub return-type selection to route ret-buffer returns to a new ReturnTypeBuffArg2 path on Windows Arm64.
  • Adds ARM64 assembly entry points to invoke/return via a ret-buffer passed in x1.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/coreclr/vm/reflectioninvocation.cpp Adds IsRetBuffPassedAsFirstArg() to satisfy updated ArgIteratorTemplate expectations.
src/coreclr/vm/callstubgenerator.h Adds a Windows-Arm64-only ReturnTypeBuffArg2 to represent ret-buff passed in arg slot 2 (X1 when this is present).
src/coreclr/vm/callstubgenerator.cpp Selects a Windows-Arm64 thiscall ArgIterator and routes ret-buff returns to CallJittedMethodRetBuffX1 / InterpreterStubRetBuffX1.
src/coreclr/vm/callingconvention.h Switches to this->IsRetBuffPassedAsFirstArg() so iterator specializations can override behavior; adds Windows-Arm64 thiscall iterator specialization.
src/coreclr/vm/arm64/asmhelpers.asm Adds InterpreterStubRetBuffX1 and CallJittedMethodRetBuffX1 assembly stubs for X1 ret-buffer passing.

davidwrighton and others added 2 commits January 23, 2026 09:43
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@davidwrighton davidwrighton merged commit d7834a3 into dotnet:main Jan 23, 2026
102 of 104 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.

2 participants