This PR introduces internal directory and put all the following non-user-relevant packages there:
* wazeroir
* leb128
* ieee754
* wasm/example
*spectests
Also this creates interpreter package where we put the wazeroir interpreter taken out of wazeroir pkg
since the fact wazeroir.NewEngine returns interpreter is not intuitive to users and IR is IR so it shouldn’t
be the matter of users.
Signed-off-by: Takeshi Yoneda <takeshi@tetrate.io>
This moves encoding logic into the packages binary and text, adding a
new top-level function for encoding and decoding:
Signed-off-by: Adrian Cole <adrian@tetrate.io>
Co-authored-by: Takeshi Yoneda <takeshi@tetrate.io>
The completes the minimal features required to run the following:
```
(module
(import "" "hello" (func $hello))
(start $hello)
)
```
Signed-off-by: Adrian Cole <adrian@tetrate.io>
A particularly confusing point is that function indices in Wasm are
preceded by imports. Hopefully, this helps reduce that confusion.
Signed-off-by: Adrian Cole <adrian@tetrate.io>
This adds a simpler example, which helps understand the basic ins and
outs. This will be used later when the %.wat parser is implemented.
Along the way, I noticed naming inconsistency. Most of the time,
function inputs are named params and outputs are named results. Using
the same vocab helps when mapping the spec to our code.
See https://www.w3.org/TR/wasm-core-1/#function-types%E2%91%A6
Signed-off-by: Adrian Cole <adrian@tetrate.io>
Co-authored-by: Takeshi Yoneda <takeshi@tetrate.io>
Previously, we didn't execute _start function which is in charge of
in-Wasm memory state initialization.
That's why we faced the memory related error with -gc=conservative
which is the default validator.
Also this commit revives the file system example which was temporarily removed.
This commit adds the parser of the "name" custom section[1],
and starts emitting the backtrace of the program into the runtime error message
by leveraging the function name informations stored in "name" custom section.
Note that this is the minimal implementation -- the trace doesn't contain the
original Wasm instruction address nor the source code info. The former
can be implemented easily but the latter requires us to implement the Wasm
DWARF format parser of .debug_* custom sections[2].
[1] https://webassembly.github.io/spec/core/appendix/custom.html#name-section
[2] https://yurydelendik.github.io/webassembly-dwarf/
The following is the output from examples/trap_test.go:
=== RUN Test_trap
panic: causing panic!!!!!!!!!!
wasm runtime error: unreachable
wasm backtrace:
0: runtime._panic
1: main.three
2: main.two
3: main.one
4: cause_panic
This commit fixes a bug that exists in naivevm implementation
around stack frames. Notably this fixes the usage of
recursive VM calls (i.e. calling VM functions inside of the
host function implementations). In order to test the behavior,
we enhance the host_func.go example so that we use
the recursive VM calls.
This adds CI for example code TinyGo -> Wasm. Differences are ignored because compilation is not idempotent.
Signed-off-by: Adrian Cole <adrian@tetrate.io>
This renames the project to wazero, which emphasizes that this runtime
has no platform depedencies (notably CGO). To avoid having users change
their imports twice, this also changes the org to "tetratelabs" ahead of
transfer.
Exciting times ahead, wazeros!
Signed-off-by: Adrian Cole <adrian@tetrate.io>