Skip to content

Replace MethodDescCallSite with UnmanagedCallersOnly in clrex.cpp#126061

Merged
AaronRobinsonMSFT merged 11 commits intodotnet:mainfrom
AaronRobinsonMSFT:dev/arobins/clrex-uco-conversion
Mar 28, 2026
Merged

Replace MethodDescCallSite with UnmanagedCallersOnly in clrex.cpp#126061
AaronRobinsonMSFT merged 11 commits intodotnet:mainfrom
AaronRobinsonMSFT:dev/arobins/clrex-uco-conversion

Conversation

@AaronRobinsonMSFT
Copy link
Copy Markdown
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
Copy Markdown
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.

Comment thread src/coreclr/vm/clrex.cpp Outdated
Comment thread src/coreclr/vm/corelib.h
Comment thread src/coreclr/vm/clrex.cpp Outdated
Comment thread src/coreclr/vm/clrex.cpp Outdated
Comment thread src/coreclr/System.Private.CoreLib/src/System/Exception.CoreCLR.cs Outdated
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>
Comment thread src/coreclr/System.Private.CoreLib/src/System/IO/FileLoadException.CoreCLR.cs Outdated
Comment thread src/coreclr/System.Private.CoreLib/src/System/Exception.CoreCLR.cs
Comment thread src/coreclr/System.Private.CoreLib/src/System/Exception.CoreCLR.cs Outdated
Comment thread src/coreclr/System.Private.CoreLib/src/System/Exception.CoreCLR.cs Outdated
Co-authored-by: Jan Kotas <jkotas@microsoft.com>
Copilot AI review requested due to automatic review settings March 25, 2026 17:24
Copy link
Copy Markdown
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
Copy Markdown
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.

Comment thread src/coreclr/System.Private.CoreLib/src/System/Exception.CoreCLR.cs
Comment thread src/coreclr/System.Private.CoreLib/src/System/IO/FileLoadException.CoreCLR.cs Outdated
Comment thread src/coreclr/System.Private.CoreLib/src/System/IO/FileLoadException.CoreCLR.cs Outdated
Comment thread src/coreclr/System.Private.CoreLib/src/System/Exception.CoreCLR.cs Outdated
Co-authored-by: Aaron R Robinson <arobins@microsoft.com>
Copilot AI review requested due to automatic review settings March 25, 2026 21:13
Copilot AI review requested due to automatic review settings March 26, 2026 18:04
Copy link
Copy Markdown
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.

Comment thread src/coreclr/vm/clrex.cpp
Comment thread src/coreclr/vm/clrex.cpp
Comment thread src/coreclr/vm/clrex.cpp
@AaronRobinsonMSFT
Copy link
Copy Markdown
Member Author

/azp run runtime

@AaronRobinsonMSFT
Copy link
Copy Markdown
Member Author

/azp run runtime

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

Copilot AI review requested due to automatic review settings March 27, 2026 17:26
Copy link
Copy Markdown
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 9 out of 10 changed files in this pull request and generated 1 comment.

Comment thread src/coreclr/vm/clrex.cpp
Comment thread src/native/libs/Common/JavaScript/loader/dotnet.d.ts
@AaronRobinsonMSFT
Copy link
Copy Markdown
Member Author

/ba-g Unrelated failure

@AaronRobinsonMSFT AaronRobinsonMSFT merged commit ff21bcd into dotnet:main Mar 28, 2026
161 of 163 checks passed
@AaronRobinsonMSFT AaronRobinsonMSFT deleted the dev/arobins/clrex-uco-conversion branch March 28, 2026 23:46
@github-project-automation github-project-automation Bot moved this to Done in AppModel Mar 28, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 28, 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.

5 participants