]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-106213: Make Emscripten trampolines work with JSPI (GH-106219)
authorHood Chatham <roberthoodchatham@gmail.com>
Fri, 15 Sep 2023 22:04:21 +0000 (15:04 -0700)
committerGitHub <noreply@github.com>
Fri, 15 Sep 2023 22:04:21 +0000 (15:04 -0700)
commit6b179adb8c05801bf069121b360531d135ee3f44
tree0ef8079fe12fed536e09162574dd759cf59b3cb1
parent59073c9ab8eb8db9304f16c46086ccc525e82570
gh-106213: Make Emscripten trampolines work with JSPI (GH-106219)

There is a WIP proposal to enable webassembly stack switching which have been
implemented in v8:

https://github.com/WebAssembly/js-promise-integration

It is not possible to switch stacks that contain JS frames so the Emscripten JS
trampolines that allow calling functions with the wrong number of arguments
don't work in this case. However, the js-promise-integration proposal requires
the [type reflection for Wasm/JS API](https://github.com/WebAssembly/js-types)
proposal, which allows us to actually count the number of arguments a function
expects.

For better compatibility with stack switching, this PR checks if type reflection
is available, and if so we use a switch block to decide the appropriate
signature. If type reflection is unavailable, we should use the current EMJS
trampoline.

We cache the function argument counts since when I didn't cache them performance
was negatively affected.

Co-authored-by: T. Wouters <thomas@python.org>
Co-authored-by: Brett Cannon <brett@python.org>
Include/internal/pycore_emscripten_trampoline.h [new file with mode: 0644]
Include/internal/pycore_object.h
Include/internal/pycore_runtime.h
Misc/NEWS.d/next/Core and Builtins/2023-06-29-09-42-56.gh-issue-106213.TCUgzM.rst [new file with mode: 0644]
Objects/descrobject.c
Objects/methodobject.c
Python/emscripten_trampoline.c [new file with mode: 0644]
Python/pystate.c
configure
configure.ac