From 5f5823bc42b5e5c64adf7bb2b76a597693d8628a Mon Sep 17 00:00:00 2001 From: Milos Kotlar Date: Tue, 4 Apr 2023 17:31:29 +0200 Subject: [PATCH 01/12] Enable deduplication of runtime invoke wrappers --- src/mono/mono/mini/aot-compiler.c | 42 ++++++++++++++++++++----------- src/mono/mono/mini/aot-runtime.c | 4 --- 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/src/mono/mono/mini/aot-compiler.c b/src/mono/mono/mini/aot-compiler.c index 3310f46226544..b8b50901b5af4 100644 --- a/src/mono/mono/mini/aot-compiler.c +++ b/src/mono/mono/mini/aot-compiler.c @@ -4283,9 +4283,35 @@ get_method_index (MonoAotCompile *acfg, MonoMethod *method) return index - 1; } +static gboolean +collect_dedup_method (MonoAotCompile *acfg, MonoMethod *method) +{ + // Check if the dedup is enabled, and if the current method can be deduplicated + if ((acfg->aot_opts.dedup || acfg->aot_opts.dedup_include) && mono_aot_can_dedup (method)) { + if (!acfg->dedup_emit_mode) { + /* Remember for later */ + if (!g_hash_table_lookup (dedup_methods, method)) + g_hash_table_insert (dedup_methods, method, method); + } else if (acfg->aot_opts.dedup_include) { + // Allow emitting collected methods + return FALSE; + } + return TRUE; + } + return FALSE; +} + + + static int add_method_full (MonoAotCompile *acfg, MonoMethod *method, gboolean extra, int depth) { + if (collect_dedup_method (acfg, method)) + return -1; + + if (acfg->aot_opts.log_generics && extra) + aot_printf (acfg, "%*sAdding method %s.\n", depth, "", mono_method_get_full_name (method)); + int index; index = GPOINTER_TO_UINT (g_hash_table_lookup (acfg->method_indexes, method)); @@ -4372,20 +4398,6 @@ add_extra_method_full (MonoAotCompile *acfg, MonoMethod *method, gboolean prefer mono_error_assert_ok (error); } - if ((acfg->aot_opts.dedup || acfg->aot_opts.dedup_include) && mono_aot_can_dedup (method)) { - if (acfg->aot_opts.dedup) { - /* Don't emit instances */ - return; - } else if (!acfg->dedup_emit_mode) { - /* Remember for later */ - if (!g_hash_table_lookup (dedup_methods, method)) - g_hash_table_insert (dedup_methods, method, method); - } - } - - if (acfg->aot_opts.log_generics) - aot_printf (acfg, "%*sAdding method %s.\n", depth, "", mono_method_get_full_name (method)); - add_method_full (acfg, method, TRUE, depth); } @@ -14868,6 +14880,8 @@ aot_assembly (MonoAssembly *ass, guint32 jit_opts, MonoAotOptions *aot_options) g_hash_table_iter_init (&iter, dedup_methods); while (g_hash_table_iter_next (&iter, (gpointer *)&key, (gpointer *)&method)) add_method_full (acfg, method, TRUE, 0); + // Disable dedup_emit_mode to restrict emitting additional methods which are not collected in dedup_methods + acfg->dedup_emit_mode = FALSE; } { diff --git a/src/mono/mono/mini/aot-runtime.c b/src/mono/mono/mini/aot-runtime.c index 84b032829be53..a9eb211669115 100644 --- a/src/mono/mono/mini/aot-runtime.c +++ b/src/mono/mono/mini/aot-runtime.c @@ -4542,11 +4542,7 @@ mono_aot_can_dedup (MonoMethod *method) /* Use a set of wrappers/instances which work and useful */ switch (method->wrapper_type) { case MONO_WRAPPER_RUNTIME_INVOKE: -#ifdef TARGET_WASM return TRUE; -#else - return FALSE; -#endif break; case MONO_WRAPPER_OTHER: { WrapperInfo *info = mono_marshal_get_wrapper_info (method); From 6318c17687ba6224ca95f236d1e0776b227bc29e Mon Sep 17 00:00:00 2001 From: Milos Kotlar Date: Thu, 6 Apr 2023 13:14:20 +0200 Subject: [PATCH 02/12] Add DedupState enum and remove dedup flags --- src/mono/mono/mini/aot-compiler.c | 65 ++++++++++++++++++------------- 1 file changed, 37 insertions(+), 28 deletions(-) diff --git a/src/mono/mono/mini/aot-compiler.c b/src/mono/mono/mini/aot-compiler.c index b8b50901b5af4..165d9c7b107a7 100644 --- a/src/mono/mono/mini/aot-compiler.c +++ b/src/mono/mono/mini/aot-compiler.c @@ -217,7 +217,7 @@ typedef struct MonoAotOptions { gboolean use_trampolines_page; gboolean no_instances; // We are collecting inflated methods and emitting non-inflated - gboolean dedup; + gboolean dedup_skip; // The name of the assembly for which the AOT module is going to have all deduped methods moved to. // When set, we are emitting inflated methods only char *dedup_include; @@ -294,6 +294,13 @@ typedef struct _UnwindInfoSectionCacheItem { } UnwindInfoSectionCacheItem; #endif +typedef enum { + DEDUP_NONE, // dedup is turned off + DEDUP_SKIP, // dedup is on, dedup assembly is not provided + DEDUP_COLLECT, // dedup is on, this assembly is not the dedup image, so just collect the methods + DEDUP_EMIT // dedup is on, this assembly is the dedup image, emit collected methods +} DedupPhase; + typedef struct MonoAotCompile { MonoImage *image; GPtrArray *methods; @@ -380,7 +387,6 @@ typedef struct MonoAotCompile { gboolean llvm; gboolean has_jitted_code; gboolean is_full_aot; - gboolean dedup_collect_only; MonoAotFileFlags flags; MonoDynamicStream blob; gboolean blob_closed; @@ -415,8 +421,8 @@ typedef struct MonoAotCompile { FILE *compiled_methods_outfile; int datafile_offset; int gc_name_offset; - // In this mode, we are emitting dedupable methods that we encounter - gboolean dedup_emit_mode; + + DedupPhase dedup_phase; } MonoAotCompile; typedef struct { @@ -503,6 +509,12 @@ mono_aot_mode_is_hybrid (MonoAotOptions *opts) return opts->mode == MONO_AOT_MODE_HYBRID; } +static void +mono_aot_dedup_change_phase (MonoAotCompile *acfg, int next_phase) +{ + acfg->dedup_phase = next_phase; +} + static void aot_printf (MonoAotCompile *acfg, const gchar *format, ...) { @@ -4287,15 +4299,10 @@ static gboolean collect_dedup_method (MonoAotCompile *acfg, MonoMethod *method) { // Check if the dedup is enabled, and if the current method can be deduplicated - if ((acfg->aot_opts.dedup || acfg->aot_opts.dedup_include) && mono_aot_can_dedup (method)) { - if (!acfg->dedup_emit_mode) { - /* Remember for later */ - if (!g_hash_table_lookup (dedup_methods, method)) + if ((acfg->dedup_phase == DEDUP_SKIP || acfg->dedup_phase == DEDUP_COLLECT) && mono_aot_can_dedup (method)) { + // Remember for later + if (acfg->dedup_phase == DEDUP_COLLECT && !g_hash_table_lookup (dedup_methods, method)) g_hash_table_insert (dedup_methods, method, method); - } else if (acfg->aot_opts.dedup_include) { - // Allow emitting collected methods - return FALSE; - } return TRUE; } return FALSE; @@ -6298,7 +6305,7 @@ is_direct_callable (MonoAotCompile *acfg, MonoMethod *method, MonoJumpInfo *patc if (callee_cfg) { gboolean direct_callable = TRUE; - if (direct_callable && (acfg->aot_opts.dedup || acfg->aot_opts.dedup_include) && mono_aot_can_dedup (patch_info->data.method)) + if (direct_callable && acfg->dedup_phase != DEDUP_NONE && mono_aot_can_dedup (patch_info->data.method)) direct_callable = FALSE; if (direct_callable && !acfg->llvm && !(!callee_cfg->has_got_slots && mono_class_is_before_field_init (callee_cfg->method->klass))) @@ -8701,7 +8708,7 @@ mono_aot_parse_options (const char *aot_options, MonoAotOptions *opts) } else if (str_begins_with (arg, "internal-logfile=")) { opts->logfile = g_strdup (arg + strlen ("internal-logfile=")); } else if (str_begins_with (arg, "dedup-skip")) { - opts->dedup = TRUE; + opts->dedup_skip = TRUE; } else if (str_begins_with (arg, "dedup-include=")) { opts->dedup_include = g_strdup (arg + strlen ("dedup-include=")); } else if (str_begins_with (arg, "mtriple=")) { @@ -13955,6 +13962,7 @@ acfg_create (MonoAssembly *ass, guint32 jit_opts) acfg->gshared_instances = g_hash_table_new (NULL, NULL); acfg->prefer_instances = g_hash_table_new (NULL, NULL); acfg->exported_methods = g_ptr_array_new (); + acfg->dedup_phase = DEDUP_NONE; mono_os_mutex_init_recursive (&acfg->mutex); init_got_info (&acfg->got_info); @@ -14601,15 +14609,20 @@ aot_assembly (MonoAssembly *ass, guint32 jit_opts, MonoAotOptions *aot_options) acfg = acfg_create (ass, jit_opts); memcpy (&acfg->aot_opts, aot_options, sizeof (MonoAotOptions)); - - if (acfg->aot_opts.dedup_include && ass != dedup_assembly) - acfg->dedup_collect_only = TRUE; + if (acfg->aot_opts.dedup_skip || acfg->aot_opts.dedup_include) { + if (acfg->aot_opts.dedup_skip) + mono_aot_dedup_change_phase (acfg, DEDUP_SKIP); + else if (acfg->aot_opts.dedup_include && ass != dedup_assembly) + mono_aot_dedup_change_phase (acfg, DEDUP_COLLECT); + else + mono_aot_dedup_change_phase (acfg, DEDUP_EMIT); + } if (acfg->aot_opts.logfile) { acfg->logfile = fopen (acfg->aot_opts.logfile, "a+"); } - if (acfg->aot_opts.compiled_methods_outfile && !acfg->dedup_collect_only) { + if (acfg->aot_opts.compiled_methods_outfile && acfg->dedup_phase != DEDUP_COLLECT) { acfg->compiled_methods_outfile = fopen (acfg->aot_opts.compiled_methods_outfile, "w+"); if (!acfg->compiled_methods_outfile) aot_printerrf (acfg, "Unable to open compiled-methods-outfile specified file %s\n", acfg->aot_opts.compiled_methods_outfile); @@ -14660,14 +14673,14 @@ aot_assembly (MonoAssembly *ass, guint32 jit_opts, MonoAotOptions *aot_options) if (acfg->jit_opts & MONO_OPT_GSHAREDVT) mono_set_generic_sharing_vt_supported (TRUE); - if (!acfg->dedup_collect_only) + if (acfg->dedup_phase != DEDUP_COLLECT) aot_printf (acfg, "Mono Ahead of Time compiler - compiling assembly %s\n", image->name); if (!acfg->aot_opts.deterministic) generate_aotid ((guint8*) &acfg->image->aotid); char *aotid = mono_guid_to_string (acfg->image->aotid); - if (!acfg->dedup_collect_only && !acfg->aot_opts.deterministic) + if (acfg->dedup_phase != DEDUP_COLLECT && !acfg->aot_opts.deterministic) aot_printf (acfg, "AOTID %s\n", aotid); g_free (aotid); @@ -14773,9 +14786,9 @@ aot_assembly (MonoAssembly *ass, guint32 jit_opts, MonoAotOptions *aot_options) if (mini_safepoints_enabled ()) acfg->flags = (MonoAotFileFlags)(acfg->flags | MONO_AOT_FILE_FLAG_SAFEPOINTS); - // The methods in dedup-emit amodules must be available on runtime startup + // The methods in dedup AOT module must be available on runtime startup // Note: Only one such amodule can have this attribute - if (ass == dedup_assembly) + if (acfg->dedup_phase == DEDUP_EMIT) acfg->flags = (MonoAotFileFlags)(acfg->flags | MONO_AOT_FILE_FLAG_EAGER_LOAD); if (acfg->aot_opts.instances_logfile_path) { @@ -14867,7 +14880,7 @@ aot_assembly (MonoAssembly *ass, guint32 jit_opts, MonoAotOptions *aot_options) return 1; } - if (ass == dedup_assembly) { + if (acfg->dedup_phase == DEDUP_EMIT) { /* Add collected dedup-able methods */ aot_printf (acfg, "Adding %d dedup-ed methods.\n", g_hash_table_size (dedup_methods)); @@ -14875,13 +14888,9 @@ aot_assembly (MonoAssembly *ass, guint32 jit_opts, MonoAotOptions *aot_options) MonoMethod *key; MonoMethod *method; - acfg->dedup_emit_mode = TRUE; - g_hash_table_iter_init (&iter, dedup_methods); while (g_hash_table_iter_next (&iter, (gpointer *)&key, (gpointer *)&method)) add_method_full (acfg, method, TRUE, 0); - // Disable dedup_emit_mode to restrict emitting additional methods which are not collected in dedup_methods - acfg->dedup_emit_mode = FALSE; } { @@ -14961,7 +14970,7 @@ aot_assembly (MonoAssembly *ass, guint32 jit_opts, MonoAotOptions *aot_options) TV_GETTIME (btv); acfg->stats.jit_time = GINT64_TO_INT (TV_ELAPSED (atv, btv)); - if (acfg->dedup_collect_only) { + if (acfg->dedup_phase == DEDUP_COLLECT) { /* We only collected methods from this assembly */ acfg_free (acfg); return 0; From f225ca8134509a662e855993e46711c6796469df Mon Sep 17 00:00:00 2001 From: Milos Kotlar Date: Fri, 7 Apr 2023 10:43:24 +0200 Subject: [PATCH 03/12] Revert runtime invoke wrappers to test the library tests failures on iOS --- src/mono/mono/mini/aot-compiler.c | 6 +++--- src/mono/mono/mini/aot-runtime.c | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/mono/mono/mini/aot-compiler.c b/src/mono/mono/mini/aot-compiler.c index 165d9c7b107a7..4c095dda52e20 100644 --- a/src/mono/mono/mini/aot-compiler.c +++ b/src/mono/mono/mini/aot-compiler.c @@ -4313,9 +4313,6 @@ collect_dedup_method (MonoAotCompile *acfg, MonoMethod *method) static int add_method_full (MonoAotCompile *acfg, MonoMethod *method, gboolean extra, int depth) { - if (collect_dedup_method (acfg, method)) - return -1; - if (acfg->aot_opts.log_generics && extra) aot_printf (acfg, "%*sAdding method %s.\n", depth, "", mono_method_get_full_name (method)); @@ -4405,6 +4402,9 @@ add_extra_method_full (MonoAotCompile *acfg, MonoMethod *method, gboolean prefer mono_error_assert_ok (error); } + if (collect_dedup_method (acfg, method)) + return; + add_method_full (acfg, method, TRUE, depth); } diff --git a/src/mono/mono/mini/aot-runtime.c b/src/mono/mono/mini/aot-runtime.c index a9eb211669115..84b032829be53 100644 --- a/src/mono/mono/mini/aot-runtime.c +++ b/src/mono/mono/mini/aot-runtime.c @@ -4542,7 +4542,11 @@ mono_aot_can_dedup (MonoMethod *method) /* Use a set of wrappers/instances which work and useful */ switch (method->wrapper_type) { case MONO_WRAPPER_RUNTIME_INVOKE: +#ifdef TARGET_WASM return TRUE; +#else + return FALSE; +#endif break; case MONO_WRAPPER_OTHER: { WrapperInfo *info = mono_marshal_get_wrapper_info (method); From 95b010e977e58464635bef58218812d472721e51 Mon Sep 17 00:00:00 2001 From: Milos Kotlar Date: Fri, 7 Apr 2023 12:58:56 +0200 Subject: [PATCH 04/12] Deduplicate runtime invoke dynamic wrapper --- src/mono/mono/mini/aot-compiler.c | 7 +++++-- src/mono/mono/mini/aot-runtime.c | 4 ---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/mono/mono/mini/aot-compiler.c b/src/mono/mono/mini/aot-compiler.c index 4c095dda52e20..9a9f657a43fdc 100644 --- a/src/mono/mono/mini/aot-compiler.c +++ b/src/mono/mono/mini/aot-compiler.c @@ -4841,8 +4841,11 @@ add_wrappers (MonoAotCompile *acfg) add_method (acfg, get_runtime_invoke (acfg, method, FALSE)); #ifdef MONO_ARCH_DYN_CALL_SUPPORTED - if (!acfg->aot_opts.llvm_only) - add_method (acfg, mono_marshal_get_runtime_invoke_dynamic ()); + if (!acfg->aot_opts.llvm_only) { + method = mono_marshal_get_runtime_invoke_dynamic (); + if (!collect_dedup_method (acfg, method)) + add_method (acfg, method); + } #endif /* These are used by mono_jit_runtime_invoke () to calls gsharedvt out wrappers */ diff --git a/src/mono/mono/mini/aot-runtime.c b/src/mono/mono/mini/aot-runtime.c index 84b032829be53..a9eb211669115 100644 --- a/src/mono/mono/mini/aot-runtime.c +++ b/src/mono/mono/mini/aot-runtime.c @@ -4542,11 +4542,7 @@ mono_aot_can_dedup (MonoMethod *method) /* Use a set of wrappers/instances which work and useful */ switch (method->wrapper_type) { case MONO_WRAPPER_RUNTIME_INVOKE: -#ifdef TARGET_WASM return TRUE; -#else - return FALSE; -#endif break; case MONO_WRAPPER_OTHER: { WrapperInfo *info = mono_marshal_get_wrapper_info (method); From 66f60e69586c411021d9bdabca1e5a3dd5cd12a7 Mon Sep 17 00:00:00 2001 From: Milos Kotlar Date: Fri, 7 Apr 2023 15:41:28 +0200 Subject: [PATCH 05/12] Emit runtime invoke wrappers within corelib and dedup AOT module --- src/mono/mono/mini/aot-compiler.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mono/mono/mini/aot-compiler.c b/src/mono/mono/mini/aot-compiler.c index 9a9f657a43fdc..b50cec1c1737f 100644 --- a/src/mono/mono/mini/aot-compiler.c +++ b/src/mono/mono/mini/aot-compiler.c @@ -4843,8 +4843,8 @@ add_wrappers (MonoAotCompile *acfg) #ifdef MONO_ARCH_DYN_CALL_SUPPORTED if (!acfg->aot_opts.llvm_only) { method = mono_marshal_get_runtime_invoke_dynamic (); - if (!collect_dedup_method (acfg, method)) - add_method (acfg, method); + collect_dedup_method (acfg, method); + add_method (acfg, method); } #endif From 691ffe40808110e02c86dbdfdd854be275ddc477 Mon Sep 17 00:00:00 2001 From: Milos Kotlar Date: Mon, 10 Apr 2023 15:22:55 +0200 Subject: [PATCH 06/12] Deduplicate runtime invoke wrappers --- src/mono/mono/mini/aot-compiler.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/mono/mono/mini/aot-compiler.c b/src/mono/mono/mini/aot-compiler.c index b50cec1c1737f..165d9c7b107a7 100644 --- a/src/mono/mono/mini/aot-compiler.c +++ b/src/mono/mono/mini/aot-compiler.c @@ -4313,6 +4313,9 @@ collect_dedup_method (MonoAotCompile *acfg, MonoMethod *method) static int add_method_full (MonoAotCompile *acfg, MonoMethod *method, gboolean extra, int depth) { + if (collect_dedup_method (acfg, method)) + return -1; + if (acfg->aot_opts.log_generics && extra) aot_printf (acfg, "%*sAdding method %s.\n", depth, "", mono_method_get_full_name (method)); @@ -4402,9 +4405,6 @@ add_extra_method_full (MonoAotCompile *acfg, MonoMethod *method, gboolean prefer mono_error_assert_ok (error); } - if (collect_dedup_method (acfg, method)) - return; - add_method_full (acfg, method, TRUE, depth); } @@ -4841,11 +4841,8 @@ add_wrappers (MonoAotCompile *acfg) add_method (acfg, get_runtime_invoke (acfg, method, FALSE)); #ifdef MONO_ARCH_DYN_CALL_SUPPORTED - if (!acfg->aot_opts.llvm_only) { - method = mono_marshal_get_runtime_invoke_dynamic (); - collect_dedup_method (acfg, method); - add_method (acfg, method); - } + if (!acfg->aot_opts.llvm_only) + add_method (acfg, mono_marshal_get_runtime_invoke_dynamic ()); #endif /* These are used by mono_jit_runtime_invoke () to calls gsharedvt out wrappers */ From 92bf0ac6df4eb4afb24d4a189afcd39fc08edb64 Mon Sep 17 00:00:00 2001 From: Milos Kotlar Date: Mon, 10 Apr 2023 18:45:15 +0200 Subject: [PATCH 07/12] Run iOS tests on osx 12 as osx 10.15 is no longer in support by apple --- eng/pipelines/libraries/helix-queues-setup.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/eng/pipelines/libraries/helix-queues-setup.yml b/eng/pipelines/libraries/helix-queues-setup.yml index 32681c5466b01..c1c9ef4531a61 100644 --- a/eng/pipelines/libraries/helix-queues-setup.yml +++ b/eng/pipelines/libraries/helix-queues-setup.yml @@ -119,8 +119,6 @@ jobs: - ${{ if in(parameters.platform, 'ios_arm64') }}: # split traffic for runtime-extra-platforms (which mostly runs on rolling builds) - ${{ if ne(parameters.jobParameters.isExtraPlatforms, true) }}: - - OSX.1015.Amd64.Iphone.Open - - ${{ if eq(parameters.jobParameters.isExtraPlatforms, true) }}: - OSX.1200.Amd64.Iphone.Open # tvOS devices From 3e89528d63c8a73b861c313df24a5d79dfd9e2b8 Mon Sep 17 00:00:00 2001 From: Milos Kotlar Date: Mon, 10 Apr 2023 19:56:58 +0200 Subject: [PATCH 08/12] Change ios queue to arm64 to check if x64 is failing --- eng/pipelines/libraries/helix-queues-setup.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/pipelines/libraries/helix-queues-setup.yml b/eng/pipelines/libraries/helix-queues-setup.yml index c1c9ef4531a61..fbdd119c7b2db 100644 --- a/eng/pipelines/libraries/helix-queues-setup.yml +++ b/eng/pipelines/libraries/helix-queues-setup.yml @@ -119,7 +119,7 @@ jobs: - ${{ if in(parameters.platform, 'ios_arm64') }}: # split traffic for runtime-extra-platforms (which mostly runs on rolling builds) - ${{ if ne(parameters.jobParameters.isExtraPlatforms, true) }}: - - OSX.1200.Amd64.Iphone.Open + - OSX.13.Arm64.Iphone.Open # tvOS devices - ${{ if in(parameters.platform, 'tvos_arm64') }}: From c676e7e11fdffb6bfb0a4292119fa85e12d212b3 Mon Sep 17 00:00:00 2001 From: Milos Kotlar Date: Tue, 11 Apr 2023 12:07:15 +0200 Subject: [PATCH 09/12] Revert pipeline changes --- eng/pipelines/libraries/helix-queues-setup.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/eng/pipelines/libraries/helix-queues-setup.yml b/eng/pipelines/libraries/helix-queues-setup.yml index fbdd119c7b2db..32681c5466b01 100644 --- a/eng/pipelines/libraries/helix-queues-setup.yml +++ b/eng/pipelines/libraries/helix-queues-setup.yml @@ -119,7 +119,9 @@ jobs: - ${{ if in(parameters.platform, 'ios_arm64') }}: # split traffic for runtime-extra-platforms (which mostly runs on rolling builds) - ${{ if ne(parameters.jobParameters.isExtraPlatforms, true) }}: - - OSX.13.Arm64.Iphone.Open + - OSX.1015.Amd64.Iphone.Open + - ${{ if eq(parameters.jobParameters.isExtraPlatforms, true) }}: + - OSX.1200.Amd64.Iphone.Open # tvOS devices - ${{ if in(parameters.platform, 'tvos_arm64') }}: From d4402668ce2523135b283252210491a2892e6252 Mon Sep 17 00:00:00 2001 From: Milos Kotlar Date: Wed, 12 Apr 2023 17:30:17 +0200 Subject: [PATCH 10/12] Enable runtime logging in MonoAOTCompiler task --- src/mono/mono/mini/aot-compiler.c | 8 ++++---- src/mono/msbuild/apple/build/AppleBuild.targets | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/mono/mono/mini/aot-compiler.c b/src/mono/mono/mini/aot-compiler.c index d7ee13e411b5b..dd38d04c80f45 100644 --- a/src/mono/mono/mini/aot-compiler.c +++ b/src/mono/mono/mini/aot-compiler.c @@ -526,7 +526,7 @@ mono_aot_mode_is_hybrid (MonoAotOptions *opts) } static void -mono_aot_dedup_change_phase (MonoAotCompile *acfg, int next_phase) +dedup_change_phase (MonoAotCompile *acfg, int next_phase) { acfg->dedup_phase = next_phase; } @@ -14728,11 +14728,11 @@ aot_assembly (MonoAssembly *ass, guint32 jit_opts, MonoAotOptions *aot_options) memcpy (&acfg->aot_opts, aot_options, sizeof (MonoAotOptions)); if (acfg->aot_opts.dedup_skip || acfg->aot_opts.dedup_include) { if (acfg->aot_opts.dedup_skip) - mono_aot_dedup_change_phase (acfg, DEDUP_SKIP); + dedup_change_phase (acfg, DEDUP_SKIP); else if (acfg->aot_opts.dedup_include && ass != dedup_assembly) - mono_aot_dedup_change_phase (acfg, DEDUP_COLLECT); + dedup_change_phase (acfg, DEDUP_COLLECT); else - mono_aot_dedup_change_phase (acfg, DEDUP_EMIT); + dedup_change_phase (acfg, DEDUP_EMIT); } if (acfg->aot_opts.logfile) { diff --git a/src/mono/msbuild/apple/build/AppleBuild.targets b/src/mono/msbuild/apple/build/AppleBuild.targets index 61b656c3590d1..be000414c9673 100644 --- a/src/mono/msbuild/apple/build/AppleBuild.targets +++ b/src/mono/msbuild/apple/build/AppleBuild.targets @@ -258,7 +258,8 @@ ProjectName="$(AssemblyName)" RuntimeComponents="$(RuntimeComponents)" TargetOS="$(TargetOS)" - UseConsoleUITemplate="True"> + UseConsoleUITemplate="True" + EnableRuntimeLogging="True"> From 3b5ed5ae55db0afa8e50774640d8c902dc6f67be Mon Sep 17 00:00:00 2001 From: Milos Kotlar Date: Thu, 13 Apr 2023 09:10:06 +0200 Subject: [PATCH 11/12] Revert deduplication of runtime invoke wrappers --- src/mono/mono/mini/aot-compiler.c | 12 ++++++------ src/mono/mono/mini/aot-runtime.c | 5 ++++- src/mono/msbuild/apple/build/AppleBuild.targets | 3 +-- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/mono/mono/mini/aot-compiler.c b/src/mono/mono/mini/aot-compiler.c index dd38d04c80f45..87667e2073dbe 100644 --- a/src/mono/mono/mini/aot-compiler.c +++ b/src/mono/mono/mini/aot-compiler.c @@ -4330,12 +4330,6 @@ collect_dedup_method (MonoAotCompile *acfg, MonoMethod *method) static int add_method_full (MonoAotCompile *acfg, MonoMethod *method, gboolean extra, int depth) { - if (collect_dedup_method (acfg, method)) - return -1; - - if (acfg->aot_opts.log_generics && extra) - aot_printf (acfg, "%*sAdding method %s.\n", depth, "", mono_method_get_full_name (method)); - int index; index = GPOINTER_TO_UINT (g_hash_table_lookup (acfg->method_indexes, method)); @@ -4422,6 +4416,12 @@ add_extra_method_full (MonoAotCompile *acfg, MonoMethod *method, gboolean prefer mono_error_assert_ok (error); } + if (collect_dedup_method (method)) + return; + + if (acfg->aot_opts.log_generics) + aot_printf (acfg, "%*sAdding method %s.\n", depth, "", mono_method_get_full_name (method)); + add_method_full (acfg, method, TRUE, depth); } diff --git a/src/mono/mono/mini/aot-runtime.c b/src/mono/mono/mini/aot-runtime.c index a9eb211669115..fa11dc8ed57d4 100644 --- a/src/mono/mono/mini/aot-runtime.c +++ b/src/mono/mono/mini/aot-runtime.c @@ -4542,8 +4542,11 @@ mono_aot_can_dedup (MonoMethod *method) /* Use a set of wrappers/instances which work and useful */ switch (method->wrapper_type) { case MONO_WRAPPER_RUNTIME_INVOKE: +#ifdef TARGET_WASM return TRUE; - break; +#else + return FALSE; +#endif case MONO_WRAPPER_OTHER: { WrapperInfo *info = mono_marshal_get_wrapper_info (method); diff --git a/src/mono/msbuild/apple/build/AppleBuild.targets b/src/mono/msbuild/apple/build/AppleBuild.targets index be000414c9673..61b656c3590d1 100644 --- a/src/mono/msbuild/apple/build/AppleBuild.targets +++ b/src/mono/msbuild/apple/build/AppleBuild.targets @@ -258,8 +258,7 @@ ProjectName="$(AssemblyName)" RuntimeComponents="$(RuntimeComponents)" TargetOS="$(TargetOS)" - UseConsoleUITemplate="True" - EnableRuntimeLogging="True"> + UseConsoleUITemplate="True"> From 769e95cc6cbe6f27e1f734b81a7a85ed0d1c935e Mon Sep 17 00:00:00 2001 From: Milos Kotlar Date: Thu, 13 Apr 2023 09:29:55 +0200 Subject: [PATCH 12/12] Add missing parameter to collect_dedup_methods --- src/mono/mono/mini/aot-compiler.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/mono/mini/aot-compiler.c b/src/mono/mono/mini/aot-compiler.c index 87667e2073dbe..5cb0a2ad1888c 100644 --- a/src/mono/mono/mini/aot-compiler.c +++ b/src/mono/mono/mini/aot-compiler.c @@ -4416,7 +4416,7 @@ add_extra_method_full (MonoAotCompile *acfg, MonoMethod *method, gboolean prefer mono_error_assert_ok (error); } - if (collect_dedup_method (method)) + if (collect_dedup_method (acfg, method)) return; if (acfg->aot_opts.log_generics)