diff --git a/README_wasm_of_ocaml.md b/README_wasm_of_ocaml.md index 906ff7591f..299c83bb37 100644 --- a/README_wasm_of_ocaml.md +++ b/README_wasm_of_ocaml.md @@ -1,6 +1,6 @@ # Wasm_of_ocaml -Wasm_of_ocaml is a fork of Js_of_ocaml which compiles OCaml bytecode to WebAssembly. +Wasm_of_ocaml is an alternative compiler which compiles OCaml bytecode to WebAssembly. ## Supported engines @@ -12,7 +12,7 @@ In particular, the output code requires the following [Wasm extensions](https:// - [the exception handling extension](https://github.com/WebAssembly/exception-handling/blob/master/proposals/exception-handling/Exceptions.md) OCaml 5.x code using effect handlers can be compiled in two different ways: -One can enable the CPS transformation from `js_of_ocaml` by passing the +one can enable the CPS transformation from `js_of_ocaml` by passing the `--effects=cps` flag. Without the flag `wasm_of_ocaml` will instead default to `--effects=jspi` and emit code utilizing - [the JavaScript-Promise Integration extension](https://github.com/WebAssembly/js-promise-integration/blob/main/proposals/js-promise-integration/Overview.md). @@ -33,8 +33,9 @@ You may want to install additional packages. For instance: opam install js_of_ocaml js_of_ocaml-ppx js_of_ocaml-lwt ``` -## Running the testsuite +## Running the test suite +The following commands can be used to set up an opam switch and run the test suite. ``` opam switch create wasm-tests 4.14.0 eval $(opam env --switch=wasm-tests) diff --git a/manual/wasm_overview.wiki b/manual/wasm_overview.wiki index 363a97dae9..532659a16a 100644 --- a/manual/wasm_overview.wiki +++ b/manual/wasm_overview.wiki @@ -3,9 +3,9 @@ == Overview == Wasm_of_ocaml is a compiler from OCaml bytecode programs to WebAssembly. -It provides an alternative way to run pure OCaml programs in JavaScript environment like browsers and Node.js. +It provides an alternative way to run pure OCaml programs in JavaScript environments like browsers and Node.js. -The compiler is provided by the wasm_of_ocaml-package. <> are compatible with this compiler. +The compiler is provided by the wasm_of_ocaml-package. The <> are compatible with this compiler. == Installation @@ -49,7 +49,7 @@ supported in general. However, Compared to Js_of_ocaml, dynlink is not supported, and it is not possible to build an OCaml toplevel. The virtual filesystem is not implemented either. OCaml 5.x code using effect handlers can be compiled in two different ways: -One can enable the CPS transformation from `js_of_ocaml` by passing the +one can enable the CPS transformation from `js_of_ocaml` by passing the `--effects=cps` flag. Without the flag `wasm_of_ocaml` will instead default to `--effects=jspi` and emit code utilizing [the JavaScript-Promise Integration extension](https://github.com/WebAssembly/js-promise-integration/blob/main/proposals/js-promise-integration/Overview.md). diff --git a/manual/wasm_runtime.wiki b/manual/wasm_runtime.wiki index 9b4d7467e0..69f9ccd598 100644 --- a/manual/wasm_runtime.wiki +++ b/manual/wasm_runtime.wiki @@ -3,11 +3,15 @@ User-defined primitives can be implemented by writing Wasm modules. This modules (".wat" extension for text modules and ".wasm" extension for binary modules) can be passed on the command-line. +With dune, you can use the option +{{{(wasm_of_ocaml (wasm_files ...))}}} to specify these runtime files. It still makes sense to link JavaScript files to specify the possible side-effects of some primitives (see <>), or to implement some functionalities in JavaScript. +With dune, you can use the option +{{{(wasm_of_ocaml (javascript_files ...))}}} to specify these files. == Data representation == @@ -44,7 +48,7 @@ You can import the following functions to access or allocate integers of type in == Implementing primitives -Primitives can be defined as exported Wasm functions with parameters and return value of type {{{(ref eq)}}}. +You define a primitive by exporting a Wasm function with parameters and return value of type {{{(ref eq)}}}. {{{ (func (export "input") (param $channel (ref eq)) (param $buffer (ref eq)) (param $offset (ref eq)) (param $length (ref eq)) (result (ref eq)) ...