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

[release/8.0] [mono][metadata] Replace use of mem manager lock with loader lock #91327

Merged
merged 2 commits into from
Aug 30, 2023
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
15 changes: 9 additions & 6 deletions src/mono/mono/metadata/metadata.c
Original file line number Diff line number Diff line change
Expand Up @@ -3434,7 +3434,8 @@ mono_metadata_get_canonical_generic_inst (MonoGenericInst *candidate)
MonoMemoryManager *mm = mono_mem_manager_get_generic (data.images, data.nimages);
collect_data_free (&data);

mono_mem_manager_lock (mm);
// Hashtable key equal func can take loader lock
mono_loader_lock ();

if (!mm->ginst_cache)
mm->ginst_cache = g_hash_table_new_full (mono_metadata_generic_inst_hash, mono_metadata_generic_inst_equal, NULL, (GDestroyNotify)free_generic_inst);
Expand All @@ -3456,7 +3457,7 @@ mono_metadata_get_canonical_generic_inst (MonoGenericInst *candidate)
g_hash_table_insert (mm->ginst_cache, ginst, ginst);
}

mono_mem_manager_unlock (mm);
mono_loader_unlock ();

return ginst;
}
Expand All @@ -3467,7 +3468,8 @@ mono_metadata_get_canonical_aggregate_modifiers (MonoAggregateModContainer *cand
g_assert (candidate->count > 0);
MonoMemoryManager *mm = mono_metadata_get_mem_manager_for_aggregate_modifiers (candidate);

mono_mem_manager_lock (mm);
// Hashtable key equal func can take loader lock
mono_loader_lock ();

if (!mm->aggregate_modifiers_cache)
mm->aggregate_modifiers_cache = g_hash_table_new_full (aggregate_modifiers_hash, aggregate_modifiers_equal, NULL, (GDestroyNotify)free_aggregate_modifiers);
Expand All @@ -3484,7 +3486,7 @@ mono_metadata_get_canonical_aggregate_modifiers (MonoAggregateModContainer *cand

g_hash_table_insert (mm->aggregate_modifiers_cache, amods, amods);
}
mono_mem_manager_unlock (mm);
mono_loader_unlock ();
return amods;
}

Expand Down Expand Up @@ -3543,7 +3545,8 @@ mono_metadata_lookup_generic_class (MonoClass *container_class, MonoGenericInst
if (gclass)
return gclass;

mono_mem_manager_lock (mm);
// Hashtable key equal func can take loader lock
mono_loader_lock ();

gclass = mono_mem_manager_alloc0 (mm, sizeof (MonoGenericClass));
if (is_dynamic)
Expand All @@ -3563,7 +3566,7 @@ mono_metadata_lookup_generic_class (MonoClass *container_class, MonoGenericInst

// g_hash_table_insert (set->gclass_cache, gclass, gclass);

mono_mem_manager_unlock (mm);
mono_loader_unlock ();

return gclass2;
}
Expand Down
Loading