diff --git a/src/lib/libpthread.js b/src/lib/libpthread.js index c9ba01e4820d6..ac112b6a6dc80 100644 --- a/src/lib/libpthread.js +++ b/src/lib/libpthread.js @@ -278,14 +278,18 @@ var LibraryPThread = { #endif // If this message is intended to a recipient that is not the main - // thread, forward it to the target thread. - if (d.targetThread && d.targetThread != _pthread_self()) { + // thread, forward it to the target thread. This is currently only + // used by `CMD_CHECK_MAILBOX`. + if (d.targetThread) { +#if ASSERTIONS + // pthreads should not be relaying messages to themselves. + assert(d.targetThread != _pthread_self()); +#endif var targetWorker = PThread.pthreads[d.targetThread]; - if (targetWorker) { - targetWorker.postMessage(d, d.transferList); - } else { - err(`worker sent message (${cmd}) to pthread (${d.targetThread}) that no longer exists`); - } +#if ASSERTIONS + if (!targetWorker) err(`worker sent message (${cmd}) to pthread (${d.targetThread}) that no longer exists`); +#endif + targetWorker?.postMessage(d); return; } diff --git a/test/codesize/test_codesize_minimal_pthreads.json b/test/codesize/test_codesize_minimal_pthreads.json index 851b17340ee79..7843e557c59d8 100644 --- a/test/codesize/test_codesize_minimal_pthreads.json +++ b/test/codesize/test_codesize_minimal_pthreads.json @@ -1,10 +1,10 @@ { - "a.out.js": 7110, - "a.out.js.gz": 3524, + "a.out.js": 7012, + "a.out.js.gz": 3472, "a.out.nodebug.wasm": 19037, "a.out.nodebug.wasm.gz": 8787, - "total": 26147, - "total_gz": 12311, + "total": 26049, + "total_gz": 12259, "sent": [ "a (memory)", "b (exit)", diff --git a/test/codesize/test_codesize_minimal_pthreads_memgrowth.json b/test/codesize/test_codesize_minimal_pthreads_memgrowth.json index 9dcfca60775f6..079165820445c 100644 --- a/test/codesize/test_codesize_minimal_pthreads_memgrowth.json +++ b/test/codesize/test_codesize_minimal_pthreads_memgrowth.json @@ -1,10 +1,10 @@ { - "a.out.js": 7518, - "a.out.js.gz": 3728, + "a.out.js": 7420, + "a.out.js.gz": 3672, "a.out.nodebug.wasm": 19038, "a.out.nodebug.wasm.gz": 8788, - "total": 26556, - "total_gz": 12516, + "total": 26458, + "total_gz": 12460, "sent": [ "a (memory)", "b (exit)",