Skip to content

Commit

Permalink
remove old emscripten keepalive workaround hack
Browse files Browse the repository at this point in the history
  • Loading branch information
lambdageek committed Apr 18, 2023
1 parent 9b8297f commit fb3f7ab
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 40 deletions.
26 changes: 0 additions & 26 deletions src/mono/mono/metadata/threads.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -4979,34 +4974,13 @@ 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();
}

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);
Expand Down
14 changes: 0 additions & 14 deletions src/mono/mono/utils/mono-threads-wasm.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,6 @@
#include <glib.h>
#include <mono/utils/mono-threads.h>

#if defined(HOST_BROWSER) && !defined(DISABLE_THREADS)
#include <emscripten/version.h>
/* 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

/*
Expand Down

0 comments on commit fb3f7ab

Please sign in to comment.