-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Don't call emscripten_tls_init from static constructor. NFC #14981
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
5623ed5
to
14b3503
Compare
This change makes handling of `emscripten_tls_init` the same on all threads, including the main thread and/or library loading thread. This is precursor to a change that makes use of the return value of emscripten_tls_init to do TLS relocations so making the call explicit is required. I've also removed the use of EM_ASM from library_pthread.c.
14b3503
to
f8679e0
Compare
#if PTHREADS_PROFILING | ||
PThread.createProfilerBlock(tb); | ||
PThread.setThreadName(tb, "Browser main thread"); | ||
PThread.setThreadStatus(tb, {{{ cDefine('EM_THREAD_STATUS_RUNNING') }}}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't we need to set the thread status any more down in __emscripten_init_main_thread_js?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added call to PThread.threadInit
which takes case of setThreadStatus
. Before threadInit
was only called on threads. Now its called on the main thread too (during __emscripten_init_main_thread_js
).
PThread.tlsInitFunctions.push(initTLS); | ||
if (runtimeInitialized) { | ||
initTLS(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this pushes and calls initTLS whether or not we are in a pthread, but previously both only happened when not in a pthread. Why is this change correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before the main thread would run its TLS inits from the static ctor, but the threads would need to run this explicitly. The point of this change is to remove this difference and always run init TLS explicitly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it, thanks!
This change makes handling of
emscripten_tls_init
thesame on all threads, including the main thread and/or library
loading thread.
This is precursor to a change that makes use of the return
value of
emscripten_tls_init
to do TLS relocations so makingthe call explicit is required.