Watib (WebAssembly Toolchain In Bigloo) is a (WIP) WebAssembly toolchain. It aims at being user friendly and fast. We currently support a big part of the current draft of the version 3 of the standard. See here for more details on what is currently missing.
It is used by the Bigloo scheme compiler for its wasm backend.
To build watib, a working Bigloo distribution is required. You can, then, build it with:
makeOnce built, watib can be called on a WebAssembly Text file to validate, optimise and convert it to binary format. It supports several options:
-o <file>to specify an output file,-kor--keep-goingto continue validation after an error has been encoutered (won't produce an output file),-vor--validate-onlyto stop after validation,-O0to disable the optimisations,-O1to enable optimisations (default),-j <n>to use more than one job.
The source code consists of the following directories:
- The
Valdirectory contains the validation logic. In particular, theinstruction-types.schfile contains the descritption of the type of most instructions. It also handles the desuggaring of the text format. - The
Typedirectory contains functions to manipulate and compare types. - The
Astdirectory contains the internal representation of wasm code outputted by the validation and used by the two following directories. - The
Asmdirectory contains the translation to the binary format logic. - The
Optdirectory contains the optimisation logic. Each subdirectory is an optimisation pass and everything is glued together by theoptimise.scmfile. - The
Miscdirectory contains various routines used by the previous directories.
The functions in the first four directories are more or less straightforward transcriptions of the spec. The code is annotated with the positions in the spec it implements (the precision of the annotations depends on the subtlety of what is being implemented).
More detailed information can be found in watib's documentation.
Watib doesn't support the following features yet (the list may be incomplete):
- Tables,
- Most memory instructions,
- Vector instructions,
- Active data declarations,
- Elem declarations other than
(elem declare func ...), - Start declarations,
- Omission of the module keyword,
- Type indices in type-uses (i.e. functions have to be declared with
(param ...)and(result ...), - Offset and alignment in
load8_sxandstore8, - Multiple memories,
- NaN of the form
nan:...(only nan is supported) and hexfloats.
If you want to use watib and need one of these, feel free to raise an issue or send an email at aghilas.boussaa@normalesup.org.
Thanks to Manuel Serrano who wrote the Bigloo compiler, became the first user and provided help, feedbacks and the internship which led to watib. Thanks to Andreas Rossberg for his reactivity and valuable knowledge concerning doubts on the specification and Wasm more generally.