Skip to content

[mono] Optimize computing of a bitmap for structs with InlineArray attribute #84116

Closed as not planned
@kotlarmilos

Description

@kotlarmilos

Description

The current implementation of bitmap for structs with InlineArray attribute iterates N times and computes ref positions in the bitmap. It could be changed to copy the bitmap of the field N times instead of redoing the whole loop (bitcopy might be implemented using memcpy).

guint32 field_pos = pos; /* save where the bitmap starts for the first field */
while (fields_iter...) {
}
if (m_class_is_inlinearray (klass) {
  guint32 after_field_pos = pos;
  guint32 field_bits_size = after_field_pos - field_pos;
  /* make N-1 additional copies of the bits from field_pos to current pos */
  for (int i = 1; i < m_class_inlinearray_value (klass); i++) {
    bitcopy (bitmap, field_pos, pos, field_bits_size);
    pos += field_bits_size;
    /* TODO: also update max_set */
  }
}

Furthermore, it could encode an inlined vector in the middle of another descriptor. Function mono_class_compute_gc_descriptor could be updated for valuetypes [that contain valuetypes] that contain inlined arrays. Instead of just computing a bitmap, it could finding the maximal repeating sequence in the middle of a bit sequence to creates an sgen descriptor directly.

/cc: @lambdageek @BrzVlad

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions