[clr-interp] Handle unmanaged thiscall on Windows Arm64#123519
Merged
davidwrighton merged 3 commits intodotnet:mainfrom Jan 23, 2026
Merged
[clr-interp] Handle unmanaged thiscall on Windows Arm64#123519davidwrighton merged 3 commits intodotnet:mainfrom
davidwrighton merged 3 commits intodotnet:mainfrom
Conversation
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.
Contributor
|
Tagging subscribers to this area: @BrzVlad, @janvorli, @kg |
Contributor
There was a problem hiding this comment.
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
ArgIteratorvariant 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
ReturnTypeBuffArg2path 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. |
jkoritzinsky
approved these changes
Jan 23, 2026
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…fix_unmanaged_this_on_windows_arm64
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.