From fb3f7ab91e99429cfdf0db526b0bbac05e0621c1 Mon Sep 17 00:00:00 2001 From: Aleksey Kliger Date: Tue, 18 Apr 2023 11:40:16 -0400 Subject: [PATCH] remove old emscripten keepalive workaround hack --- src/mono/mono/metadata/threads.c | 26 ------------------------- src/mono/mono/utils/mono-threads-wasm.h | 14 ------------- 2 files changed, 40 deletions(-) diff --git a/src/mono/mono/metadata/threads.c b/src/mono/mono/metadata/threads.c index 374f6ae27aaf4..abe6cae20c51e 100644 --- a/src/mono/mono/metadata/threads.c +++ b/src/mono/mono/metadata/threads.c @@ -1116,11 +1116,6 @@ fire_attach_profiler_events (MonoNativeThreadId tid) } -#ifdef MONO_EMSCRIPTEN_KEEPALIVE_WORKAROUND_HACK -/* See ves_icall_System_Threading_WebWorkerEventLoop_KeepalivePopInternal */ -__thread uint mono_emscripten_keepalive_hack_count; -#endif - static guint32 WINAPI start_wrapper_internal (StartInfo *start_info, gsize *stack_ptr) { @@ -4979,9 +4974,6 @@ ves_icall_System_Threading_LowLevelLifoSemaphore_ReleaseInternal (gpointer sem_p void ves_icall_System_Threading_WebWorkerEventLoop_KeepalivePushInternal (void) { -#ifdef MONO_EMSCRIPTEN_KEEPALIVE_WORKAROUND_HACK - mono_emscripten_keepalive_hack_count++; -#endif emscripten_runtime_keepalive_push(); } @@ -4989,24 +4981,6 @@ void ves_icall_System_Threading_WebWorkerEventLoop_KeepalivePopInternal (void) { emscripten_runtime_keepalive_pop(); -#ifdef MONO_EMSCRIPTEN_KEEPALIVE_WORKAROUND_HACK - /* This is a BAD IDEA: - * - * 1. We don't know if there were non-mono callers of emscripten_runtime_keepalive_push. We - * could be dropping a thread that was meant to stay alive. - * - * 2. mono_thread_exit while we have managed frames on the stack means we might leak - * resource since finally clauses didn't run. Also the mono interpreter doesn't really get - * a chance to clean up. - * - * - */ - mono_emscripten_keepalive_hack_count--; - if (!mono_emscripten_keepalive_hack_count) { - g_warning ("thread %p mono keepalive count is zero, detaching\n", (void*)(intptr_t)pthread_self()); - mono_thread_exit(); - } -#endif } extern int mono_wasm_eventloop_has_unsettled_interop_promises(void); diff --git a/src/mono/mono/utils/mono-threads-wasm.h b/src/mono/mono/utils/mono-threads-wasm.h index b76606045ecb8..c06d8501e1ec3 100644 --- a/src/mono/mono/utils/mono-threads-wasm.h +++ b/src/mono/mono/utils/mono-threads-wasm.h @@ -11,20 +11,6 @@ #include #include -#if defined(HOST_BROWSER) && !defined(DISABLE_THREADS) -#include -/* for Emscripten < 3.1.33, - * emscripten_runtime_keepalive_push()/emscripten_runtime_keepalive_pop()/emscripten_keepalive_check() - * are no-ops when -sNO_EXIT_RUNTIME=1 (the default). Do our own bookkeeping when we can. Note - * that this is a HACK that is very sensitive to code that actually cares about this bookkeeping. - * - * Specifically we need https://github.com/emscripten-core/emscripten/commit/0c2f5896b839e25fee9763a9ac9c619f359988f4 - */ -#if (__EMSCRIPTEN_major__ < 3) || (__EMSCRIPTEN_major__ == 3 && __EMSCRIPTEN_minor__ < 1) || (__EMSCRIPTEN_major__ == 3 && __EMSCRIPTEN_minor__ == 1 && __EMSCRIPTEN_tiny__ < 33) -#define MONO_EMSCRIPTEN_KEEPALIVE_WORKAROUND_HACK 1 -#endif -#endif /*HOST_BROWSER && !DISABLE_THREADS*/ - #ifdef HOST_WASM /*