[clr-interp] Fix some interop suite issues#122656
Conversation
- 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.
|
@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. |
|
/azp run runtime-interpreter |
|
Azure Pipelines successfully started running 1 pipeline(s). |
…e_interop_suite_issues
|
/azp run runtime-interpreter |
|
Azure Pipelines successfully started running 1 pipeline(s). |
|
Tagging subscribers to this area: @BrzVlad, @janvorli, @kg |
There was a problem hiding this comment.
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
IsBuiltInComEnabledto return false when the CoreCLR interpreter is active - Added a peephole optimizer that recognizes
LDFTN/LDVIRTFTN+NEWOBJpatterns 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 |
src/tests/Interop/PInvoke/SafeHandles/InvalidSafeHandleMarshallingTests.cs
Show resolved
Hide resolved
|
/ba-g known issues + a machine that would have produced a known issue instead dead-lettered. |
This fixes several issues that were blocking the interop suite from passing: