Skip to content

Commit

Permalink
[mono][aot] Avoid emitting gshared methods multiple times when prefer…
Browse files Browse the repository at this point in the history
…ring instances of them. (#80100)

This fixes a part of the size regression added by c7c6aa0.
  • Loading branch information
vargaz authored Jan 5, 2023
1 parent 92d7381 commit 5c36a27
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/mono/mono/mini/aot-compiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -4346,9 +4346,11 @@ add_extra_method_full (MonoAotCompile *acfg, MonoMethod *method, gboolean prefer
return;
}

if (g_hash_table_lookup (acfg->prefer_instances, method))
/* Compile an instance as well */
if (g_hash_table_lookup (acfg->prefer_instances, method) && !is_open_method (orig)) {
/* Compile an instance instead */
add_extra_method_full (acfg, orig, FALSE, depth);
return;
}

/* Add it to profile_methods so its not skipped later */
if (acfg->aot_opts.profile_only && g_hash_table_lookup (acfg->profile_methods, orig))
Expand Down Expand Up @@ -9282,6 +9284,7 @@ compile_method (MonoAotCompile *acfg, MonoMethod *method)
* for performance reasons, since gshared methods cannot implement some
* features like static virtual methods efficiently.
*/
/* Instances encountered later will be handled in add_extra_method_full () */
g_hash_table_insert (acfg->prefer_instances, method, method);
GPtrArray *instances = g_hash_table_lookup (acfg->gshared_instances, method);
if (instances) {
Expand Down

0 comments on commit 5c36a27

Please sign in to comment.