Skip to content

Convert PREPARE_SIMPLE_VIRTUAL_CALLSITE usages to use the UCO pattern - #124921

Merged
jkoritzinsky merged 8 commits into
dotnet:mainfrom
jkoritzinsky:psvcs
Mar 3, 2026
Merged

jkoritzinsky merged 8 commits into
dotnet:mainfrom
jkoritzinsky:psvcs

Conversation

@jkoritzinsky

Copy link
Copy Markdown
Member

Contributes to #123864.

Also remove PREPARE_SIMPLE_VIRTUAL_CALLSITE now that it is unused.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @agocke
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 converts the remaining PREPARE_SIMPLE_VIRTUAL_CALLSITE usages in dynamicmethod.cpp to use the more efficient UnmanagedCallersOnly (UCO) pattern, and removes the now-unused PREPARE_SIMPLE_VIRTUAL_CALLSITE macro from callhelpers.h. This is part of the larger effort tracked in issue #123864 to replace MethodDescCallSite/CallDescrWorker infrastructure with UnmanagedCallersOnly reverse P/Invoke calls for better performance when invoking managed code from native code.

Changes:

  • Converted 5 call sites in LCGMethodResolver to use UnmanagedCallersOnlyCaller pattern
  • Added corresponding [UnmanagedCallersOnly] wrapper methods in RuntimeHandles.cs
  • Updated method signatures in metasig.h and corelib.h from instance methods (IM_*) to static methods with pointer parameters (SM_Ptr*)
  • Removed the deprecated PREPARE_SIMPLE_VIRTUAL_CALLSITE and PREPARE_SIMPLE_VIRTUAL_CALLSITE_USING_SLOT macros

Reviewed changes

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

Show a summary per file
File Description
src/coreclr/vm/metasig.h Added 3 new method signature definitions for the converted methods: ResolveToken, ResolveSignature, and GetEHInfo
src/coreclr/vm/corelib.h Updated 4 method definitions from instance methods to static methods with pointer parameters
src/coreclr/vm/callhelpers.h Removed deprecated PREPARE_SIMPLE_VIRTUAL_CALLSITE macros (56 lines) and fixed trailing whitespace
src/coreclr/vm/dynamicmethod.cpp Converted 5 call sites (ResolveToken, ResolveSignature x2, GetRawEHInfo, GetEHInfo) to use UnmanagedCallersOnlyCaller with explicit GC protection
src/coreclr/System.Private.CoreLib/src/System/RuntimeHandles.cs Added 4 new [UnmanagedCallersOnly] wrapper methods with exception out-parameters

Comment thread src/coreclr/vm/dynamicmethod.cpp Outdated
Comment thread src/coreclr/vm/dynamicmethod.cpp Outdated
Comment thread src/coreclr/vm/dynamicmethod.cpp Outdated
Comment thread src/coreclr/vm/dynamicmethod.cpp Outdated
Comment thread src/coreclr/vm/dynamicmethod.cpp Outdated
Comment thread src/coreclr/vm/dynamicmethod.cpp Outdated
Comment thread src/coreclr/System.Private.CoreLib/src/System/RuntimeHandles.cs Outdated
Comment thread src/coreclr/vm/dynamicmethod.cpp Outdated
Comment thread src/coreclr/vm/metasig.h Outdated
Copilot AI review requested due to automatic review settings February 28, 2026 01:13

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

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

Comment thread src/coreclr/vm/dynamicmethod.cpp
Comment thread src/coreclr/vm/dynamicmethod.cpp
Comment thread src/coreclr/vm/dynamicmethod.cpp
Comment thread src/coreclr/vm/metasig.h
Comment thread src/coreclr/vm/wasm/callhelpers-reverse.cpp Outdated
Copilot AI review requested due to automatic review settings March 2, 2026 18:30

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

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

Comment thread src/coreclr/vm/dynamicmethod.cpp
@jkoritzinsky

Copy link
Copy Markdown
Member Author

/ba-g wbt failures

@jkoritzinsky
jkoritzinsky merged commit 9766d74 into dotnet:main Mar 3, 2026
121 of 126 checks passed
@github-project-automation github-project-automation Bot moved this to Done in AppModel Mar 3, 2026
@jkoritzinsky
jkoritzinsky deleted the psvcs branch March 3, 2026 04:46
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 2, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants