diff options
| author | Henry Gressmann <mail@henrygressmann.de> | 2024-06-30 22:19:25 +0200 |
|---|---|---|
| committer | Henry Gressmann <mail@henrygressmann.de> | 2024-06-30 22:19:25 +0200 |
| commit | 4425733bdfb516ca2530e6199c2c95ece91b627d (patch) | |
| tree | 2b50626d449c5b4f2295ac90f93d28df1600a901 /examples/wasm-rust.rs | |
| parent | 9c85fa9c3a2066ce851af53d7019e6a25a45af3b (diff) | |
chore: Memory and Data Instances are no longer reference counted
Signed-off-by: Henry Gressmann <mail@henrygressmann.de>
Diffstat (limited to 'examples/wasm-rust.rs')
| -rw-r--r-- | examples/wasm-rust.rs | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/examples/wasm-rust.rs b/examples/wasm-rust.rs index 79fb8fb..5d32cd2 100644 --- a/examples/wasm-rust.rs +++ b/examples/wasm-rust.rs @@ -1,3 +1,5 @@ +use std::hint::black_box; + use eyre::{eyre, Result}; use tinywasm::{Extern, FuncContext, Imports, MemoryStringExt, Module, Store}; @@ -66,19 +68,13 @@ fn tinywasm() -> Result<()> { let mut store = Store::default(); let mut imports = Imports::new(); - imports.define( - "env", - "printi32", - Extern::typed_func(|_: FuncContext<'_>, x: i32| { - println!("{}", x); - Ok(()) - }), - )?; - let instance = module.instantiate(&mut store, Some(imports))?; + imports.define("env", "printi32", Extern::typed_func(|_: FuncContext<'_>, _x: i32| Ok(())))?; + let instance = module.instantiate(&mut store, Some(black_box(imports)))?; let hello = instance.exported_func::<(), ()>(&store, "hello")?; - hello.call(&mut store, ())?; - + hello.call(&mut store, black_box(()))?; + hello.call(&mut store, black_box(()))?; + hello.call(&mut store, black_box(()))?; Ok(()) } @@ -133,7 +129,7 @@ fn printi32() -> Result<()> { } fn fibonacci() -> Result<()> { - let module = Module::parse_file("./examples/rust/out/fibonacci.wasm")?; + let module = Module::parse_file("./examples/rust/out/fibonacci.opt.wasm")?; let mut store = Store::default(); let instance = module.instantiate(&mut store, None)?; @@ -146,7 +142,7 @@ fn fibonacci() -> Result<()> { } fn argon2id() -> Result<()> { - let module = Module::parse_file("./examples/rust/out/argon2id.wasm")?; + let module = Module::parse_file("./examples/rust/out/argon2id.opt.wasm")?; let mut store = Store::default(); let instance = module.instantiate(&mut store, None)?; |
