Skip to content

Conversation

janvorli
Copy link
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.
@janvorli janvorli added this to the 10.0.0 milestone Jul 15, 2025
@janvorli janvorli requested review from kg and kotlarmilos July 15, 2025 14:40
@janvorli janvorli self-assigned this Jul 15, 2025
@Copilot Copilot AI review requested due to automatic review settings July 15, 2025 14:40
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 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 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.

@janvorli
Copy link
Member Author

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

@janvorli janvorli merged commit b24079e into dotnet:main Jul 16, 2025
98 of 100 checks passed
@janvorli janvorli deleted the fix-interpreter-this-passing branch July 16, 2025 14:08
@github-actions github-actions bot locked and limited conversation to collaborators Aug 16, 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.

2 participants