Skip to content

Commit 6da0fa9

Browse files
authored
[mono][gc] Fix gc descriptor computation for InlineArray structs (#116879)
1 parent baec721 commit 6da0fa9

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/mono/mono/metadata/object.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -906,9 +906,13 @@ compute_class_bitmap (MonoClass *klass, gsize *bitmap, int size, int offset, int
906906

907907
guint32 field_iter = 1;
908908
guint32 field_instance_offset = field_offset;
909+
int field_size = 0;
909910
// If struct has InlineArray attribute, iterate `length` times to set a bitmap
910-
if (m_class_is_inlinearray (p))
911+
if (m_class_is_inlinearray (p)) {
912+
int align;
911913
field_iter = mono_class_get_inlinearray_value (p);
914+
field_size = mono_type_size (field->type, &align);
915+
}
912916

913917
if (field_iter > 500)
914918
g_warning ("Large number of iterations detected when creating a GC bitmap, might affect performance.");
@@ -973,7 +977,7 @@ compute_class_bitmap (MonoClass *klass, gsize *bitmap, int size, int offset, int
973977
break;
974978
}
975979

976-
field_instance_offset += field_offset;
980+
field_instance_offset += field_size;
977981
field_iter--;
978982
}
979983
}

0 commit comments

Comments
 (0)