Skip to content

Remove assumption that Array has to implement all interfaces for MonoVM #44859

@marek-safar

Description

@marek-safar

In Mono class setup we hardcode dependency on 3 interfaces which are rarely needed and could be removed if we didn't have runtime dependency.

We should fix the metadata loaded to not require the presence of

  • System.Collections.Generic.IList`1
  • System.Collections.Generic.IReadOnlyCollection`1
  • System.Collections.Generic.IReadOnlyList`1

Or any of their individual methods

/* IList and IReadOnlyList -> 2x if enum*/
interface_count = klass->element_class->enumtype ? 4 : 2;
interfaces = (MonoClass **)mono_image_alloc0 (klass->image, sizeof (MonoClass*) * interface_count);
args [0] = m_class_get_byval_arg (m_class_get_element_class (klass));
interfaces [0] = mono_class_bind_generic_parameters (
mono_defaults.generic_ilist_class, 1, args, FALSE);
interfaces [1] = mono_class_bind_generic_parameters (
mono_defaults.generic_ireadonlylist_class, 1, args, FALSE);
if (klass->element_class->enumtype) {
args [0] = mono_class_enum_basetype_internal (klass->element_class);
interfaces [2] = mono_class_bind_generic_parameters (
mono_defaults.generic_ilist_class, 1, args, FALSE);
interfaces [3] = mono_class_bind_generic_parameters (
mono_defaults.generic_ireadonlylist_class, 1, args, FALSE);
}

@lambdageek

Metadata

Metadata

Assignees

Labels

area-VM-meta-monosize-reductionIssues impacting final app size primary for size sensitive workloads

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions