You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Followup to: #121698. WebAssembly in the browser is soon gaining stack switching support, but we're not allowed to stack switch through JS frames. The stack switching support used to require the wasm-js-type-reflection proposal, so in #121698 I updated the call trampoline to use js type reflection if it's present to avoid the JS frame and so the problem was fixed. However, the stack switching proposal has since been updated not to depend on type reflection, and it is going to be shipped while type reflection is still waiting for further refinement. This change means I need a different solution. Fortunately, wasm-gc is in stage 4 (shipped everywhere) and adds a webassembly instruction to query the type of a function. Unfortunately, toolchain support for wasm-gc is poor. Not even my favored assembler supports it.
Another problem is that the existing code is incompatible with memory snapshots since it calls JS initialization code that needs to happen even if restoring a memory snapshot from C code that is skipped when restoring a memory snapshot. I'll fix this at the same time.
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.
Followup to: #121698. WebAssembly in the browser is soon gaining stack switching support, but we're not allowed to stack switch through JS frames. The stack switching support used to require the wasm-js-type-reflection proposal, so in #121698 I updated the call trampoline to use js type reflection if it's present to avoid the JS frame and so the problem was fixed. However, the stack switching proposal has since been updated not to depend on type reflection, and it is going to be shipped while type reflection is still waiting for further refinement. This change means I need a different solution. Fortunately, wasm-gc is in stage 4 (shipped everywhere) and adds a webassembly instruction to query the type of a function. Unfortunately, toolchain support for wasm-gc is poor. Not even my favored assembler supports it.
Another problem is that the existing code is incompatible with memory snapshots since it calls JS initialization code that needs to happen even if restoring a memory snapshot from C code that is skipped when restoring a memory snapshot. I'll fix this at the same time.
Linked PRs
The text was updated successfully, but these errors were encountered: