From df034c938c8bdbb3b0a272e9794084e9bce8567c Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Wed, 1 Dec 2021 10:12:25 -0800 Subject: [PATCH] Fix initial currentStatusStartTime in PTHREADS_PROFILING (#15678) `currentStatusStartTime` is a double not a u32 so needs to be set via `HEAPF64`. See below in `setThreadStatusConditional` where we update this value (correctly) using `HEAPF64`. Also, use zeroMemory rather than a loop. --- src/library_pthread.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/library_pthread.js b/src/library_pthread.js index f6f2f59008a94..d869aca33b2d9 100644 --- a/src/library_pthread.js +++ b/src/library_pthread.js @@ -8,7 +8,7 @@ var LibraryPThread = { $PThread__postset: 'if (!ENVIRONMENT_IS_PTHREAD) PThread.initMainThreadBlock();', $PThread__deps: ['_emscripten_thread_init', 'emscripten_futex_wake', '$killThread', - '$cancelThread', '$cleanupThread', + '$cancelThread', '$cleanupThread', '$zeroMemory', '_emscripten_thread_free_data', 'exit', #if !MINIMAL_RUNTIME @@ -59,8 +59,8 @@ var LibraryPThread = { Atomics.store(HEAPU32, (pthreadPtr + {{{ C_STRUCTS.pthread.profilerBlock }}} ) >> 2, profilerBlock); // Zero fill contents at startup. - for (var i = 0; i < {{{ C_STRUCTS.thread_profiler_block.__size__ }}}; i += 4) Atomics.store(HEAPU32, (profilerBlock + i) >> 2, 0); - Atomics.store(HEAPU32, (profilerBlock + {{{ C_STRUCTS.thread_profiler_block.currentStatusStartTime }}} ) >> 2, performance.now()); + zeroMemory(profilerBlock, {{{ C_STRUCTS.thread_profiler_block.__size__ }}}); + HEAPF64[(profilerBlock + {{{ C_STRUCTS.thread_profiler_block.currentStatusStartTime }}} ) >> 3] = performance.now(); }, // Sets the current thread status, but only if it was in the given expected state before. This is used