2e34bad267ffc09373b7e2384fc933135c9cfa3f
Gasm
A minimal implementation of Wasm Virtual machine purely written in Go. The VM passes all the Wasm Spec test suites and is fully compatible Wasm v1.0 Specification.
The VM can be embedded in your Go program without any dependency like cgo, and enables Gophers to write Wasm host environments easily.
Example
func Test_fibonacci(t *testing.T) {
binary, _ := os.ReadFile("wasm/fibonacci.wasm")
mod, _ := wasm.DecodeModule(binary)
vm, _ := wasm.NewVM()
vm.InstantiateModule(mod, "test")
for _, c := range []struct {
in, exp int32
}{
{in: 20, exp: 6765},
{in: 10, exp: 55},
{in: 5, exp: 5},
} {
ret, _, _ := vm.ExecExportedFunction("test", "fibonacci", uint64(c.in))
require.Equal(t, c.exp, int32(ret[0]))
}
}
References
Description
Languages
Go
98.7%
Makefile
0.4%
HTML
0.4%
Rust
0.2%
Shell
0.2%