Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[clr-interp] Fix some interop suite issues - #122656

#122656
Merged
davidwrighton merged 5 commits into
dotnet:maindotnet/runtime:mainfrom
davidwrighton:fix_some_interop_suite_issuesdavidwrighton/runtime:fix_some_interop_suite_issuesCopy head branch name to clipboard
Jan 6, 2026
Merged

[clr-interp] Fix some interop suite issues#122656
davidwrighton merged 5 commits into
dotnet:maindotnet/runtime:mainfrom
davidwrighton:fix_some_interop_suite_issuesdavidwrighton/runtime:fix_some_interop_suite_issuesCopy head branch name to clipboard

Conversation

@davidwrighton

@davidwrighton davidwrighton commented Dec 19, 2025

Copy link
Copy Markdown
Member

This fixes several issues that were blocking the interop suite from passing:

  • Platform detection of IsBuiltInComEnabled in the presence of interpreter support
  • Move delegate creation to use the optimized constructors. This works around creating a delegate to a function which is marked with [UnmanagedCallersOnly]. We've since decided to fix the test suite, but this is an improvement to the compiler in any case.

- The HasUnmanagedCallersOnlyAttribute api is... not as accurate as I'd like. See comment in the code
- Fix an issue with platform detection where we are attempting to test COM interop tests with the interpreter enabled
- Fix an issue with creating a delegate to a method marked with an [UnmanagedCallersOnly] attribute. NOTE: This fix is probably not acceptable for long term usage as it injects a very expensive metadata lookup into the slow path delegate contruction logic.
@github-actions github-actions Bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Dec 19, 2025
@davidwrighton

Copy link
Copy Markdown
Member Author

@AaronRobinsonMSFT @jkoritzinsky do you have an opinion on the check of HasUnmanagedCallersOnlyAttribute in the delegate constructor. We currently have a check for it in optimized delegate construction, which is almost always used by the JIT, but I need to know if we really need that to work, or if it's just a convenience feature that it fails.

@davidwrighton

Copy link
Copy Markdown
Member Author

/azp run runtime-interpreter

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

Comment thread src/coreclr/vm/comdelegate.cpp Outdated
@davidwrighton

Copy link
Copy Markdown
Member Author

/azp run runtime-interpreter

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@davidwrighton davidwrighton changed the title [DRAFT] [clr-interp] Fix some interop suite issues [clr-interp] Fix some interop suite issues Jan 6, 2026
@davidwrighton davidwrighton added area-CodeGen-Interpreter-coreclr and removed needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners labels Jan 6, 2026
@davidwrighton
davidwrighton marked this pull request as ready for review January 6, 2026 18:08
Copilot AI review requested due to automatic review settings January 6, 2026 18:08
@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.

Copilot AI 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 fixes several interop suite issues related to the CoreCLR interpreter. The main changes include: (1) correcting platform detection for built-in COM support when the interpreter is active, and (2) implementing a peephole optimization for delegate constructor patterns to use optimized constructors.

Key changes:

  • Modified IsBuiltInComEnabled to return false when the CoreCLR interpreter is active
  • Added a peephole optimizer that recognizes LDFTN/LDVIRTFTN + NEWOBJ patterns and rewrites them to use optimized delegate constructors
  • Refactored ldftn-related code into reusable helper methods

Reviewed changes

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

File Description
InvalidSafeHandleMarshallingTests.cs Adds test skip attribute for interpreter mode with comment explaining COM interop behavior
PlatformDetection.cs Modifies IsBuiltInComEnabled to exclude CoreCLR interpreter from COM support detection
compiler.h Adds member variable m_pConstrainedToken and declares new helper methods for ldftn operations and delegate constructor optimization
compiler.cpp Implements delegate constructor peephole optimization, refactors ldftn/ldvirtftn code into EmitLdftn, extracts EmitDup and EmitLoadPointer helpers, and converts constrained token handling from local to member variable

Comment thread src/coreclr/interpreter/compiler.cpp Outdated
Comment thread src/coreclr/interpreter/compiler.cpp

@janvorli janvorli left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, thank you!

@davidwrighton

Copy link
Copy Markdown
Member Author

/ba-g known issues + a machine that would have produced a known issue instead dead-lettered.

@davidwrighton
davidwrighton merged commit 78d6652 into dotnet:main Jan 6, 2026
101 of 104 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Feb 6, 2026
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.

5 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.