Skip to content

Commit

Permalink
Fix initial currentStatusStartTime in PTHREADS_PROFILING (#15678)
Browse files Browse the repository at this point in the history
`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.
  • Loading branch information
sbc100 authored Dec 1, 2021
1 parent faf4790 commit df034c9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/library_pthread.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit df034c9

Please sign in to comment.