This fixes it so that if new WebAssembly.Module fails, we don't try to use it in
JSPI. This doesn't 100% fix no-dynamic-eval but it makes it work a lot better.
The test_static_import test was failing in Safari because it runs another Safari session
while Safari does not allow multiple sessions running simultaneously.
We already have a workaround for it, but it was not working for this test, because it
was not using selenium fixture directly. This PR refactors the test, so our workaround can be applied.
Update ContourPy to the latest release, 1.2.0. This uses meson and meson-python to build, and following the recent improvements to meson-based builds here, such as the automagic use of emscripten.meson.cross, this was really easy.
To use pybind11 with clang >= 17 we need pybind/pybind11#4767. This isn't in a pybind11 release yet, so I have included a patch to install pybind11 direct from the github commit that includes the PR. This patch can be removed after the next pybind11 release.
This allows bidirectional stack switching and other arbitrary control flow, whereas
without this patch arbitrary control flow terribly messes up the Python interpreter
state.
By far the most subtle thing here is the manipulation of the cframe state. This
required careful reading of the greenlet source code and a large amount of trial
and error to get right.
Unfortunately the file pystate.c is tightly coupled to the Python version. There are
apparently plans to try to upstream some of this code from greenlet into Python itself.
In the meantime, it should be possible to continue updating it by imitating greenlet.
This fixes a bug in python2js. python2js_custom__create_jscontext was violating
the wasm ABI for struct value arguments. A struct argument is passed as a stack
pointer, but it violates ABI to store that pointer or modify the memory. This
caused undefined behavior.
This is close to finishing the refactor. I removed the last few uses of the
Hiwire JS APIs from the PyProxy Buffer apis. I reworked all of the
JsProxy_create family to use JsVal everywhere. I removed most of the remaining
logic from hiwire.c. The only remaining places where JsRef is used are in struct
fields where it is needed.
Makes `python2js` do what `python2js_val` did and remove `python2js_val`.
Also, when accessing a `JsProxy` attribute invokes a getter and the getter
throws an error, fix it so that the error is propagated instead of being turned
into an `AttributeError`.
This gets rid of a lot more uses of hiwire from JavaScript. It also finished eliminating the need for
a js2python conversion function that takes a JsRef, so I renamed the temporary js2python_val
back to js2python.
Uses the JS Promise integration stack switching API to allow blocking for JavaScript promises and
`PyodideFuture` objects. It's a bit complicated...
This doesn't include support for reentrant switching, currently doing that will corrupt the Python VM.
One of the cpython tests (test_plistlib.TestBinaryPlistlib.test_deep_nesting)
seems to be extremely sensitive to stack utilization and stack overflows in our
CI when even a tiny amount of extra stack is used. I doubt this is a problem in
real life -- I certainly cannot reproduce it outside of the CI service. But this
rearranges the code to avoid any additional stack usage so that CI will pass.
This is a minor rearrangment.
I renamed "continuations" stuff to "stack_switching" and made a new folder
for stack switching logic. I also added logic in esbuild.config.mjs to calculate
which functions exported from stack_switching.mjs and automatically copy them to
Module and into the Emscripten namespace. This makes unit testing a little neater
since there is no modification of the Module object.
If wasm exception handling is available, use dynamically generated modules
with wasm exception handling for the invoke stubs instead of a JS trampoline.
This is useful because JS trampolines interact poorly with JS Promise Integration.
In the future, we should switch exception handling ABIs to the compiler-provided
wasm exception handling ABI and we can remove this code. Currently we are
blocked on using compiler-provided wasm eh by Rust support.
ZenGL provides OpenGL binding for Python.
The same code that runs natively also runs in the browser as-is without modifications.
It does not depend on SDL, emscripten GLES or anything else.
It binds directly to WebGL2.
This begins migrating some of the ffi code towards using externrefs, which
should make it faster and shorter.
I'm planning on migrating from the existing hiwire.h functions to new `jslib.h`
functions which will operate on externrefs, but I think it will be easiest to
do this in several PRs since it's going to be a fair amount of code that
changes (in mostly boilerplate ways though).