diff options
| -rw-r--r-- | README.md | 9 | ||||
| -rw-r--r-- | crates/parser/src/conversion.rs | 2 | ||||
| -rw-r--r-- | crates/types/src/instructions.rs | 7 |
3 files changed, 11 insertions, 7 deletions
@@ -1,7 +1,7 @@ <p align="center"> <img src="./tinywasm.png" width="100px"> <h1 align="center">TinyWasm</h1> - <h3 align="center">A tiny, interpreted WebAssembly Runtime written in Rust.</h3> + <h3 align="center">A tiny WebAssembly Runtime written in Rust.</h3> </p> <br/> @@ -11,10 +11,11 @@ # 🎯 Goals +* Interpreted Runtime * No unsafe code -* Works on `no_std` (with `alloc` the feature and nightly cler) -* Fully support WebAssembly MVP -* Low Memory Usage +* Works on `no_std` (with `alloc` the feature and nightly compiler) +* Fully support WebAssembly MVP (1.0) +* Low Memory Usage (less than 10kb) * Fast Startup Time * Preemptive multitasking support diff --git a/crates/parser/src/conversion.rs b/crates/parser/src/conversion.rs index ee30db9..86810a1 100644 --- a/crates/parser/src/conversion.rs +++ b/crates/parser/src/conversion.rs @@ -109,7 +109,7 @@ pub fn process_operators<'a>( .targets() .collect::<Result<Vec<u32>, wasmparser::BinaryReaderError>>()? .into_iter() - .map(Instruction::Br), + .map(Instruction::BrLabel), ); } op => instructions.push(process_operator(&op)?), diff --git a/crates/types/src/instructions.rs b/crates/types/src/instructions.rs index dca99fe..2be0ce7 100644 --- a/crates/types/src/instructions.rs +++ b/crates/types/src/instructions.rs @@ -16,7 +16,9 @@ pub struct MemArg { /// A WebAssembly Instruction /// See https://webassembly.github.io/spec/core/binary/instructions.html -/// Currently includes all instructions from the MVP (1.0) spec +/// These are our own internal bytecode instructions so they may not match the spec exactly. +/// Wasm Bytecode can map to multiple of these instructions. +/// For example, `br_table` stores the jump lables in the following `br_label` instructions to keep this enum small. #[derive(Debug, Clone, Copy, PartialEq)] pub enum Instruction { // Control Instructions @@ -30,7 +32,8 @@ pub enum Instruction { End, Br(LabelAddr), BrIf(LabelAddr), - BrTable(u32), // not to spec, has to be followed by multiple Br instructions with labels + BrTable(u32), // has to be followed by multiple BrLabel instructions + BrLabel(LabelAddr), Return, Call(FuncAddr), CallIndirect(TypeAddr, TableAddr), |
