Skip to content

Instantly share code, notes, and snippets.

@webmaster128
Created May 4, 2023 11:36
Show Gist options
  • Save webmaster128/3528145a49ec4ff20bafc64336be4e3c to your computer and use it in GitHub Desktop.
Save webmaster128/3528145a49ec4ff20bafc64336be4e3c to your computer and use it in GitHub Desktop.
Use new runtime stores in Wasmer 3 examples
diff --git a/examples/compiler_singlepass.rs b/examples/compiler_singlepass.rs
index 01fb181b12..5d6d90152f 100644
--- a/examples/compiler_singlepass.rs
+++ b/examples/compiler_singlepass.rs
@@ -41,6 +41,10 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create an empty import object.
let import_object = imports! {};
+ // Create a new store for this instance
+ let compiler = Singlepass::default();
+ let mut store = Store::new(compiler);
+
println!("Instantiating module...");
// Let's instantiate the Wasm module.
let instance = Instance::new(&mut store, &module, &import_object)?;
diff --git a/examples/exports_memory.rs b/examples/exports_memory.rs
index 8cb29e2e6d..6a1ebaf802 100644
--- a/examples/exports_memory.rs
+++ b/examples/exports_memory.rs
@@ -45,6 +45,9 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create an empty import object.
let import_object = imports! {};
+ // Create a new store for this instance
+ let mut store = Store::new(Cranelift::default());
+
println!("Instantiating module...");
// Let's instantiate the Wasm module.
let instance = Instance::new(&mut store, &module, &import_object)?;
diff --git a/examples/memory.rs b/examples/memory.rs
index 52528e3dcb..f278d3b698 100644
--- a/examples/memory.rs
+++ b/examples/memory.rs
@@ -65,6 +65,9 @@ fn main() -> anyhow::Result<()> {
// Create an empty import object.
let import_object = imports! {};
+ // Create a new store for this instance
+ let mut store = Store::new(Cranelift::default());
+
println!("Instantiating module...");
// Let's instantiate the Wasm module.
let instance = Instance::new(&mut store, &module, &import_object)?;
diff --git a/examples/metering.rs b/examples/metering.rs
index e5d8c70d74..8fc4638b2a 100644
--- a/examples/metering.rs
+++ b/examples/metering.rs
@@ -78,6 +78,9 @@ fn main() -> anyhow::Result<()> {
// Create an empty import object.
let import_object = imports! {};
+ // Create a new store for this instance
+ let mut store = Store::new(Cranelift::default());
+
println!("Instantiating module...");
// Let's instantiate the Wasm module.
let instance = Instance::new(&mut store, &module, &import_object)?;
diff --git a/examples/tunables_limit_memory.rs b/examples/tunables_limit_memory.rs
index da2c7a4ece..2cda1add50 100644
--- a/examples/tunables_limit_memory.rs
+++ b/examples/tunables_limit_memory.rs
@@ -154,6 +154,14 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("Instantiating module...");
let import_object = imports! {};
+ // Create a new store for this instance
+ let compiler = Cranelift::default();
+ let base = BaseTunables::for_target(&Target::default());
+ let tunables = LimitingTunables::new(base, Pages(24));
+ let mut engine: Engine = compiler.into();
+ engine.set_tunables(tunables);
+ let mut store = Store::new(engine);
+
// Now at this point, our custom tunables are used
let instance = Instance::new(&mut store, &module, &import_object)?;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment