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][aot] Make the dedup mode output deterministic. #99128

Merged
merged 1 commit into from
Mar 1, 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
17 changes: 9 additions & 8 deletions src/mono/mono/mini/aot-compiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,7 @@ static MonoAotCompile *llvm_acfg;
static MonoAotCompile *current_acfg;
static MonoAssembly *dedup_assembly;
static GHashTable *dedup_methods;
static GPtrArray *dedup_methods_list;

/* Cache of decoded method external icall symbol names. */
/* Owned by acfg, but kept in this static as well since it is */
Expand Down Expand Up @@ -4351,11 +4352,13 @@ collect_dedup_method (MonoAotCompile *acfg, MonoMethod *method)
return TRUE;
// Remember for later
g_assert (acfg->dedup_phase == DEDUP_COLLECT);
if (!g_hash_table_lookup (dedup_methods, method))
if (!g_hash_table_lookup (dedup_methods, method)) {
g_hash_table_insert (dedup_methods, method, method);
else
g_ptr_array_add (dedup_methods_list, method);
} else {
// Already processed when compiling another assembly
return TRUE;
}
}
return FALSE;
}
Expand Down Expand Up @@ -15099,13 +15102,10 @@ aot_assembly (MonoAssembly *ass, guint32 jit_opts, MonoAotOptions *aot_options)
/* Add collected dedup-able methods */
aot_printf (acfg, "Adding %d dedup-ed methods.\n", g_hash_table_size (dedup_methods));

GHashTableIter iter;
MonoMethod *key;
MonoMethod *method;

g_hash_table_iter_init (&iter, dedup_methods);
while (g_hash_table_iter_next (&iter, (gpointer *)&key, (gpointer *)&method))
for (guint i = 0; i < dedup_methods_list->len; ++i) {
MonoMethod *method = (MonoMethod*)g_ptr_array_index (dedup_methods_list, i);
add_method_full (acfg, method, TRUE, 0);
}
}

{
Expand Down Expand Up @@ -15570,6 +15570,7 @@ mono_aot_assemblies (MonoAssembly **assemblies, int nassemblies, guint32 jit_opt
assemblies [dedup_aindex] = atmp;

dedup_methods = g_hash_table_new (NULL, NULL);
dedup_methods_list = g_ptr_array_new ();
}

if (aot_opts.trimming_eligible_methods_outfile) {
Expand Down
Loading