-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Convert remaining PREPARE_NONVIRTUAL_CALLSITE call sites to UnmanagedCallersOnly #125697
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
base: main
Are you sure you want to change the base?
Changes from all commits
2328241
01b95ce
f8d8e47
34f0b6c
e327986
d465333
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -167,6 +167,32 @@ private static unsafe void ParseAsAssemblySpec(char* pAssemblyName, void* pAssem | |
| } | ||
| } | ||
|
|
||
| [UnmanagedCallersOnly] | ||
| private static unsafe void ParseAsAssemblySpec(char* pAssemblyName, void* pAssemblySpec, Exception* pException) | ||
| { | ||
| try | ||
| { | ||
| ParseAsAssemblySpec(pAssemblyName, pAssemblySpec); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actual work can be inlined here. |
||
| } | ||
| catch (Exception ex) | ||
| { | ||
| *pException = ex; | ||
| } | ||
| } | ||
|
|
||
| [UnmanagedCallersOnly] | ||
| private static unsafe void CreateAssemblyName(AssemblyName* pResult, NativeAssemblyNameParts* pParts, Exception* pException) | ||
| { | ||
| try | ||
| { | ||
| *pResult = new AssemblyName(pParts); | ||
| } | ||
| catch (Exception ex) | ||
| { | ||
| *pException = ex; | ||
| } | ||
| } | ||
|
|
||
| [LibraryImport(RuntimeHelpers.QCall, EntryPoint = "AssemblyName_InitializeAssemblySpec")] | ||
| private static unsafe partial void InitializeAssemblySpec(NativeAssemblyNameParts* pAssemblyNameParts, void* pAssemblySpec); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -138,6 +138,19 @@ internal static RuntimeType GetTypeReferencedByCustomAttribute(string typeName, | |
| return GetTypeHelper(typeName, requestingAssembly, throwOnError, requireAssemblyQualifiedName, unsafeAccessorMethod); | ||
| } | ||
|
|
||
| [UnmanagedCallersOnly] | ||
| private static unsafe void GetTypeHelper(char* pTypeName, RuntimeAssembly* pRequestingAssembly, bool throwOnError, bool requireAssemblyQualifiedName, IntPtr unsafeAccessorMethod, RuntimeType* pResult, Exception* pException) | ||
| { | ||
| try | ||
| { | ||
| *pResult = GetTypeHelper(pTypeName, *pRequestingAssembly, throwOnError, requireAssemblyQualifiedName, unsafeAccessorMethod); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actual work can be inlined here. |
||
| } | ||
| catch (Exception ex) | ||
| { | ||
| *pException = ex; | ||
| } | ||
| } | ||
|
|
||
| internal static RuntimeType? GetTypeHelper(ReadOnlySpan<char> typeName, RuntimeAssembly? requestingAssembly, | ||
| bool throwOnError, bool requireAssemblyQualifiedName, IntPtr unsafeAccessorMethod = 0) | ||
| { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -50,6 +50,19 @@ public IntPtr MarshalManagedToNative(object ManagedObj) | |
| internal static object InternalMarshalNativeToManaged(IntPtr pNativeData) | ||
| => GetInstance(null).MarshalNativeToManaged(pNativeData); | ||
|
|
||
| [System.Runtime.InteropServices.UnmanagedCallersOnly] | ||
| private static unsafe void InternalMarshalNativeToManaged(IntPtr pNativeData, object* pResult, Exception* pException) | ||
| { | ||
| try | ||
| { | ||
| *pResult = InternalMarshalNativeToManaged(pNativeData); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actual work can be inlined here.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (This applies to all cases where the managed method exists for the sole purpose of being called by the VM, and it is not very complicated.) |
||
| } | ||
| catch (Exception ex) | ||
| { | ||
| *pException = ex; | ||
| } | ||
| } | ||
|
|
||
| public object MarshalNativeToManaged(IntPtr pNativeData) | ||
| { | ||
| ArgumentNullException.ThrowIfNull(pNativeData); | ||
|
|
||
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.
Does this affect diagnosability of unhandled exceptions thrown by finalizers (e.g. from crash dumps)?
Also, the two RunFinalizers methods can be merged.
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.
@jkoritzinsky See the "Exception Propagation Helper" section in #123864. I've not written the QCall yet, but I can share the details if you'd like.