allocation/
directoryThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
README¶
Allocation examples
The examples in this directory deal with memory allocation concerns inWebAssembly, e.g. How to pass strings in and out of WebAssembly functions.
$ go run greet.go wazerowasm >> Hello, wazero!go >> Hello, wazero!While the below examples use strings, they are written in a way that would workfor binary serialization.
- Rust - Calls Wasm built with
cargo build --release --target wasm32-unknown-unknown - TinyGo - Calls Wasm built with
tinygo build -o X.wasm -scheduler=none --no-debug -target=wasi X.go - Zig - Calls Wasm built with
zig build
Note: Each of the above languages differ in both terms of exports and runtimebehavior around allocation, because there is no WebAssembly specification forit. For example, TinyGo exports allocation functions while Rust and Zig don't.Also, Rust eagerly collects memory before returning from a Wasm function while TinyGodoes not.
We still try to keep the examples as close to the same as possible, andhighlight things to be aware of in the respective source and README files.