Skip to content

Replace MethodDescCallSite with UnmanagedCallersOnly in clrex.cpp#126061

Open
AaronRobinsonMSFT wants to merge 9 commits intodotnet:mainfrom
AaronRobinsonMSFT:dev/arobins/clrex-uco-conversion
Open

Replace MethodDescCallSite with UnmanagedCallersOnly in clrex.cpp#126061
AaronRobinsonMSFT wants to merge 9 commits intodotnet:mainfrom
AaronRobinsonMSFT:dev/arobins/clrex-uco-conversion

Conversation

@AaronRobinsonMSFT
Copy link
Member

Note

This PR description was generated with the assistance of GitHub Copilot.

Convert exception construction in clrex.cpp from MethodDescCallSite/CallDescrWorker to the UnmanagedCallersOnlyCaller pattern for EEArgumentException, EETypeLoadException, and EEFileLoadException.

Changes

  • Exception.CoreCLR.cs - Add [UnmanagedCallersOnly] CreateArgumentException factory method
  • FileLoadException.CoreCLR.cs - Add [UnmanagedCallersOnly] Create factory method
  • TypeLoadException.CoreCLR.cs - Add [UnmanagedCallersOnly] Create factory method
  • clrex.cpp - Replace MethodDescCallSite usage with UnmanagedCallersOnlyCaller in three CreateThrowable methods
  • corelib.h - Register new managed methods (METHOD__EXCEPTION__CREATE_ARGUMENT_EXCEPTION, METHOD__TYPE_LOAD_EXCEPTION__CREATE, METHOD__FILE_LOAD_EXCEPTION__CREATE)
  • metasig.h - Remove unused metasig entries (IM(Str_Int_RetVoid), IM(Str_Str_Str_Int_RetVoid))

Contributes to #123864

Convert EEArgumentException, EETypeLoadException, and EEFileLoadException
CreateThrowable methods to use UnmanagedCallersOnlyCaller instead of
MethodDescCallSite/CallDescrWorker for invoking managed exception
constructors. Add corresponding [UnmanagedCallersOnly] factory methods
in managed code and remove unused metasig entries.

Contributes to dotnet#123864

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a 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 migrates several VM-to-managed exception construction paths in src/coreclr/vm/clrex.cpp from MethodDescCallSite / CallDescrWorker to the UnmanagedCallersOnlyCaller reverse P/Invoke pattern, adding the corresponding [UnmanagedCallersOnly] managed factory entrypoints and binder registrations in CoreLib.

Changes:

  • Add [UnmanagedCallersOnly] managed factory methods for ArgumentException, TypeLoadException, and FileLoadException construction.
  • Update clrex.cpp to invoke these factories via UnmanagedCallersOnlyCaller instead of MethodDescCallSite.
  • Register new CoreLib binder method IDs and remove now-unused metasig entries.

Reviewed changes

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

Show a summary per file
File Description
src/coreclr/vm/metasig.h Removes metasig entries no longer needed after dropping MethodDescCallSite ctor invocations.
src/coreclr/vm/corelib.h Adds binder registrations for the new managed [UnmanagedCallersOnly] factory methods.
src/coreclr/vm/clrex.cpp Switches three CreateThrowable() implementations to UnmanagedCallersOnlyCaller.
src/coreclr/System.Private.CoreLib/src/System/TypeLoadException.CoreCLR.cs Adds [UnmanagedCallersOnly] TypeLoadException.Create factory.
src/coreclr/System.Private.CoreLib/src/System/IO/FileLoadException.CoreCLR.cs Adds [UnmanagedCallersOnly] FileLoadException.Create factory.
src/coreclr/System.Private.CoreLib/src/System/Exception.CoreCLR.cs Adds [UnmanagedCallersOnly] Exception.CreateArgumentException helper for ctor invocation.

Refactor EEFileLoadException::GetFileLoadKind to use a switch statement.
Add ArgumentExceptionKind and FileLoadExceptionKind enums for managed mapping.
Update CreateThrowable methods to use UnmanagedCallersOnlyCaller.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Jan Kotas <jkotas@microsoft.com>
Copilot AI review requested due to automatic review settings March 25, 2026 17:24
Copy link
Contributor

Copilot AI left a comment

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 8 out of 8 changed files in this pull request and generated 1 comment.

Copilot AI review requested due to automatic review settings March 25, 2026 20:56
Copy link
Contributor

Copilot AI left a comment

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 8 out of 8 changed files in this pull request and generated 2 comments.

Co-authored-by: Aaron R Robinson <arobins@microsoft.com>
Copilot AI review requested due to automatic review settings March 25, 2026 21:13
Copy link
Contributor

Copilot AI left a comment

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 8 out of 8 changed files in this pull request and generated 3 comments.

Copilot AI review requested due to automatic review settings March 26, 2026 18:04
Copy link
Contributor

Copilot AI left a comment

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 8 out of 8 changed files in this pull request and generated 3 comments.

@AaronRobinsonMSFT
Copy link
Member Author

/azp run runtime

@AaronRobinsonMSFT
Copy link
Member Author

/azp run runtime

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

4 participants