Skip to content

Commit e1a0f02

Browse files
authored
When Atomics.wait() is polyfilled, do not attempt to use it in _emscripten_thread_mailbox_await() (#25853)
When Atomics.wait() is polyfilled, do not attempt to use it in _emscripten_thread_mailbox_await(), since the polyfill will not work there. This is take two at fixing #25494.
1 parent 951b904 commit e1a0f02

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/lib/libatomic.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ addToLibrary({
2222
// https://github.com/tc39/proposal-atomics-wait-async/blob/master/PROPOSAL.md
2323
// This polyfill performs polling with setTimeout() to observe a change in the
2424
// target memory location.
25-
$polyfillWaitAsync__postset: `if (!Atomics.waitAsync || (globalThis.navigator?.userAgent && Number((navigator.userAgent.match(/Chrom(e|ium)\\/([0-9]+)\\./)||[])[2]) < 91)) {
25+
$waitAsyncPolyfilled: '=(!Atomics.waitAsync || (globalThis.navigator?.userAgent && Number((navigator.userAgent.match(/Chrom(e|ium)\\/([0-9]+)\\./)||[])[2]) < 91));',
26+
$polyfillWaitAsync__deps: ['$waitAsyncPolyfilled'],
27+
$polyfillWaitAsync__postset: `if (waitAsyncPolyfilled) {
2628
let __Atomics_waitAsyncAddresses = [/*[i32a, index, value, maxWaitMilliseconds, promiseResolve]*/];
2729
function __Atomics_pollWaitAsyncAddresses() {
2830
let now = performance.now();

src/lib/libpthread.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1261,9 +1261,9 @@ var LibraryPThread = {
12611261
}
12621262
}),
12631263

1264-
_emscripten_thread_mailbox_await__deps: ['$checkMailbox'],
1264+
_emscripten_thread_mailbox_await__deps: ['$checkMailbox', '$waitAsyncPolyfilled'],
12651265
_emscripten_thread_mailbox_await: (pthread_ptr) => {
1266-
if (Atomics.waitAsync) {
1266+
if (!waitAsyncPolyfilled) {
12671267
// Wait on the pthread's initial self-pointer field because it is easy and
12681268
// safe to access from sending threads that need to notify the waiting
12691269
// thread.

0 commit comments

Comments
 (0)