-
Notifications
You must be signed in to change notification settings - Fork 5.3k
[clr-interp] Fix some interop suite issues #122656
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[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.
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
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
janvorli
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you!
|
/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: