Skip to content

Fix interpreter Unix x64 call stub generator#121942

Merged
janvorli merged 2 commits intodotnet:mainfrom
janvorli:fix-unix-interpreter-callstubs
Nov 25, 2025
Merged

Fix interpreter Unix x64 call stub generator#121942
janvorli merged 2 commits intodotnet:mainfrom
janvorli:fix-unix-interpreter-callstubs

Conversation

@janvorli
Copy link
Member

@janvorli janvorli commented Nov 24, 2025

The call stub generator is missing support for return buffer passing in RSI, only RDI was supported by mistake.

This change fixes it.

Fixes #121631

The call stub generator is missing support for return buffer passing
in RSI, only RDI was supported by mistake.

This change fixes it.
@janvorli janvorli added this to the 11.0.0 milestone Nov 24, 2025
@janvorli janvorli self-assigned this Nov 24, 2025
Copilot AI review requested due to automatic review settings November 24, 2025 23:21
@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

This PR fixes a bug in the CoreCLR interpreter's call stub generator for Unix x64 platforms. Previously, the generator only supported return buffer passing in the RDI register (first argument), but lacked support for passing it in RSI (second argument), which is needed when a method has a this pointer. This change properly implements support for both scenarios on Unix x64, matching the existing Windows x64 implementation that uses RCX/RDX.

Key changes:

  • Extended ReturnTypeBuffArg1 and ReturnTypeBuffArg2 enum values to Unix x64 (previously Windows-only)
  • Added extern declarations and implementations for CallJittedMethodRetBuffRDI/RSI and InterpreterStubRetBuffRDI/RSI
  • Updated switch statements to route to the correct assembly functions based on platform

Reviewed changes

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

File Description
src/coreclr/vm/callstubgenerator.h Extended ReturnTypeBuffArg1/BuffArg2 to all AMD64 platforms (not just Windows)
src/coreclr/vm/callstubgenerator.cpp Added Unix-specific extern declarations and updated switch statements to handle RDI/RSI return buffer variants
src/coreclr/vm/amd64/asmhelpers.S Implemented InterpreterStubRetBuffRDI/RSI and CallJittedMethodRetBuffRDI/RSI assembly functions for Unix

You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

Copy link
Member

@AaronRobinsonMSFT AaronRobinsonMSFT left a comment

Choose a reason for hiding this comment

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

Some nits.

Add / fix some comments on #endifs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Aaron R Robinson <arobins@microsoft.com>
@janvorli janvorli merged commit bf17d45 into dotnet:main Nov 25, 2025
99 checks passed
@janvorli janvorli deleted the fix-unix-interpreter-callstubs branch November 25, 2025 12:45
@github-actions github-actions bot locked and limited conversation to collaborators Dec 26, 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.

[clr-interp] Stackoverflow on x64

3 participants