https://github.com/beaglefoot/wasm-load-module-example
https://github.com/beaglefoot/wasm-load-module-example
docker wasm wasm-example
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/beaglefoot/wasm-load-module-example
- Owner: Beaglefoot
- Created: 2020-04-19T20:23:49.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2022-03-26T13:28:39.000Z (about 3 years ago)
- Last Synced: 2025-02-03T23:54:45.393Z (3 months ago)
- Topics: docker, wasm, wasm-example
- Language: JavaScript
- Size: 32.2 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# wasm-load-module-example
Naive side by side performance comparison of unmemoized Fibonacci number calculations.
Serves to demonstrate how to compile C function to WebAssembly and call it from JS without emscripten runtime.## How to build & run
1. `yarn install`
2. `docker build -t wasm-load-module-example .`
3. `docker cp $(docker run -d wasm-load-module-example):/usr/src/fib.wasm ./src/`
4. `yarn start`## To find names of exported wasm functions
Get inside docker container:
```sh
docker run -it wasm-load-module-example bash
```Once inside check WAST:
```sh
root@66cd9754dbf5:/usr/src# wasm-dis fib.wasm
(module
(type $0 (func (param i32) (result i32)))
(type $1 (func (result i32)))
(global $global$0 (mut i32) (i32.const 2752))
(export "_fibC" (func $0))
(export "_main" (func $1))
(export "stackAlloc" (func $2))
...
```## Helpful reading
[Compiling a New C/C++ Module to WebAssembly](https://developer.mozilla.org/en-US/docs/WebAssembly/C_to_wasm)[Using the WebAssembly JavaScript API](https://developer.mozilla.org/en-US/docs/WebAssembly/Using_the_JavaScript_API)
[WebAssembly Standalone](https://github.com/emscripten-core/emscripten/wiki/WebAssembly-Standalone)