Wagon exports multiple packages in accordance with the official WebAssembly specification:
-
Provides functions and strucutres for reading
.wasm
modules. The sub-packagewasm/operators
defines all WebAssembly operators, with their return and parameter types. -
Main entry point:
func ReadModule(r io.Reader, resolvePath ResolveFunc) (*Module, error)
. Module resolution is left to the user, to allow for non-WebAssembly/Go functions to be imported. -
Functions
Get{Function|Global|LinearMemoryData|TableElement}
provide access to a module's index spaces.
validate
allows users to validate a WebAssembly module.- It checks whether operators have correct intermediate values, type checks operands to operators and function calls, makes sure that control blocks or sequences have a consistent stack, verifies nesting depth for branching operators, etc.
- However, validation isnt restricted to the package
validate
alone. For instance,wasm
makes sure that all imported global variables are non-mutable, as per the WASM spec.
- While not a part of the official API,
disasm
allows users to disassemble WASM bytecode. - It does so by providing various types that describe the structure of a WASM function - with stack and control information.
- The package for executing WebAssembly bytecode. The internal package
exec/internal/compile
does some additional work by rewriting WASM bytecode to an easily executable format. - Wagon uses the official testsuite modules in the WebAssembly Binary Toolkit to test
exec
. The configuration for the tests can be found intestdata/modules.json
.
Because I am not familiar with the code generation phase of the Go compiler (gc
), and that JIT libraries produce code that wouldn't execute properly in a Go environment (calling conventions, lack of dynamic stacks), I was not able to add JIT functionality to wagon
. However, since the recent work on a plugin architecture in Go has allowed for dynamic loading of Go code, JIT might be a posibility soon.
As a part of the go-interpreter project, wagon should allow for WebAssembly code to refer to Go-land data and be able to call Go functions. This requires the development of an intermediate ABI for passing native Go types to WebAssembly.
One of Go's most promiment features is its concurrency constructs. Because they aren't yet avialable in WebAssembly, support for future concurrency APIs will have to be implemented in the future - perhaps with the help of an internal module imported by other modules.