Implement interpreter PInvoke Calli#119356
Merged
janvorli merged 6 commits intodotnet:mainfrom Sep 8, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
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
InvokePInvokeCalliStubfunction 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 |
jkotas
reviewed
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.
1b6d8da to
137d62b
Compare
jkotas
reviewed
Sep 5, 2025
jkotas
reviewed
Sep 5, 2025
* Disable calli with marshalled pinvokes * Refactor the target invocation methods
jkotas
approved these changes
Sep 8, 2025
Member
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.