pyodide/cpython
Hood Chatham f51f4b1603
Use wasm-gc based call adaptor if available (#5310)
I figured out a way to remove the super inefficient `calculate_wasm_func_nargs_fallback` and
replace it with wasm-gc code. This should perform much better. The cpython patch message says:

Part of the ongoing quest to support JSPI. The JSPI spec removed its dependence on
JS type reflection, and now the plan is for runtimes to ship JSPI while keeping
type reflection in stage 3. So we need an alternative way to count the number of
parameters of a function. It is possible to count them by repeatedly trying to
instantiate a webassembly module with the function as an import of a different type
signature. But this is pretty inefficient.

Since WebAssembly gc is now stage 4, there is a new option. WebAssembly gc added the
`ref.test` instruction which can ask if a funcref has a given type. It's a bit difficult
to apply because even our usual assembler the wasm binary toolkit doesn't support this
instruction yet. But all JS engines that support JSPI support it. We just have to do some
manual work to produce the binary.

This code also has to be written carefully to interact properly with memory snapshots.
Importantly, no JS initialization code can be called from the C initialization code.
For this reason, we make a C function pointer to fill from JS and fill it in a preRun
function.

Upstream PR:
python/cpython#128628
2025-01-13 14:14:06 +01:00
..
patches Use wasm-gc based call adaptor if available (#5310) 2025-01-13 14:14:06 +01:00
Makefile Make cpython build respect debug mode (#5038) 2024-08-28 14:45:01 +02:00
README.md Link to @dgym 2019-03-18 21:33:32 -07:00
Setup.local Python3.11 (#3252) 2023-01-23 19:45:59 -08:00
adjust_sysconfig.py Change wheel tag from emscripten to pyodide (#4777) 2024-05-21 12:30:01 -04:00

README.md

Credits

Based on the hard work of @dgym on cpython-emscripten.