Skip to content

Use native code for pthread_cleanup_push/pop. NFC - #14484

Merged
sbc100 merged 1 commit into
mainfrom
pthread_cleanup_push_pop
Jun 19, 2021
Merged

Use native code for pthread_cleanup_push/pop. NFC#14484
sbc100 merged 1 commit into
mainfrom
pthread_cleanup_push_pop

Conversation

@sbc100

@sbc100 sbc100 commented Jun 18, 2021

Copy link
Copy Markdown
Collaborator

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!

@sbc100
sbc100 force-pushed the pthread_cleanup_push_pop branch 2 times, most recently from 3ee3c7a to 294a9e2 Compare June 18, 2021 16:56
@sbc100
sbc100 requested review from kleisauke and kripken June 18, 2021 16:57
@sbc100

sbc100 commented Jun 18, 2021

Copy link
Copy Markdown
Collaborator Author

I'm pretty happy with how this change turned out!

@sbc100
sbc100 force-pushed the pthread_cleanup_push_pop branch from 294a9e2 to 6360f7c Compare June 18, 2021 17:47
@sbc100
sbc100 requested a review from dschuff June 18, 2021 17:48

@kripken kripken left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@sbc100
sbc100 force-pushed the pthread_cleanup_push_pop branch from 6360f7c to 845a01c Compare June 18, 2021 20:37

@kleisauke kleisauke left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@sbc100
sbc100 force-pushed the pthread_cleanup_push_pop branch from 845a01c to 3c466d6 Compare June 18, 2021 21:18
@sbc100
sbc100 enabled auto-merge (squash) June 18, 2021 21:20
@sbc100
sbc100 force-pushed the pthread_cleanup_push_pop branch from 3c466d6 to 22683fc Compare June 18, 2021 22:16
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!
@sbc100
sbc100 force-pushed the pthread_cleanup_push_pop branch from 22683fc to c2e0862 Compare June 18, 2021 23:17
@sbc100
sbc100 merged commit f46fbc5 into main Jun 19, 2021
@sbc100
sbc100 deleted the pthread_cleanup_push_pop branch June 19, 2021 00:07
sbc100 added a commit that referenced this pull request Jun 19, 2021
Rather than using a separate JS array use pthread TLS key which get
cleaned during `__pthread_tsd_run_dtors`.

Followup to #14484 and #14464 which both move more of the cleanup
handling for threads and processes onto the native side.
sbc100 added a commit that referenced this pull request Jun 19, 2021
Rather than using a separate JS array use pthread TLS key which get
cleaned during `__pthread_tsd_run_dtors`.

Followup to #14484 and #14464 which both move more of the cleanup
handling for threads and processes onto the native side.
sbc100 added a commit that referenced this pull request Jun 19, 2021
Rather than using a separate JS array use pthread TLS key which get
cleaned during `__pthread_tsd_run_dtors`.

Followup to #14484 and #14464 which both move more of the cleanup
handling for threads and processes onto the native side.
sbc100 added a commit that referenced this pull request Jun 22, 2021
Rather than using a separate JS array use pthread TLS key which get
cleaned during `__pthread_tsd_run_dtors`.

Followup to #14484 and #14464 which both move more of the cleanup
handling for threads and processes onto the native side.
sbc100 added a commit that referenced this pull request Jun 22, 2021
Rather than using a separate JS array use pthread TLS key which get
cleaned during `__pthread_tsd_run_dtors`.

Followup to #14484 and #14464 which both move more of the cleanup
handling for threads and processes onto the native side.
self->cancelbuf = cb;
static thread_local bool registerd = false;
if (!registerd) {
__cxa_thread_atexit(__run_cleanup_handlers, NULL, &__dso_handle);

Copy link
Copy Markdown
Collaborator

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sbc100 added a commit that referenced this pull request Jun 23, 2021
Rather than using a separate JS array use pthread TLS key which get
cleaned during `__pthread_tsd_run_dtors`.

Followup to #14484 and #14464 which both move more of the cleanup
handling for threads and processes onto the native side.
sbc100 added a commit that referenced this pull request Jun 23, 2021
Rather than using a separate JS array use pthread TLS key which get
cleaned during `__pthread_tsd_run_dtors`.

Followup to #14484 and #14464 which both move more of the cleanup
handling for threads and processes onto the native side.
sbc100 added a commit that referenced this pull request Jun 28, 2021
Rather than using a separate JS array use pthread TLS key which get
cleaned during `__pthread_tsd_run_dtors`.

Followup to #14484 and #14464 which both move more of the cleanup
handling for threads and processes onto the native side.
sbc100 added a commit that referenced this pull request Jun 29, 2021
Rather than using a separate JS array use pthread TLS key which get
cleaned during `__pthread_tsd_run_dtors`.

Followup to #14484 and #14464 which both move more of the cleanup
handling for threads and processes onto the native side.
sbc100 added a commit that referenced this pull request Jun 30, 2021
Rather than using a separate JS array use pthread TLS key which get
cleaned during `__pthread_tsd_run_dtors`.

Followup to #14484 and #14464 which both move more of the cleanup
handling for threads and processes onto the native side.
sbc100 added a commit that referenced this pull request Oct 4, 2021
Rather than using a separate JS array use pthread TLS key which get
cleaned during `__pthread_tsd_run_dtors`.

Followup to #14484 and #14464 which both move more of the cleanup
handling for threads and processes onto the native side.
sbc100 added a commit that referenced this pull request Oct 4, 2021
Rather than using a separate JS array use pthread TLS key which get
cleaned during `__pthread_tsd_run_dtors`.

Followup to #14484 and #14464 which both move more of the cleanup
handling for threads and processes onto the native side.
sbc100 added a commit that referenced this pull request Oct 4, 2021
Rather than using a separate JS array use pthread TLS key which get
cleaned during `__pthread_tsd_run_dtors`.

Followup to #14484 and #14464 which both move more of the cleanup
handling for threads and processes onto the native side.
sbc100 added a commit that referenced this pull request Oct 4, 2021
Rather than using a separate JS array use pthread TLS key which get
cleaned during `__pthread_tsd_run_dtors`.

Followup to #14484 and #14464 which both move more of the cleanup
handling for threads and processes onto the native side.
sbc100 added a commit that referenced this pull request Oct 4, 2021
Rather than using a separate JS array use pthread TLS key which get
cleaned during `__pthread_tsd_run_dtors`.

Followup to #14484 and #14464 which both move more of the cleanup
handling for threads and processes onto the native side.
sbc100 added a commit that referenced this pull request Oct 4, 2021
Rather than using a separate JS array use pthread TLS key which get
cleaned during `__pthread_tsd_run_dtors`.

Followup to #14484 and #14464 which both move more of the cleanup
handling for threads and processes onto the native side.
sbc100 added a commit that referenced this pull request Oct 4, 2021
Use libc++abi's version of __cxa_thread_atexit.

Followup to #14484 and #14464 which both move more of the cleanup
handling for threads and processes onto the native side.

Depends on #15210.
sbc100 added a commit that referenced this pull request Aug 12, 2022
Rather than using a separate JS array use pthread TLS key which get
cleaned during `__pthread_tsd_run_dtors`.

Followup to #14484 and #14464 which both move more of the cleanup
handling for threads and processes onto the native side.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants