diff --git a/src/worker.js b/src/worker.js index 48f789363..d54061ccb 100644 --- a/src/worker.js +++ b/src/worker.js @@ -203,24 +203,22 @@ this.onmessage = function(e) { if (ex === 'Canceled!') { Module['PThread'].threadCancel(); } else if (ex != 'unwind') { -#if MINIMAL_RUNTIME - // ExitStatus not present in MINIMAL_RUNTIME - Atomics.store(Module['HEAPU32'], (threadInfoStruct + {{{ C_STRUCTS.pthread.threadExitCode }}} ) >> 2, -2 /*A custom entry specific to Emscripten denoting that the thread crashed.*/); -#else - Atomics.store(Module['HEAPU32'], (threadInfoStruct + {{{ C_STRUCTS.pthread.threadExitCode }}} ) >> 2, (ex instanceof Module['ExitStatus']) ? ex.status : -2 /*A custom entry specific to Emscripten denoting that the thread crashed.*/); -#endif - - Atomics.store(Module['HEAPU32'], (threadInfoStruct + {{{ C_STRUCTS.pthread.threadStatus }}} ) >> 2, 1); // Mark the thread as no longer running. #if ASSERTIONS + // FIXME(sbc): Figure out if this is still needed or useful. Its not + // clear to me how this check could ever fail. In order to get into + // this try/catch block at all we have already called bunch of + // functions on `Module`.. why is this one special? if (typeof(Module['_emscripten_futex_wake']) !== "function") { err("Thread Initialisation failed."); throw ex; } #endif - Module['_emscripten_futex_wake'](threadInfoStruct + {{{ C_STRUCTS.pthread.threadStatus }}}, 0x7FFFFFFF/*INT_MAX*/); // Wake all threads waiting on this thread to finish. #if MINIMAL_RUNTIME + // ExitStatus not present in MINIMAL_RUNTIME + Module['PThread'].threadExit(-2); throw ex; // ExitStatus not present in MINIMAL_RUNTIME #else + Module['PThread'].threadExit((ex instanceof Module['ExitStatus']) ? ex.status : -2); if (!(ex instanceof Module['ExitStatus'])) throw ex; #endif #if ASSERTIONS