From e7e71d4925d5b57f5f1baa36e4d2dd9b5e72efd1 Mon Sep 17 00:00:00 2001 From: Katelyn Gadd Date: Mon, 8 Apr 2024 22:22:43 -0700 Subject: [PATCH 1/2] Don't probe for aot modules in emscripten builds unless we were explicitly built for AOT, because emscripten dlopen is very expensive --- src/mono/mono/mini/aot-runtime.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/mono/mono/mini/aot-runtime.c b/src/mono/mono/mini/aot-runtime.c index bdd39e400edca..7e32c5fab7b4a 100644 --- a/src/mono/mono/mini/aot-runtime.c +++ b/src/mono/mono/mini/aot-runtime.c @@ -1971,6 +1971,12 @@ load_aot_module (MonoAssemblyLoadContext *alc, MonoAssembly *assembly, gpointer if (mono_aot_mode == MONO_AOT_MODE_NONE) return; +#ifdef __EMSCRIPTEN__ + // This indicates that we were not built for AOT, so there's no need to probe for AOT modules. + if (mono_aot_mode == MONO_AOT_MODE_INTERP_ONLY) + return; +#endif + if (assembly->image->aot_module) /* * Already loaded. This can happen because the assembly loading code might invoke @@ -2480,7 +2486,7 @@ load_container_amodule (MonoAssemblyLoadContext *alc) mono_loader_lock (); // There might be several threads that passed the first check - // Adding another check to ensure single load of a container assembly due to race condition + // Adding another check to ensure single load of a container assembly due to race condition if (!container_amodule) { ERROR_DECL (error); From ab79837556f565a8b885fd2ee350807a77c4f428 Mon Sep 17 00:00:00 2001 From: Katelyn Gadd Date: Tue, 9 Apr 2024 10:44:11 -0700 Subject: [PATCH 2/2] Update src/mono/mono/mini/aot-runtime.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Aleksey Kliger (λgeek) --- src/mono/mono/mini/aot-runtime.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mono/mono/mini/aot-runtime.c b/src/mono/mono/mini/aot-runtime.c index 7e32c5fab7b4a..95c4b8236bc3b 100644 --- a/src/mono/mono/mini/aot-runtime.c +++ b/src/mono/mono/mini/aot-runtime.c @@ -1971,7 +1971,7 @@ load_aot_module (MonoAssemblyLoadContext *alc, MonoAssembly *assembly, gpointer if (mono_aot_mode == MONO_AOT_MODE_NONE) return; -#ifdef __EMSCRIPTEN__ +#ifdef HOST_BROWSER // This indicates that we were not built for AOT, so there's no need to probe for AOT modules. if (mono_aot_mode == MONO_AOT_MODE_INTERP_ONLY) return;