Skip to content

Conversation

janvorli
Copy link
Member

@janvorli janvorli commented Sep 4, 2025

The Calli implementation was missing support for the case when the targer is a pinvoke. That resulted in errors due to incorrect GC mode. This change fixes that.

@janvorli janvorli added this to the 11.0.0 milestone Sep 4, 2025
@janvorli janvorli self-assigned this Sep 4, 2025
@Copilot Copilot AI review requested due to automatic review settings September 4, 2025 17:39
@janvorli janvorli requested review from BrzVlad and kg as code owners September 4, 2025 17:39
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 implements missing PInvoke support for the interpreter's Calli (indirect call) functionality in the CoreCLR runtime. The implementation ensures proper GC mode handling when calling native functions through function pointers.

Key changes:

  • Added a new InvokePInvokeCalliStub function that handles PInvoke calls with proper GC mode transitions
  • Extended the Calli opcode to include PInvoke detection information
  • Refactored Calli emission code to centralize the logic and include calling convention analysis

Reviewed Changes

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

Show a summary per file
File Description
src/coreclr/vm/wasm/helpers.cpp Added stub implementation of InvokePInvokeCalliStub for WASM platform
src/coreclr/vm/interpexec.cpp Implemented InvokePInvokeCalliStub with proper GC transitions and updated Calli execution logic
src/coreclr/interpreter/intops.def Extended Calli opcodes to include an additional parameter for PInvoke detection
src/coreclr/interpreter/compiler.h Added declaration for new EmitCalli helper method
src/coreclr/interpreter/compiler.cpp Implemented EmitCalli method and refactored call emission to use it

The Calli implementation was missing support for the case when the
targer is a pinvoke. That resulted in errors due to incorrect GC mode.
This change fixes that.
* Disable calli with marshalled pinvokes
* Refactor the target invocation methods
@janvorli janvorli merged commit a216015 into dotnet:main Sep 8, 2025
98 checks passed
@janvorli janvorli deleted the implement-pinvoke-calli-support branch September 8, 2025 21:23
@github-actions github-actions bot locked and limited conversation to collaborators Oct 9, 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