Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
787: feat(interface-types) Implement Interface Types (WIT) r=Hywan a=Hywan So far, this PR implements a new crate named `wasmer-interface-types`. The goal is to implement the WebAssembly Interface Types (WIT) proposal, https://github.com/WebAssembly/interface-types. Keep in mind the proposal is highly unstable and experimental. The `wasmer-interface-types` is designed to be _runtime agnostic_, which means that there is no connection between this crate and `wasmer-runtime-core` or `wasmer-runtime` (or any backend crates). The hope is that other runtimes could use `wasmer-interface-types` according to their needs. The `wasmer-interface-types` is composed of 4 parts: * AST: [The WIT language, represented as an AST](https://github.com/Hywan/wasmer/blob/feat-interface-types/lib/interface-types/src/ast.rs) (it's not really abstract though), * Decoders: So far, it contains only [one parser that reads the WIT binary language](https://github.com/Hywan/wasmer/blob/feat-interface-types/lib/interface-types/src/decoders/binary.rs) and produces an AST, * Encoders: So far, it contains only [one compiler that transforms the AST into "WIT.wat”](https://github.com/Hywan/wasmer/blob/feat-interface-types/lib/interface-types/src/encoders/wat.rs), i.e. the textual representation of an Interface Types AST * Instructions: WIT defines a new concept called Adapters. An adapter contains a set of instructions. Those instructions are executed when data are bound. So, in more details, this module contains: * [`interpreter.rs`](https://github.com/Hywan/wasmer/blob/feat-interface-types/lib/interface-types/src/interpreter/mod.rs), a stack-based interpreter, defined by: * A compiler that transforms a set of instructions into a set of _executable_ instructions, * A stack, * A runtime that holds the “invocation inputs” (arguments of the interpreter), the stack, and the Wasm instance (which holds the exports, the imports, the memories, the tables etc.), * [`stack.rs`](https://github.com/Hywan/wasmer/blob/feat-interface-types/lib/interface-types/src/interpreter/stack.rs), a very light and generic stack implementation, exposing only the API required by the interpreter, * [`wasm/*.rs`](https://github.com/Hywan/wasmer/blob/feat-interface-types/lib/interface-types/src/interpreter/wasm/structures.rs), a set of enums, types, and traits to represent a Wasm runtime —basically this is the part a runtime should take a look to support the `wasmer-interface-types` crate—. Progression: * [x] WIT binary parser, * [x] WIT.wat compiler, * [ ] Interpreter: * [ ] Wasm runtime traits to represent: * [x] Instance, * [x] Export, * [x] Memory, * [x] Import, * [ ] Table, * [x] Generic stack implementation, * [ ] Implemented instructions: * [x] `arg.get`, * [x] `call`, * [x] `call-export`, * [x] `read-utf8`, * [x] `write-utf8`, * [ ] `as-wasm`, * [ ] `as-interface` * [ ] `table-ref-add` * [ ] `table-ref-get` * [ ] `call-method` * [ ] `make-record` * [ ] `get-field` * [ ] `const` * [ ] `fold-seq` * [ ] `add` * [ ] `mem-to-seq` * [ ] `load` * [ ] `seq.new` * [ ] `list.push` * [ ] `repeat-until` * [ ] `seq-to-mem` * [ ] `store` * [ ] Plug `wasmer-interface-types` into `wasmer-runtime-core` Co-authored-by: Ivan Enderlin <ivan.enderlin@hoa-project.net>
- Loading branch information