Skip to content

Commit 0b372d0

Browse files
committed
Improve Web Image README
1 parent 656ece2 commit 0b372d0

File tree

1 file changed

+50
-7
lines changed

1 file changed

+50
-7
lines changed

web-image/README.md

Lines changed: 50 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,76 @@
11
# Web Image
22

3+
Web Image is an experimental backend for Native Image that produces a
4+
WebAssembly module from Java code.
5+
6+
## Prerequisites
7+
8+
Being part of Native Image, check out its [Quick Start Guide](../docs/reference-manual/native-image/contribute/DevelopingNativeImage.md)
9+
for all the prerequisites for building Native Image.
10+
11+
In addition, Web Image also uses `wasm-as` from
12+
[binaryen](https://github.com/WebAssembly/binaryen) as its assembler.
13+
Version 119 of `wasm-as` has to be available on your `PATH`.
14+
15+
<details>
16+
<summary>Installation</summary>
17+
18+
Binaryen provides pre-built releases for all major platforms on
19+
[GitHub](https://github.com/WebAssembly/binaryen/releases).
20+
21+
On MacOS, it is recommended to install through [Homebrew](https://brew.sh/), as
22+
the pre-built binaries are not signed and may be quarantined by MacOS.
23+
24+
```bash
25+
brew install binaryen
26+
```
27+
</details>
28+
329
## Building
430

31+
To build Web Image, run the `mx build` command in the `web-image` suite:
32+
533
```bash
34+
cd /path/to/graal
35+
cd web-image
636
mx build
737
```
838

939
## Usage
1040

11-
Use this as you would regular the regular `native-image` tool, but with an
41+
Use this as you would use the regular `native-image` tool, but with an
1242
additional `--tool:svm-wasm` flag to enable the WebAssembly backend:
1343

1444
```bash
1545
mx native-image --tool:svm-wasm -cp ... HelloWorld
1646
```
1747

1848
This produces `helloworld.js` and `helloworld.js.wasm` in your working
19-
directory. The JavaScript file is a wrapper that loads and runs the WebAssembly
20-
code and can be run with [Node.js](https://nodejs.org/en) 22 or later:
49+
directory. The `--tool:svm-wasm` flag should be the first argument if possible.
50+
If any experimental options specific to the Wasm backend are used, they can
51+
only be added after the `--tool:svm-wasm` flag.
2152

22-
The `--tool:svm-wasm` flag should be the first argument if possible. If any
23-
experimental options specific to the Wasm backend are used, they can only be
24-
added after the `--tool:svm-wasm` flag.
53+
The JavaScript file is a wrapper that loads and runs the WebAssembly
54+
code and can be run with [Node.js](https://nodejs.org/en) 22 or later:
2555

2656
```bash
27-
$ node helloworld.js
57+
# --experimental-wasm-exnref is only required for Node versions before 25
58+
$ node --experimental-wasm-exnref helloworld.js
2859
Hello World
2960
```
3061

62+
## WebAssembly Features
63+
64+
The WebAssembly code generated by Web Image makes use of various WebAssembly
65+
features from WebAssembly 3.0:
66+
67+
- [Garbage Collection](https://github.com/WebAssembly/gc)
68+
- [Exception Handling](https://github.com/WebAssembly/exception-handling/blob/master/proposals/exception-handling/Exceptions.md)
69+
- [Typed Function References](https://github.com/WebAssembly/function-references/blob/main/proposals/function-references/Overview.md)
70+
71+
Support for [WebAssembly 2.0](https://www.w3.org/TR/wasm-core-2/#release-20) is
72+
generally assumed.
73+
3174
## Contributors
3275

3376
- Aleksandar Prokopec

0 commit comments

Comments
 (0)