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
18 changes: 13 additions & 5 deletions src/mono/mono/metadata/assembly-load-context.c
Original file line number Diff line number Diff line change
Expand Up @@ -424,11 +424,19 @@ mono_alc_from_gchandle (MonoGCHandle alc_gchandle)
if (alc_gchandle == default_alc->gchandle)
return default_alc;

HANDLE_FUNCTION_ENTER ();
MonoManagedAssemblyLoadContextHandle managed_alc = MONO_HANDLE_CAST (MonoManagedAssemblyLoadContext, mono_gchandle_get_target_handle (alc_gchandle));
g_assert (!MONO_HANDLE_IS_NULL (managed_alc));
MonoAssemblyLoadContext *alc = MONO_HANDLE_GETVAL (managed_alc, native_assembly_load_context);
HANDLE_FUNCTION_RETURN_VAL (alc);
MONO_STATIC_POINTER_INIT (MonoClassField, resolve)

MonoClass *alc_class = mono_class_get_assembly_load_context_class ();
g_assert (alc_class);
resolve = mono_class_get_field_from_name_full (alc_class, "_nativeAssemblyLoadContext", NULL);

MONO_STATIC_POINTER_INIT_END (MonoClassField, resolve)

g_assert (resolve);

MonoAssemblyLoadContext *alc = NULL;
mono_field_get_value_internal (mono_gchandle_get_target_internal (alc_gchandle), resolve, &alc);
return alc;
}

MonoGCHandle
Expand Down
7 changes: 0 additions & 7 deletions src/mono/mono/metadata/object-internals.h
Original file line number Diff line number Diff line change
Expand Up @@ -1406,13 +1406,6 @@ typedef enum {
UNLOADING = 1
} MonoManagedAssemblyLoadContextInternalState;

// Keep in sync with System.Runtime.Loader.AssemblyLoadContext
typedef struct {
MonoObject object;
MonoAssemblyLoadContext *native_assembly_load_context;
} MonoManagedAssemblyLoadContext;

TYPED_HANDLE_DECL (MonoManagedAssemblyLoadContext);

/* All MonoInternalThread instances should be pinned, so it's safe to use the raw ptr. However
* for uniformity, icall wrapping will make handles anyway. So this is the method for getting the payload.
Expand Down