cpython/Tools/wasm/emscripten
Miss Islington (bot) d118bc061b
[3.14] gh-124621: Emscripten: Add support for async input devices (GH-136822) (GH-136935)
This is useful for implementing proper `input()`. It requires the
JavaScript engine to support the wasm JSPI spec which is now stage 4.
It is supported on Chrome since version 137 and on Firefox and node
behind a flag.

We override the `__wasi_fd_read()` syscall with our own variant that
checks for a readAsync operation. If it has it, we use our own async
variant of `fd_read()`, otherwise we use the original `fd_read()`.
We also add a variant of `FS.createDevice()` called
`FS.createAsyncInputDevice()`.

Finally, if JSPI is available, we wrap the `main()` symbol with
`WebAssembly.promising()` so that we can stack switch from `fd_read()`.
If JSPI is not available, attempting to read from an AsyncInputDevice
will raise an `OSError`.
(cherry picked from commit 7ae4749d06)

Co-authored-by: Hood Chatham <roberthoodchatham@gmail.com>
2025-07-22 11:51:02 +02:00
..
web_example gh-127146: Fix Emscripten build with --pydebug (#131672) 2025-03-25 05:43:31 +08:00
__main__.py [3.14] gh-124621: Emscripten: Add support for async input devices (GH-136822) (GH-136935) 2025-07-22 11:51:02 +02:00
config.site-wasm32-emscripten [3.14] gh-133600: Move config.site-wasm32-emscripten into the emscripten folder (GH-136934) (#136956) 2025-07-22 00:22:57 +00:00
make_libffi.sh gh-127629: Add ctypes to the Emscripten build (#127683) 2024-12-10 10:32:58 +08:00
node_entry.mjs gh-127503: Improve tracebacks on Emscripten when there is a trap (#131158) 2025-03-13 08:28:15 +08:00