Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
ShawSumma committed Jan 9, 2023
1 parent 34190ac commit 70dd3e6
Show file tree
Hide file tree
Showing 14 changed files with 70 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
with:
version: 3.1.25
actions-cache-folder: 'emsdk-cache'
- run: make CC=gcc OPT='-O3 -fomit-frame-pointer' all
- run: make CC=gcc OPT='-O3 -flto -fomit-frame-pointer' all CFLAGS+='-DWEB49_OPT_CONST0'
- run: sudo cp bin/miniwasm /usr/bin/miniwasm
- run: pushd ./; git clone https://github.com/wasm3/wasm3 && cd wasm3 && cmake . && sudo make -Bj install; popd
- run: sudo apt install -y python3 python3-pip
Expand Down
83 changes: 69 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,83 @@
# Web49

Web49 contains a few tools for working with webassembly
Web49 contains a few tools for working with WebAssembly.

## miniwasm
* interpreters
* miniwasm
* [fast](#benchmarks) wasm interpreter
* uses technology from [minivm](https://github.com/fastvm/minivm)
* suports multiple wasm formats
* wasm binary format: ~100% complete
* wasm text format: ~95% complete
* wasm spect test: ~75% complete
* includes a custom [WASI](https://github.com/webassembly/wasi) [implementation](src/api/wasi.c)
* raywasm
* wasm interpreter based on miniwasm
* includes [raylib](https://github.com/raysan5/raylib) [bindings](src/api/raylib.c) [generated from](src/api/raylib.py) [json](src/api/raylib.json)
* wasm binary tools rewrite
* much simpler than WABT's tools
* much smaller than Binaryen's tools
* [wat2wasm](main/wat2wasm.c)
* convert wasm text into wasm binary
* [wasm2wat](main/wasm2wat.c)
* generates nearly identical wat as binaryen or wabt
* turn wasm binary into wasm text
* supports all of wasm 1.0 and some extensions
* [wasm2wasm](main/wasm2wasm.c)
* shrink numbers in wasm files generated by llvm
* saves 0-4 bytes per 32 bit number
* saves 0-10 bytes per 64 bit number
* round trip parse and reemit

MiniWASM applies what was learned in developing MiniVM to a webassembly intepreter.
## Benchmarks

MiniVM was about 2x faster than Wasm3, with more types and more dynamism.
MiniVM was natively a register-only machine, and MiniWASM too will be mostly registers.
Benchmarks performed by [wasm3](https://github.com/wasm3/wasm3) and miniwasm. Ran on an 2020 Macbook Air (M1 + 8GiB ram) using [bench.py](bench.py).

MiniWASM intends to support all of what people use today in webassembly, tho it is still under heavy development.
All Benchmarks compiled with: `emcc -O2`

## wasm2wat
One can also view results run on [github actions](https://github.com/FastVM/Web49/actions)
One can run the benchmarks for themselves.

The wasm2wat tool is a faster rewrite of wabt's wasm2wat, doing only the bare minimum for now.
* python3
* with pip
* make
* tested with GNUMake
* works with BSDMake too
* and a C compiler
* gcc/clang/tcc works
* msvc would work if someone rewrites two macros
* #define NEXT() break
* #define LABEL(X) case X:
* probably a couple others

## wat2wasm
```sh
git clone https://github.com/fastvm/web49
cd web49
make CC=gcc # gcc is fastest in my tests
python3 -m pip install matplotlib
python3 bench.py
```

The wat2wasm tool is a much faster rewrite of wabt's wat2wasm, it does not handle names correctly yet.
### [Binary Trees](test/bench/binary-trees.c)
![](res/binary-trees.png)

## wasm2wasm
### [Coremark](test/bench/coremark.c)
![](res/coremark.png)

The wasm2wasm tool intends to do the same thing as a round trip to the text format and back. Effectivly seeing the binary as it is seen by miniwasm/wasm2wat=
### [Fannkuch Redux](test/bench/fannkuch-redux.c)
![](res/fannkuch-redux.png)

# whoami
### [Fibonacci on ints32_t](test/bench/fib_i32.c)
![](res/fib_i32.png)

I am Shaw Summa, of MiniVM fame.
### [Mandelbrot with SIMD](test/bench/mandelbrot-simd.c)
![](res/mandelbrot-simd.png)

### [Mandelbrot without SIMD](test/bench/mandelbrot.c)
![](res/mandelbrot.png)

### [Nbody](test/bench/nbody.c)
![](res/nbody.png)

### [Executing A Trap](test/bench/trap.c)
![](res/trap.png)
Binary file added res/binary-trees.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/coremark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/fannkuch-redux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/fib_f32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/fib_f64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/fib_i32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/fib_i64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/mandelbrot-simd.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/mandelbrot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/nbody.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/nop.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added res/trap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 70dd3e6

Please sign in to comment.