Skip to content

A lightweight WebAssembly runtime that is fast, secure, and standards-compliant

Remove unnecessary `memory_tys` param from `vm::Instance::new` (#12414)

Nick Fitzgerald58ce6b8b89bf
diff --git a/crates/wasmtime/src/runtime/vm/instance.rs b/crates/wasmtime/src/runtime/vm/instance.rs
index ebf0982ce5..2df61b88b9 100644
--- a/crates/wasmtime/src/runtime/vm/instance.rs
+++ b/crates/wasmtime/src/runtime/vm/instance.rs
@@ -161,12 +161,25 @@ impl Instance {
req: InstanceAllocationRequest,
memories: PrimaryMap<DefinedMemoryIndex, (MemoryAllocationIndex, Memory)>,
tables: PrimaryMap<DefinedTableIndex, (TableAllocationIndex, Table)>,
- memory_tys: &PrimaryMap<MemoryIndex, wasmtime_environ::Memory>,
) -> InstanceHandle {
let module = req.runtime_info.env_module();
+ let memory_tys = &module.memories;
let dropped_elements = EntitySet::with_capacity(module.passive_elements.len());
let dropped_data = EntitySet::with_capacity(module.passive_data_map.len());
+ #[cfg(feature = "wmemcheck")]
+ let wmemcheck_state = if req.store.engine().config().wmemcheck {
+ let size = memory_tys
+ .iter()
+ .next()
+ .map(|memory| memory.1.limits.min)
+ .unwrap_or(0)
+ * 64
+ * 1024;
+ Some(Wmemcheck::new(size.try_into().unwrap()))
+ } else {
+ None
+ };
#[cfg(not(feature = "wmemcheck"))]
let _ = memory_tys;
@@ -178,20 +191,7 @@ impl Instance {
dropped_elements,
dropped_data,
#[cfg(feature = "wmemcheck")]
- wmemcheck_state: {
- if req.store.engine().config().wmemcheck {
- let size = memory_tys
- .iter()
- .next()
- .map(|memory| memory.1.limits.min)
- .unwrap_or(0)
- * 64
- * 1024;
- Some(Wmemcheck::new(size.try_into().unwrap()))
- } else {
- None
- }
- },
+ wmemcheck_state,
store: None,
vmctx: OwnedVMContext::new(),
});
diff --git a/crates/wasmtime/src/runtime/vm/instance/allocator.rs b/crates/wasmtime/src/runtime/vm/instance/allocator.rs
index 3e420cf096..247cce6f51 100644
--- a/crates/wasmtime/src/runtime/vm/instance/allocator.rs
+++ b/crates/wasmtime/src/runtime/vm/instance/allocator.rs
@@ -344,7 +344,6 @@ impl dyn InstanceAllocator + '_ {
request,
mem::take(&mut guard.memories),
mem::take(&mut guard.tables),
- &module.memories,
))
};