Skip to content

[mono] Simplify runtime assembly representation/remove MonoImage/MonoAssembly split #41569

Open
@CoffeeFlux

Description

@CoffeeFlux

In Mono, we have historically used two high-level structs on the native side to store assembly information—MonoImage and MonoAssembly. The split existed primarily due to MonoImage sharing across domains and multi-module assemblies, neither of which exist in .NET Core and will never be brought back.

For ALC support, we already ensured that on netcore we have a 1:1 relationship between a MonoImage and a MonoAssembly, and each MonoAssembly is tied to a single ALC. For netcore, we could viably get rid of MonoImage entirely and probably also stop refcounting the MonoAssembly. We might still want to move some of the information previous in MonoImage or MonoAssembly into a struct below the main one, but we should have a single top level struct to represent an assembly on the native side and a consistent load process to produce it.

The three main things preventing this are:

  • Internal MonoImage * usage
  • Embedding MonoImage * usage
  • mono/mono support

I think for both MonoImage * cases, the solution would be to eliminate usage of the MonoImage struct within the loader itself and then just have an empty MonoImage * that ties back to the MonoAssembly *. Internally, we access some of the MonoImage fields directly and those cases would probably need to be switched to use an accessor function. For embedders, this should be fairly opaque, though we would probably end up creating more external-only functions taking in a MonoImage * as we switch over to MonoAssembly * everywhere internally.

mono/mono support is a little harder. We already have a lot of fairly distinct loader paths for netcore and legacy, so I personally think it's viable to just split this up further. If we stop mirroring at some point, this becomes much easier.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions