Skip to content

Fix interpreter passing managed "this" in presence of return buffer - #117661

Merged
janvorli merged 1 commit into
dotnet:mainfrom
janvorli:fix-interpreter-this-passing
Jul 16, 2025
Merged

Fix interpreter passing managed "this" in presence of return buffer#117661
janvorli merged 1 commit into
dotnet:mainfrom
janvorli:fix-interpreter-this-passing

Conversation

@janvorli

Copy link
Copy Markdown
Member

The CallStubGenerator is using the native x64 Windows calling convention for the case when both "this" and "return buffer" arguments are passed to native callees. However, the CLR ABI diverges from this convention. While the native one passes the return buffer first and the this pointer second, the CLR ABI always passes the "this" pointer first.

This fixes a number of failures on the runtime startup path when running interpreted.

The CallStubGenerator is using the native x64 Windows calling
convention for the case when both "this" and "return buffer" arguments
are passed to native callees. However, the CLR ABI diverges from this
convention. While the native one passes the return buffer first and the
this pointer second, the CLR ABI always passes the "this" pointer first.
This fixes a number of failures on the runtime startup path when running
interpreted.
@janvorlijanvorli added this to the 10.0.0 milestone Jul 15, 2025
@janvorli
janvorli requested review from kg and kotlarmilosJuly 15, 2025 14:40
@janvorlijanvorli self-assigned this Jul 15, 2025
CopilotAI review requested due to automatic review settings July 15, 2025 14:40
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

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 updates the CallStubGenerator to use the CLR ABI ordering for the this pointer when a return buffer is present, ensuring this is always passed in the first argument register rather than following the native Windows x64 convention.

  • Removes the special-case Windows/AMD64 branch that swapped the registers when a return buffer was present.
  • Always sets m_r1 to 0 for the this pointer under the CLR ABI.
  • Updates the comment to clarify the CLR ABI behavior.

Comment threadsrc/coreclr/vm/callstubgenerator.cpp
kg
kg approved these changes Jul 15, 2025
@janvorli

Copy link
Copy Markdown
MemberAuthor

/ba-g the Android build timeouts are a known issue

@janvorli
janvorli merged commit b24079e into dotnet:mainJul 16, 2025
@janvorli
janvorli deleted the fix-interpreter-this-passing branch July 16, 2025 14:08
@github-actionsgithub-actionsBot locked and limited conversation to collaborators Aug 16, 2025
Sign up for freeto 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

@janvorli@kg