Remove TODO from libpthread.js. NFC - #26603
Merged
Merged
Conversation
This TODO was added in emscripten-core#18861 when the following line read: ``` Atomics.waitAsync(HEAP32, pthread_ptr >> 2, pthread_ptr); ``` I'm not sure if the TODO here was refering to that 2nd or 3rd argument but they both work fine under wasm64 right now. The second argument now uses `getHeapOffset('pthread_ptr', 'i32')` which works find under wasm64 even for addresses over 4gb. The third argument here is actually not important since its value never changes, it just needs to match the contents of the memory at the specific location. I verified that this works in wasm64_4gb mode. The `pthread_ptr` is simply converted to a U32 and then compared to the low bits of the 64-bit pthread_ptr in memory. The assert on the line below ensure that this does indeed work. If it didn't then `"not-equal"` would be returned from `Atomics.waitAsync`
tlively
approved these changes
Apr 1, 2026
Co-authored-by: Thomas Lively <tlively123@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This TODO was added in #18861 when the following line read:
I'm not sure if the TODO here was refering to that 2nd or 3rd argument but they both work fine under wasm64 right now.
The second argument now uses
getHeapOffset('pthread_ptr', 'i32')which works find under wasm64 even for addresses over 4gb.The third argument here is actually not important since its value never changes, it just needs to match the contents of the memory at the specific location. I verified that this works in wasm64_4gb mode. The
pthread_ptris simply converted to a U32 and then compared to the low bits of the 64-bit pthread_ptr in memory. The assert on the line below ensure that this does indeed work. If it didn't then"not-equal"would be returned fromAtomics.waitAsync