Skip to content

Commit

Permalink
Improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
vouillon committed Jan 8, 2025
1 parent 84f1e91 commit 5d367fb
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
7 changes: 4 additions & 3 deletions README_wasm_of_ocaml.md
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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).
Expand All @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions manual/wasm_overview.wiki
Original file line number Diff line number Diff line change
Expand Up @@ -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. <<a_manual chapter="overview" |Js_of_ocaml packages>> are compatible with this compiler.
The compiler is provided by the wasm_of_ocaml-package. The <<a_manual chapter="overview" |Js_of_ocaml libraries>> are compatible with this compiler.

== Installation

Expand Down Expand Up @@ -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).
Expand Down
6 changes: 5 additions & 1 deletion manual/wasm_runtime.wiki
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<a_manual chapter="linker" |Link
with JavaScript code>>), 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 ==

Expand Down Expand Up @@ -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))
...
Expand Down

0 comments on commit 5d367fb

Please sign in to comment.