Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions src/coreclr/nativeaot/Runtime/HandleTableHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,8 @@ static ManagedObjectWrapper* ToManagedObjectWrapper(void* dispatchPtr)
// invokes AddRef while holding a lock that it *also* holds while a GC is in progress. If AddRef was managed, we would have
// to synchronize with the GC before entering AddRef, which would deadlock with the other thread holding Xaml's lock.
//
static uint32_t __stdcall IUnknown_AddRef(void* pComThis)
EXTERN_C uint32_t __stdcall RhIUnknown_AddRef(void* pComThis)
{
ManagedObjectWrapper* wrapper = ToManagedObjectWrapper(pComThis);
return wrapper->AddRef();
}

FCIMPL0(void*, RhGetIUnknownAddRef)
{
return (void*)&IUnknown_AddRef;
}
FCIMPLEND
Original file line number Diff line number Diff line change
Expand Up @@ -1337,7 +1337,7 @@ public static void RegisterForMarshalling(ComWrappers instance)
public static unsafe void GetIUnknownImpl(out IntPtr fpQueryInterface, out IntPtr fpAddRef, out IntPtr fpRelease)
{
fpQueryInterface = (IntPtr)(delegate* unmanaged<IntPtr, Guid*, IntPtr*, int>)&ComWrappers.IUnknown_QueryInterface;
fpAddRef = RuntimeImports.RhGetIUnknownAddRef(); // Implemented in C/C++ to avoid GC transitions
fpAddRef = (IntPtr)(delegate*<IntPtr, uint>)&RuntimeImports.RhIUnknown_AddRef; // Implemented in C/C++ to avoid GC transitions
fpRelease = (IntPtr)(delegate* unmanaged<IntPtr, uint>)&ComWrappers.IUnknown_Release;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -501,8 +501,14 @@ internal enum GcRestrictedCalloutKind
internal static extern unsafe void RhUnregisterRefCountedHandleCallback(IntPtr pCalloutMethod, MethodTable* pTypeFilter);

[MethodImplAttribute(MethodImplOptions.InternalCall)]
[RuntimeImport(RuntimeLibrary, "RhGetIUnknownAddRef")]
internal static extern IntPtr RhGetIUnknownAddRef();
[RuntimeImport(RuntimeLibrary,
#if TARGET_WINDOWS && TARGET_X86
"_RhIUnknown_AddRef@4"
#else
"RhIUnknown_AddRef"
#endif
)]
internal static extern uint RhIUnknown_AddRef(nint pThis);

#if FEATURE_OBJCMARSHAL
[MethodImplAttribute(MethodImplOptions.InternalCall)]
Expand Down
Loading
Loading