Skip to content

Commit ab2ae9b

Browse files
feat: rework instructions (#4)
2 parents 43e6d23 + 417bb70 commit ab2ae9b

26 files changed

+749
-613
lines changed

BENCHMARKS.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ All runtimes are compiled with the following settings:
3030

3131
| Benchmark | Native | TinyWasm\* | Wasmi | Wasmer (Single Pass) |
3232
| ------------ | -------- | ---------- | --------- | -------------------- |
33-
| `fib` | \*\* | ` 43.81µs` | `48.60µs` | ` 43.97µs` |
34-
| `fib-rec` | `0.26ms` | ` 20.99ms` | ` 4.64ms` | ` 0.50ms` |
35-
| `argon2id` | `0.53ms` | `107.77ms` | `47.76ms` | ` 4.49ms` |
36-
| `selfhosted` | `0.06ms` | ` 2.88ms` | ` 6.20ms` | `359.33ms` |
33+
| `fib` | \*\* | ` 43.60µs` | `48.27µs` | ` 44.99µs` |
34+
| `fib-rec` | `0.27ms` | ` 21.13ms` | ` 4.63ms` | ` 0.47ms` |
35+
| `argon2id` | `0.53ms` | ` 99.16ms` | `45.00ms` | ` 4.59ms` |
36+
| `selfhosted` | `0.05ms` | ` 1.84ms` | ` 6.51ms` | `446.48ms` |
3737

38-
_\* converting WASM to TinyWasm bytecode is not included. I takes ~7ms to convert `tinywasm.wasm` to TinyWasm bytecode._
38+
_\* converting WASM to TinyWasm bytecode is not included. I takes ~5.7ms to convert `tinywasm.wasm` to TinyWasm bytecode._
3939
_\*\* essentially instant as it gets computed at compile time._
4040

4141
### Fib

Cargo.lock

+23-23
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
## Why TinyWasm?
1414

15-
- **Tiny**: TinyWasm is designed to be as small as possible without significantly compromising performance or functionality.
15+
- **Tiny**: TinyWasm is designed to be as small as possible without significantly compromising performance or functionality (< 6000 lines of code).
1616
- **Portable**: TinyWasm runs on any platform that Rust can target, including WebAssembly itself, with minimal external dependencies.
1717
- **Lightweight**: TinyWasm is easy to integrate and has a low call overhead, making it suitable for scripting and embedding.
1818

crates/benchmarks/benches/fibonacci.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ fn run_wasmi(wasm: &[u8], iterations: i32, name: &str) {
1717

1818
fn run_wasmer(wasm: &[u8], iterations: i32, name: &str) {
1919
use wasmer::*;
20-
let engine: Engine = wasmer::Singlepass::default().into();
21-
let mut store = Store::default();
20+
let compiler = wasmer::Singlepass::default();
21+
let mut store = Store::new(compiler);
2222
let import_object = imports! {};
23-
let module = wasmer::Module::from_binary(&engine, wasm).expect("wasmer::Module::from_binary");
23+
let module = wasmer::Module::from_binary(&store, wasm).expect("wasmer::Module::from_binary");
2424
let instance = Instance::new(&mut store, &module, &import_object).expect("Instance::new");
2525
let fib = instance.exports.get_typed_function::<i32, i32>(&store, name).expect("get_function");
2626
fib.call(&mut store, iterations).expect("call");

crates/parser/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ repository.workspace=true
99

1010
[dependencies]
1111
# fork of wasmparser with no_std support, see https://github.com/bytecodealliance/wasmtime/issues/3495
12-
wasmparser={version="0.200.2", package="tinywasm-wasmparser", default-features=false}
12+
wasmparser={version="0.200.3", package="tinywasm-wasmparser", default-features=false}
1313
log={version="0.4", optional=true}
1414
tinywasm-types={version="0.4.0", path="../types", default-features=false}
1515

crates/parser/src/conversion.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ pub(crate) fn convert_valtype(valtype: &wasmparser::ValType) -> ValType {
226226
}
227227

228228
pub(crate) fn convert_memarg(memarg: wasmparser::MemArg) -> MemoryArg {
229-
MemoryArg { offset: memarg.offset, align: memarg.align, align_max: memarg.max_align, mem_addr: memarg.memory }
229+
MemoryArg { offset: memarg.offset, mem_addr: memarg.memory }
230230
}
231231

232232
pub(crate) fn process_const_operators(ops: OperatorsReader<'_>) -> Result<ConstInstruction> {

crates/parser/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#![forbid(unsafe_code)]
88
#![cfg_attr(not(feature = "std"), feature(error_in_core))]
99
//! See [`tinywasm`](https://docs.rs/tinywasm) for documentation.
10-
#![recursion_limit = "1028"]
1110
1211
mod std;
1312
extern crate alloc;

0 commit comments

Comments
 (0)