Skip to content

Commit 88e0002

Browse files
authored
Simplify emscripten_futex_wait after recent changes. NFC (#26693)
As a followup to #26691 and #26659 we can simplify `emscripten_futex_wait` even further removing all references to `_emscripten_process_dlopen_queue`. Instead we move the call to emscripten_yield() until after the atomic.wait operation (or the skipping of it). `emscripten_yield()` then takes care of calling `_emscripten_process_dlopen_queue` as needed.
1 parent 91c0580 commit 88e0002

File tree

3 files changed

+10
-14
lines changed

3 files changed

+10
-14
lines changed

system/lib/pthread/emscripten_futex_wait.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,6 @@ int emscripten_futex_wait(volatile void *addr, uint32_t val, double max_wait_ms)
155155
return ret;
156156
}
157157

158-
// Pass 0 here, which means we don't have access to the current time in this
159-
// function. This tells _emscripten_yield to call emscripten_get_now if (and
160-
// only if) it needs to know the time.
161-
_emscripten_yield(0);
162-
163158
DBG("emscripten_futex_wait ms=%f", max_wait_ms);
164159

165160
bool is_runtime_thread = emscripten_is_main_runtime_thread();
@@ -189,11 +184,12 @@ int emscripten_futex_wait(volatile void *addr, uint32_t val, double max_wait_ms)
189184
// Clear the wait_addr
190185
DBG("emscripten_futex_wait done notify=%d cancelable=%d cancel=%d", !!(self->wait_addr & NOTIFY_BIT), cancelable, self->cancel);
191186
self->wait_addr = 0;
192-
#ifdef EMSCRIPTEN_DYNAMIC_LINKING
193-
if (!is_runtime_thread) {
194-
_emscripten_process_dlopen_queue();
195-
}
196-
#endif
187+
188+
// Pass 0 here, which means we don't have access to the current time in this
189+
// function. This tells _emscripten_yield to call emscripten_get_now if (and
190+
// only if) it needs to know the time.
191+
_emscripten_yield(0);
192+
197193
if (cancelable && self->cancel) {
198194
__pthread_testcancel();
199195
// If __pthread_testcancel does return here it means that canceldisable

test/codesize/test_codesize_minimal_pthreads.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
"a.out.js": 7367,
33
"a.out.js.gz": 3605,
44
"a.out.nodebug.wasm": 19079,
5-
"a.out.nodebug.wasm.gz": 8824,
5+
"a.out.nodebug.wasm.gz": 8825,
66
"total": 26446,
7-
"total_gz": 12429,
7+
"total_gz": 12430,
88
"sent": [
99
"a (memory)",
1010
"b (exit)",

test/codesize/test_codesize_minimal_pthreads_memgrowth.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
"a.out.js": 7769,
33
"a.out.js.gz": 3811,
44
"a.out.nodebug.wasm": 19080,
5-
"a.out.nodebug.wasm.gz": 8825,
5+
"a.out.nodebug.wasm.gz": 8826,
66
"total": 26849,
7-
"total_gz": 12636,
7+
"total_gz": 12637,
88
"sent": [
99
"a (memory)",
1010
"b (exit)",

0 commit comments

Comments
 (0)