Skip to content

Move emscripten_wasm_worker_self_id to native code. NFC#26468

Merged
sbc100 merged 1 commit intoemscripten-core:mainfrom
sbc100:move_emscripten_wasm_worker_self_id
Mar 17, 2026
Merged

Move emscripten_wasm_worker_self_id to native code. NFC#26468
sbc100 merged 1 commit intoemscripten-core:mainfrom
sbc100:move_emscripten_wasm_worker_self_id

Conversation

@sbc100
Copy link
Copy Markdown
Collaborator

@sbc100 sbc100 commented Mar 17, 2026

This will speed up this function significantly which is going to be important for hybrid pthreads + Wasm Workers builds where we need to be able to distinguish between Wasm Workers and non-Wasm Workers sometimes at the very local level.

Note that this function returns 0 for all non-Wasm Workers, which includes both the main thread and pthreads.

Also, move emscripten_current_thread_is_wasm_worker since that is trivially implemented on top of _self_id()

@sbc100 sbc100 requested review from cwoffenden, juj and kripken March 17, 2026 16:31
@sbc100 sbc100 force-pushed the move_emscripten_wasm_worker_self_id branch 3 times, most recently from a39cb00 to ed753e8 Compare March 17, 2026 19:19
sbc100 added a commit to sbc100/emscripten that referenced this pull request Mar 17, 2026
This change doesn't look very useful but as followup to this (and
combined with emscripten-core#26468) this should allow us to enable more internal
musl locking code that currently depends on `pthread_self()->tid`.
sbc100 added a commit to sbc100/emscripten that referenced this pull request Mar 17, 2026
This change doesn't look very useful but as followup to this (and
combined with emscripten-core#26468) this should allow us to enable more internal
musl locking code that currently depends on `pthread_self()->tid`.
@sbc100 sbc100 force-pushed the move_emscripten_wasm_worker_self_id branch from ed753e8 to 1a4e775 Compare March 17, 2026 20:35
@sbc100 sbc100 requested a review from dschuff March 17, 2026 20:35
@sbc100 sbc100 force-pushed the move_emscripten_wasm_worker_self_id branch from 1a4e775 to 0a51da3 Compare March 17, 2026 20:37
This will speed up this function significantly which is going to be
important for hybrid pthreads + Wasm Workers builds where we need to be
able to distinguish between Wasm Workers and non-Wasm Workers sometimes
at the very local level.

Note that this function returns 0 for all non-Wasm Workers, which
includes both the main thread and pthreads.

Also, move emscripten_current_thread_is_wasm_worker since that is
trivially implemented on top of `_self_id()`
@sbc100 sbc100 force-pushed the move_emscripten_wasm_worker_self_id branch from 0a51da3 to e3d078c Compare March 17, 2026 21:34
sbc100 added a commit to sbc100/emscripten that referenced this pull request Mar 17, 2026
This change doesn't look very useful but as followup to this (and
combined with emscripten-core#26468) this should allow us to enable more internal
musl locking code that currently depends on `pthread_self()->tid`.
sbc100 added a commit to sbc100/emscripten that referenced this pull request Mar 17, 2026
This change doesn't look very useful but as followup to this (and
combined with emscripten-core#26468) this should allow us to enable more internal
musl locking code that currently depends on `pthread_self()->tid`.
@sbc100 sbc100 merged commit fb18236 into emscripten-core:main Mar 17, 2026
38 checks passed
@sbc100 sbc100 deleted the move_emscripten_wasm_worker_self_id branch March 17, 2026 22:44
sbc100 added a commit to sbc100/emscripten that referenced this pull request Mar 17, 2026
This change doesn't look very useful but as followup to this (and
combined with emscripten-core#26468) this should allow us to enable more internal
musl locking code that currently depends on `pthread_self()->tid`.
sbc100 added a commit to sbc100/emscripten that referenced this pull request Mar 17, 2026
This change doesn't look very useful but as followup to this (and
combined with emscripten-core#26468) this should allow us to enable more internal
musl locking code that currently depends on `pthread_self()->tid`.
sbc100 added a commit to sbc100/emscripten that referenced this pull request Mar 17, 2026
This change doesn't look very useful but as followup to this (and
combined with emscripten-core#26468) this should allow us to enable more internal
musl locking code that currently depends on `pthread_self()->tid`.
sbc100 added a commit that referenced this pull request Mar 18, 2026
This change doesn't look very useful but as followup to this (and
combined with #26468) this should allow us to enable more internal musl
locking code that currently depends on `pthread_self()->tid`.
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.

2 participants