-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Use native code for pthread_cleanup_push
/pop
. NFC
#14484
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
3ee3c7a
to
294a9e2
Compare
I'm pretty happy with how this change turned out! |
294a9e2
to
6360f7c
Compare
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.
Nice!
6360f7c
to
845a01c
Compare
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.
LGTM!
845a01c
to
3c466d6
Compare
3c466d6
to
22683fc
Compare
This change reverts one of our musl patches so that `pthread_cleanup_push/pop` are now implemented as macros as in upstream musl. `pthread_cleanup_push/pop` are now handled separately to `__cxa_atexit_thread`, which is technically a bug fix. Without this fix, calling `__cxa_atexit_thread` in the middle of push/pop block would end up pop'ing the wrong thing at the end. Overall this reduces the API surface of our JS API and increases the amount of code we share with musl, while also reducing the cost of `pthread_cleanup_push/pop.` Now, they never involve any allocation or calls to JS!
22683fc
to
c2e0862
Compare
self->cancelbuf = cb; | ||
static thread_local bool registerd = false; | ||
if (!registerd) { | ||
__cxa_thread_atexit(__run_cleanup_handlers, NULL, &__dso_handle); |
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.
Should we set registerd
(typo: registered
) to true
here? Noticed this during the review of #14489.
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.
Thanks!
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.
This change reverts one of our musl patches so that
pthread_cleanup_push/pop
are now implemented as macros as in upstreammusl.
pthread_cleanup_push/pop
are now handled separately to__cxa_atexit_thread
, which is technically a bug fix. Without this fix,calling
__cxa_atexit_thread
in the middle of push/pop block would end uppop'ing the wrong thing at the end.
Overall this reduces the API surface of our JS API and increases the
amount of code we share with musl, while also reducing the cost of
pthread_cleanup_push/pop.
Now, they never involve any allocation orcalls to JS!