Skip to content

Conversation

@janvorli
Copy link
Member

@janvorli janvorli commented Jul 8, 2025

The CallStubGenerator was missing support for arguments passed by reference using stack slots. Only references in registers were implemented. There was also a bug in passing return buffer argument when there was "this" at the same time. Only the m_r1 was set to 1, but the m_r2 was left unchanged, being 0. That resulted in the routine fetched for that register range being NULL.

This change fixes both of these issues and adds a test.

The CallStubGenerator was missing support for arguments passed by
reference using stack slots. Only references in registers were
implemented. There was also a bug in passing return buffer argument when
there was "this" at the same time. Only the m_r1 was set to 1, but the
m_r2 was left unchanged, being 0. That resulted in the routine fetched
for that register range being NULL.

This change fixes both of these issues and adds a test.
@janvorli janvorli added this to the 10.0.0 milestone Jul 8, 2025
@janvorli janvorli self-assigned this Jul 8, 2025
@Copilot Copilot AI review requested due to automatic review settings July 8, 2025 00:28
@janvorli janvorli requested a review from davidwrighton July 8, 2025 00:28
@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.

@janvorli janvorli requested a review from kg July 8, 2025 00:28
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

This PR adds support for arguments passed by reference on the stack, fixes return-buffer register setup when a this parameter is present on Windows AMD64, and adds a new interpreter/JIT calling convention test.

  • Introduce GetStackRefRoutine and corresponding assembly helpers for stack-based by-ref args.
  • Initialize m_r2 to properly handle return-buffer + this on Windows AMD64.
  • Add TestCallingConvention13 suite to validate the new stack-ref code paths.

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/tests/JIT/interpreter/Interpreter.cs Add TestCallingConvention13* methods and integrate into test runners
src/coreclr/vm/callstubgenerator.h Declare new GetStackRefRoutine method
src/coreclr/vm/callstubgenerator.cpp Define GetStackRefRoutine, handle by-ref stack args, fix m_r2 init
src/coreclr/vm/arm64/asmhelpers.asm Add Load_Stack_Ref/Store_Stack_Ref and ref-copy macro
src/coreclr/vm/arm64/asmhelpers.S Mirror new stack-ref routines and macro in assembler
src/coreclr/vm/amd64/AsmHelpers.asm Add Load_Stack_Ref/Store_Stack_Ref routines for AMD64

Copy link
Member

@kg kg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@janvorli
Copy link
Member Author

janvorli commented Jul 8, 2025

/ba-g build failure is unrelated, I've created #117413 to track it.

@janvorli janvorli merged commit 34078bb into dotnet:main Jul 8, 2025
98 of 103 checks passed
@janvorli janvorli deleted the fix-callstub-generator branch July 8, 2025 12:21
@github-actions github-actions bot locked and limited conversation to collaborators Aug 8, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants