Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/lib/libatomic.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ addToLibrary({
// https://github.com/tc39/proposal-atomics-wait-async/blob/master/PROPOSAL.md
// This polyfill performs polling with setTimeout() to observe a change in the
// target memory location.
$polyfillWaitAsync__postset: `if (!Atomics.waitAsync || (globalThis.navigator?.userAgent && Number((navigator.userAgent.match(/Chrom(e|ium)\\/([0-9]+)\\./)||[])[2]) < 91)) {
$waitAsyncPolyfilled: `Atomics.waitAsyncPolyfilled = (!Atomics.waitAsync || (globalThis.navigator?.userAgent && Number((navigator.userAgent.match(/Chrom(e|ium)\\/([0-9]+)\\./)||[])[2]) < 91));`,
$polyfillWaitAsync__deps: ['$waitAsyncPolyfilled'],
$polyfillWaitAsync__postset: `if (Atomics.waitAsyncPolyfilled) {
let __Atomics_waitAsyncAddresses = [/*[i32a, index, value, maxWaitMilliseconds, promiseResolve]*/];
function __Atomics_pollWaitAsyncAddresses() {
let now = performance.now();
Expand Down
4 changes: 2 additions & 2 deletions src/lib/libpthread.js
Original file line number Diff line number Diff line change
Expand Up @@ -1261,9 +1261,9 @@ var LibraryPThread = {
}
}),

_emscripten_thread_mailbox_await__deps: ['$checkMailbox'],
_emscripten_thread_mailbox_await__deps: ['$checkMailbox', '$waitAsyncPolyfilled'],
_emscripten_thread_mailbox_await: (pthread_ptr) => {
if (Atomics.waitAsync) {
if (!Atomics.waitAsyncPolyfilled) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not just if (waitAsyncPolyfilled)? i.e. why modify the Atomics object at all?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The idea was to make it look like a public API, if other code might need to check if the implementation was polyfilled or not. Changed to not modify the Atomics object.

// Wait on the pthread's initial self-pointer field because it is easy and
// safe to access from sending threads that need to notify the waiting
// thread.
Expand Down
Loading