3 ms·
Looks like the compiler includes support for amd64 and arm64 code generation. It's unclear if you can compile WASM to assembly at runtime and invoke it? If so,
by skybrian 5y ago
Looks like the compiler includes support for amd64 and arm64 code generation. It's unclear if you can compile WASM to assembly at runtime and invoke it? If so, it might be a viable way to implement plugin support.
- adrianfcole 5y ago(wazero maintainer) The default implementation will compile WASM to assembly not at runtime, but AOT (during Runtime.CompileModule). This allows more consistent performance and also more errors to materialize before a function call occurs. Compilation is automatic and also transparent (via mmap not files you configure), so you don't need to do anything special. waPC [1] (used by some things like kubewarden) is an example of a plugin system, and its go integration [2] is one of the few things currently using wazero. It also integrates with alternatives such as wasmer and wasmtime, so you can look at the code to see how things are different. We were intentionally hush about the project as we finish version 1.0, so weren't pushing for a lot of integrations, rather serving early adopters. Hence, wapc-go is currently the main victim of our api ;) hope this helps! [1] https://wapc.io/ https://wapc.io/ [2] https://github.com/wapc/wapc-go https://github.com/wapc/wapc-go
- skybrian 5y agoTo clarify the terminology, by AOT do you mean that the WASM needs to be compiled as part of the build of the Go executable that uses it, or just that it gets compiled before running the WASM code?
- adrianfcole 5y agonope this is all under the scenes. We formerly called this JIT, which was inaccurate but removed this confusion. Calling it AOT is more precise, but people ask this question. win some you lose some I guess! Anyway, if you use `wazero.NewRuntime()` magically it redirects to `wazero.NewRuntimeCompiler()`[1]. When the compiler is in use, all the native stuff happens automatically and you don't need to change your binary based on the wasm you use. This is actually neater than it seems as embedded compiler is goroutine safe, meaning you can compile modules concurrently. https://pkg.go.dev/github.com/tetratelabs/wazero#NewRuntimeConfigCompiler https://pkg.go.dev/github.com/tetratelabs/wazero#NewRuntimeC...
- skybrian 5y agoIt sounds promising! When explaining it, it might be a good idea to focus on a little more on what this technology can do for you: "How to add cross-platform plugin support to a Go program using WebAssembly."
- adrianfcole 5y agothumbs up and subscribe to this :) https://github.com/tetratelabs/wazero/issues/577 https://github.com/tetratelabs/wazero/issues/577