Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mono][interp] Fix resizing of ref slots bitset #100907

Merged
merged 2 commits into from
Apr 11, 2024
Merged
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
6 changes: 4 additions & 2 deletions src/mono/mono/mini/interp/transform.c
Original file line number Diff line number Diff line change
Expand Up @@ -8553,7 +8553,7 @@ interp_mark_ref_slots_for_vt (TransformData *td, int base_offset, MonoClass *kla
retry:
if (mini_type_is_reference (ftype) || ftype->type == MONO_TYPE_I || ftype->type == MONO_TYPE_U || m_type_is_byref (ftype)) {
int index = offset / sizeof (gpointer);
mono_bitset_set_fast (td->ref_slots, index);
mono_bitset_set (td->ref_slots, index);
if (td->verbose_level)
g_print ("Stack ref slot vt field at off %d\n", offset);
} else if (ftype->type == MONO_TYPE_VALUETYPE || ftype->type == MONO_TYPE_GENERICINST) {
Expand Down Expand Up @@ -8585,6 +8585,8 @@ interp_mark_ref_slots_for_var (TransformData *td, int var)
if (!td->ref_slots || max_index >= td->ref_slots->size) {
guint32 old_size = td->ref_slots ? (guint32)td->ref_slots->size : 0;
guint32 new_size = old_size ? old_size * 2 : 32;
while (new_size <= max_index)
new_size *= 2;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it matter if it allocates new_size > max_index? Should it go up to max_index instead?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That might produce further reallocation, but it is also valid. I don't think it matters much


gpointer mem = mono_mempool_alloc0 (td->mempool, mono_bitset_alloc_size (new_size, 0));
MonoBitSet *new_ref_slots = mono_bitset_mem_new (mem, new_size, 0);
Expand All @@ -8602,7 +8604,7 @@ interp_mark_ref_slots_for_var (TransformData *td, int var)
// Managed pointers in interp are normally MONO_TYPE_I
if (mini_type_is_reference (type) || type->type == MONO_TYPE_I || type->type == MONO_TYPE_U || m_type_is_byref (type)) {
int index = td->vars [var].offset / sizeof (gpointer);
mono_bitset_set_fast (td->ref_slots, index);
mono_bitset_set (td->ref_slots, index);
if (td->verbose_level)
g_print ("Stack ref slot at off %d for var %d\n", index * sizeof (gpointer), var);
}
Expand Down
Loading