Skip to content

Commit 14f87e8

Browse files
Add back coreclr_unity_profiler_assembly_load_context_get_loader_allocator_handle to simplify landing
1 parent 91ac4f8 commit 14f87e8

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

src/coreclr/dlls/mscoree/mscorwks_ntdef.src

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ EXPORTS
3636
coreclr_unity_profiler_register
3737
coreclr_unity_profiler_class_get_assembly_load_context_handle
3838
coreclr_unity_profiler_get_managed_assembly_load_context
39+
coreclr_unity_profiler_assembly_load_context_get_loader_allocator_handle
3940
coreclr_unity_profiler_loader_allocator_get_assembly_load_context_handle
4041
coreclr_unity_gc_concurrent_mode
4142
mono_assembly_get_assemblyref

src/coreclr/dlls/mscoree/mscorwks_unixexports.src

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ coreclr_unity_class_array_element_size
2222
coreclr_unity_profiler_register
2323
coreclr_unity_profiler_class_get_assembly_load_context_handle
2424
coreclr_unity_profiler_get_managed_assembly_load_context
25+
coreclr_unity_profiler_assembly_load_context_get_loader_allocator_handle
2526
coreclr_unity_profiler_loader_allocator_get_assembly_load_context_handle
2627
coreclr_unity_gc_concurrent_mode
2728
mono_assembly_get_assemblyref

src/coreclr/vm/mono/mono_coreclr.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,26 @@ extern "C" EXPORT_API ObjectHandleID EXPORT_CC coreclr_unity_profiler_get_manage
789789
return (ObjectHandleID)pAssemblyBinder->GetManagedAssemblyLoadContext();
790790
}
791791

792+
extern "C" EXPORT_API ObjectHandleID EXPORT_CC coreclr_unity_profiler_assembly_load_context_get_loader_allocator_handle(ObjectID assemblyLoadContextObjectID)
793+
{
794+
STATIC_CONTRACT_NOTHROW;
795+
796+
ASSEMBLYLOADCONTEXTREF pAssemblyLoadContext = (ASSEMBLYLOADCONTEXTREF)assemblyLoadContextObjectID;
797+
if (pAssemblyLoadContext == NULL)
798+
return NULL;
799+
800+
AssemblyBinder* pAssemblyBinder = (AssemblyBinder*)pAssemblyLoadContext->GetNativeAssemblyBinder();
801+
if (pAssemblyBinder == NULL)
802+
return NULL;
803+
804+
LoaderAllocator* loaderAllocator = pAssemblyBinder->GetLoaderAllocator();
805+
if (loaderAllocator == NULL)
806+
return NULL;
807+
808+
// ManagedAssemblyLoadContext is a handle to the managed AssemblyLoadContext object
809+
return (ObjectHandleID)loaderAllocator->GetLoaderAllocatorObjectHandle();
810+
}
811+
792812
// Return the AssemblyLoadContext handle for the given LoaderAllocator checking whether or not LoaderAllocator is still alive.
793813
// LoaderAllocator is the main object that tracks AssemblyLoadContext liveness as AssemblyLoadContext is a simple wrapper around a native
794814
// reference to LoaderAllocator.

0 commit comments

Comments
 (0)