diff --git a/src/library_pthread.js b/src/library_pthread.js index bff45471ffab..31349149a88c 100644 --- a/src/library_pthread.js +++ b/src/library_pthread.js @@ -551,14 +551,14 @@ var LibraryPThread = { worker.pthread_ptr = 0; }, - __emscripten_thread_cleanup: (thread) => { + _emscripten_thread_cleanup: (thread) => { // Called when a thread needs to be cleaned up so it can be reused. // A thread is considered reusable when it either returns from its // entry point, calls pthread_exit, or acts upon a cancellation. // Detached threads are responsible for calling this themselves, // otherwise pthread_join is responsible for calling this. #if PTHREADS_DEBUG - dbg(`__emscripten_thread_cleanup: ${ptrToString(thread)}`) + dbg(`_emscripten_thread_cleanup: ${ptrToString(thread)}`) #endif if (!ENVIRONMENT_IS_PTHREAD) cleanupThread(thread); else postMessage({ 'cmd': 'cleanupThread', 'thread': thread }); @@ -702,7 +702,7 @@ var LibraryPThread = { #endif navigator['hardwareConcurrency'], - __emscripten_init_main_thread_js: (tb) => { + _emscripten_init_main_thread_js: (tb) => { // Pass the thread address to the native code where they stored in wasm // globals which act as a form of TLS. Global constructors trying // to access this value will read the wrong value, but that is UB anyway. diff --git a/src/library_sigs.js b/src/library_sigs.js index 1c09ee3ce962..c0c68dcd26df 100644 --- a/src/library_sigs.js +++ b/src/library_sigs.js @@ -225,8 +225,6 @@ sigs = { __cxa_rethrow_primary_exception__sig: 'vp', __cxa_throw__sig: 'vppp', __cxa_uncaught_exceptions__sig: 'i', - __emscripten_init_main_thread_js__sig: 'vp', - __emscripten_thread_cleanup__sig: 'vp', __handle_stack_overflow__sig: 'vp', __pthread_create_js__sig: 'ipppp', __pthread_kill_js__sig: 'ipi', @@ -324,6 +322,7 @@ sigs = { _emscripten_fs_load_embedded_files__sig: 'vp', _emscripten_get_now_is_monotonic__sig: 'i', _emscripten_get_progname__sig: 'vpi', + _emscripten_init_main_thread_js__sig: 'vp', _emscripten_lookup_name__sig: 'ip', _emscripten_memcpy_js__sig: 'vppp', _emscripten_notify_mailbox_postmessage__sig: 'vppp', @@ -333,6 +332,7 @@ sigs = { _emscripten_runtime_keepalive_clear__sig: 'v', _emscripten_set_offscreencanvas_size__sig: 'ipii', _emscripten_system__sig: 'ip', + _emscripten_thread_cleanup__sig: 'vp', _emscripten_thread_exit_joinable__sig: 'vp', _emscripten_thread_mailbox_await__sig: 'vp', _emscripten_thread_set_strongref__sig: 'vp', diff --git a/src/library_wasm_worker.js b/src/library_wasm_worker.js index 6a1073ae6fb5..f9fdcf6a922d 100644 --- a/src/library_wasm_worker.js +++ b/src/library_wasm_worker.js @@ -73,7 +73,7 @@ addToLibrary({ '$_wasmWorkerDelayedMessageQueue', '$_wasmWorkerRunPostMessage', '$_wasmWorkerAppendToQueue', - 'emscripten_wasm_worker_initialize', + '_emscripten_wasm_worker_initialize', #if PTHREADS '__set_thread_state', #endif @@ -96,7 +96,7 @@ addToLibrary({ ___set_stack_limits(m['sb'] + m['sz'], m['sb']); #endif // Run the C side Worker initialization for stack and TLS. - _emscripten_wasm_worker_initialize(m['sb'], m['sz']); + __emscripten_wasm_worker_initialize(m['sb'], m['sz']); #if PTHREADS // Record that this Wasm Worker supports synchronous blocking in emscripten_futex_wake(). ___set_thread_state(/*thread_ptr=*/0, /*is_main_thread=*/0, /*is_runtime_thread=*/0, /*supports_wait=*/0); diff --git a/system/lib/compiler-rt/stack_limits.S b/system/lib/compiler-rt/stack_limits.S index 7bb9d895c46e..1c4c719fa18a 100644 --- a/system/lib/compiler-rt/stack_limits.S +++ b/system/lib/compiler-rt/stack_limits.S @@ -85,9 +85,9 @@ emscripten_stack_get_free: #ifdef __EMSCRIPTEN_WASM_WORKERS__ # TODO: Relocate the following to its own file wasm_worker.S, but need to figure out how to reference # __stack_base and __stack_end globals from a separate file as externs in order for that to work. -.globl emscripten_wasm_worker_initialize -emscripten_wasm_worker_initialize: - .functype emscripten_wasm_worker_initialize (PTR /*stackLowestAddress*/, i32 /*stackSize*/) -> () +.globl _emscripten_wasm_worker_initialize +_emscripten_wasm_worker_initialize: + .functype _emscripten_wasm_worker_initialize (PTR /*stackLowestAddress*/, i32 /*stackSize*/) -> () // __stack_end = stackLowestAddress + (__builtin_wasm_tls_size() + 15) & -16; local.get 0 diff --git a/system/lib/libc/musl/src/thread/pthread_join.c b/system/lib/libc/musl/src/thread/pthread_join.c index d209324a9ab8..a5d539b65175 100644 --- a/system/lib/libc/musl/src/thread/pthread_join.c +++ b/system/lib/libc/musl/src/thread/pthread_join.c @@ -45,7 +45,7 @@ static int __pthread_timedjoin_np(pthread_t t, void **res, const struct timespec if (res) *res = t->result; #ifdef __EMSCRIPTEN__ // Thread was exited during this call, be sure to clean it up. - if (state == DT_EXITED) __emscripten_thread_cleanup(t); + if (state == DT_EXITED) _emscripten_thread_cleanup(t); #else // XXX Emscripten map_base unused if (t->map_base) __munmap(t->map_base, t->map_size); #endif diff --git a/system/lib/pthread/library_pthread.c b/system/lib/pthread/library_pthread.c index 773e08668182..a90de5ff4011 100644 --- a/system/lib/pthread/library_pthread.c +++ b/system/lib/pthread/library_pthread.c @@ -137,8 +137,8 @@ weak_alias(dummy_tsd, __pthread_tsd_main); // See system/lib/README.md for static constructor ordering. __attribute__((constructor(48))) -void __emscripten_init_main_thread(void) { - __emscripten_init_main_thread_js(&__main_pthread); +void _emscripten_init_main_thread(void) { + _emscripten_init_main_thread_js(&__main_pthread); // The pthread struct has a field that points to itself - this is used as // a magic ID to detect whether the pthread_t structure is 'alive'. diff --git a/system/lib/pthread/pthread_create.c b/system/lib/pthread/pthread_create.c index d7050bbc7551..295fa1d52753 100644 --- a/system/lib/pthread/pthread_create.c +++ b/system/lib/pthread/pthread_create.c @@ -335,7 +335,7 @@ void _emscripten_thread_exit(void* result) { int state = a_cas(&self->detach_state, DT_JOINABLE, DT_EXITING); if (state == DT_DETACHED) { - __emscripten_thread_cleanup(self); + _emscripten_thread_cleanup(self); } else { // Mark the thread as no longer running, so it can be joined. // Once we publish this, any threads that are waiting to join with us can diff --git a/system/lib/pthread/threading_internal.h b/system/lib/pthread/threading_internal.h index 993c5665028e..121bfbeee57d 100644 --- a/system/lib/pthread/threading_internal.h +++ b/system/lib/pthread/threading_internal.h @@ -43,9 +43,9 @@ typedef struct thread_profiler_block { // the current time. void _emscripten_yield(double now); -void __emscripten_init_main_thread_js(void* tb); +void _emscripten_init_main_thread_js(void* tb); void _emscripten_thread_profiler_enable(); -void __emscripten_thread_cleanup(pthread_t thread); +void _emscripten_thread_cleanup(pthread_t thread); hidden void* _emscripten_tls_init(void); hidden void _emscripten_tls_free(void); diff --git a/test/other/metadce/test_metadce_minimal_pthreads.gzsize b/test/other/metadce/test_metadce_minimal_pthreads.gzsize index 651ba07e2d02..cc1d64bcf857 100644 --- a/test/other/metadce/test_metadce_minimal_pthreads.gzsize +++ b/test/other/metadce/test_metadce_minimal_pthreads.gzsize @@ -1 +1 @@ -5254 +5253 diff --git a/tools/emscripten.py b/tools/emscripten.py index 35df13bae9af..f73e2e1675b4 100644 --- a/tools/emscripten.py +++ b/tools/emscripten.py @@ -1042,11 +1042,11 @@ def create_pointer_conversion_wrappers(metadata): '_emscripten_thread_free_data': '_p', '_emscripten_dlsync_self_async': '_p', '_emscripten_proxy_dlsync_async': '_pp', + '_emscripten_wasm_worker_initialize': '_p_', '_wasmfs_rmdir': '_p', '_wasmfs_unlink': '_p', '_wasmfs_mkdir': '_p_', '_wasmfs_open': '_p__', - 'emscripten_wasm_worker_initialize': '_p_', 'asyncify_start_rewind': '_p', 'asyncify_start_unwind': '_p', '__get_exception_message': '_ppp',