Skip to content

Commit 649b1f9

Browse files
authored
Move PTHREADS_PROFILING freeing to freeThreadData. NFC. (#14297)
1 parent 43d6840 commit 649b1f9

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/library_pthread.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,6 @@ var LibraryPThread = {
174174
},
175175

176176
runExitHandlersAndDeinitThread: function(tb, exitCode) {
177-
#if PTHREADS_PROFILING
178-
var profilerBlock = Atomics.load(HEAPU32, (tb + {{{ C_STRUCTS.pthread.profilerBlock }}} ) >> 2);
179-
Atomics.store(HEAPU32, (tb + {{{ C_STRUCTS.pthread.profilerBlock }}} ) >> 2, 0);
180-
_free(profilerBlock);
181-
#endif
182-
183177
// Disable all cancellation so that executing the cleanup handlers won't trigger another JS
184178
// canceled exception to be thrown.
185179
Atomics.store(HEAPU32, (tb + {{{ C_STRUCTS.pthread.canceldisable }}} ) >> 2, 1/*PTHREAD_CANCEL_DISABLE*/);
@@ -259,6 +253,11 @@ var LibraryPThread = {
259253
var tlsMemory = {{{ makeGetValue('pthread.threadInfoStruct', C_STRUCTS.pthread.tsd, 'i32') }}};
260254
{{{ makeSetValue('pthread.threadInfoStruct', C_STRUCTS.pthread.tsd, 0, 'i32') }}};
261255
_free(tlsMemory);
256+
#if PTHREADS_PROFILING
257+
var profilerBlock = {{{ makeGetValue('pthread.threadInfoStruct', C_STRUCTS.pthread.profilerBlock, 'i32') }}};
258+
{{{ makeSetValue('pthread.threadInfoStruct', C_STRUCTS.pthread.profilerBlock, 0, 'i32') }}};
259+
_free(profilerBlock);
260+
#endif
262261
_free(pthread.threadInfoStruct);
263262
}
264263
pthread.threadInfoStruct = 0;

0 commit comments

Comments
 (0)