Skip to content

Wasm native effects (Stack Switching proposal)#2189

Open
vouillon wants to merge 15 commits into
masterfrom
native-effects-node
Open

Wasm native effects (Stack Switching proposal)#2189
vouillon wants to merge 15 commits into
masterfrom
native-effects-node

Conversation

@vouillon
Copy link
Copy Markdown
Member

@vouillon vouillon commented Feb 20, 2026

@vouillon vouillon added the wasm label Feb 20, 2026
@vouillon vouillon force-pushed the native-effects-node branch 7 times, most recently from 803534a to b2a10e7 Compare February 24, 2026 16:46
@vouillon vouillon changed the title Wasm native effects Wasm native effects (Stack Switching proposal) Feb 26, 2026
@vouillon vouillon force-pushed the native-effects-node branch from b2a10e7 to 6c31bb2 Compare February 26, 2026 13:29
@vouillon vouillon force-pushed the native-effects-node branch from 6c31bb2 to 89c34af Compare March 10, 2026 16:34
@hhugo hhugo mentioned this pull request Mar 12, 2026
4 tasks
@vouillon vouillon force-pushed the native-effects-node branch 2 times, most recently from d8dd689 to 58ef063 Compare March 12, 2026 13:02
@vouillon vouillon force-pushed the native-effects-node branch from 58ef063 to d215c0b Compare March 16, 2026 13:33
Comment thread tools/node_wrapper.ml Outdated
@@ -1,8 +1,4 @@
let extra_args_for_wasoo =
[ "--experimental-wasm-imported-strings"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we no longer need these flags

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both flags have been removed in node 26 (the features are always enabled).
--experimental-wasm-imported-strings has been the default for quite some time.
--experimental-wasm-stack-switching (JSPI) is enabled by default since node 25.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we maintain a list of flags per node and feature used ? Same thing for chrome ? It could live in the doc

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this belongs to the doc if these flags are only used for testing.
We have a fallback polyfill, so --experimental-wasm-imported-strings is never necessary.
Maybe I can document that JSPI is enabled by default since Chrome 137 and node 25?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I can document that JSPI is enabled by default since Chrome 137 and node 25?

Yes.

--experimental-wasm-imported-strings has been the default for quite some time.
--experimental-wasm-stack-switching (JSPI) is enabled by default since node 25.

But the readme says

The generated code works with Chrome 119, Node.js 22, Firefox 122, and Safari 18.2 (or more recent versions of these applications).

I think we should try to be more precise maybe.

@vouillon vouillon force-pushed the native-effects-node branch from d215c0b to fda7c88 Compare March 20, 2026 11:10
@vouillon vouillon force-pushed the native-effects-node branch 2 times, most recently from 5d49a99 to 3c7b97f Compare April 14, 2026 15:29
@vouillon vouillon force-pushed the native-effects-node branch from 3c7b97f to 2692817 Compare May 5, 2026 17:10
vouillon added 9 commits May 6, 2026 17:47
Dune 3.23 derives the >= 20180523 menhir constraint from
(using menhir 3.0). Older dune versions don't, so they would
regenerate the opam files without it. State the bound explicitly
in each (depends ...) of dune-project so opam files stay stable
across dune versions, and update the opam files accordingly.
Dune 3.23 forces sandboxing on user rules, so gen.exe runs from
_build/.sandbox/<hash>/default/<dir> instead of the project tree.
The previous prefix walker (stop when parent ends with _build) then
yielded <hash>/default/<dir>/, which both shows up in the generated
;; comment and shifts the Hashtbl.hash-based name suffix, making the
runtest diff against the checked-in dune.inc fail.

Take the project-relative directory as argv.(1) (replacing the
previously unused library-name argument) so the prefix is stable
regardless of where dune runs the action.
The current release of ocaml-dune-lint is not compatible with dune 3.23.
Under dune 3.23 sandboxing, rules that run a *.bc.wasm.js file also
need to depend on the companion *.bc.wasm.assets/ directory so that
the .wasm files are copied into the sandbox.
Under dune 3.23 sandboxing, rules invoking js_of_ocaml or wasm_of_ocaml
with --toplevel need their .cmi files brought into the sandbox.

For locally built cmis, declare them as deps. For library cmis, add
a cmi_include_dirs.txt rule (mirroring the existing one for toplevel.bc)
that uses ocamlfind to produce -I flags, and pass the result via
read-strings.
Under dune 3.23 sandboxing, the test runs `node %{test} wc.ml` but
wc.ml is only referenced positionally on the command line, not as a
dune dep, so it isn't copied into the sandbox. Adding it under
(deps ...) makes the rule sandbox-clean.
It uses `js_of_ocaml --build-config` to manage config details.

Dune 3.23 sandboxes user rules by default; the necessary test
adjustments are in the following commits.
Drop CI matrix entries, opam constraints, and conditional code for
4.13. Minimum supported version is now 4.14.
@vouillon vouillon force-pushed the native-effects-node branch from 2692817 to f88da80 Compare May 6, 2026 17:33
@vouillon vouillon changed the base branch from master to dune-3.23 May 6, 2026 17:36
@vouillon vouillon changed the base branch from dune-3.23 to master May 6, 2026 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants