diff --git a/crates/runtime/src/cow.rs b/crates/runtime/src/cow.rs index bbe18363d1..3542c48552 100644 --- a/crates/runtime/src/cow.rs +++ b/crates/runtime/src/cow.rs @@ -422,6 +422,7 @@ impl MemoryImageSlot { } } + #[cfg(feature = "pooling-allocator")] pub(crate) fn dummy() -> MemoryImageSlot { MemoryImageSlot { base: 0, @@ -760,6 +761,12 @@ impl MemoryImageSlot { /// Map anonymous zeroed memory across the whole slot, /// inaccessible. Used both during instantiate and during drop. fn reset_with_anon_memory(&mut self) -> Result<()> { + if self.static_size == 0 { + assert!(self.image.is_none()); + assert_eq!(self.accessible, 0); + return Ok(()); + } + unsafe { cfg_if::cfg_if! { if #[cfg(unix)] { diff --git a/crates/runtime/src/memory.rs b/crates/runtime/src/memory.rs index aff54101d9..8a6d30d43b 100644 --- a/crates/runtime/src/memory.rs +++ b/crates/runtime/src/memory.rs @@ -10,7 +10,6 @@ use crate::Store; use anyhow::Error; use anyhow::{bail, format_err, Result}; use std::convert::TryFrom; -use std::mem; use std::sync::atomic::Ordering; use std::sync::{Arc, RwLock}; use wasmtime_environ::{MemoryPlan, MemoryStyle, WASM32_MAX_PAGES, WASM64_MAX_PAGES}; @@ -768,7 +767,7 @@ impl Memory { #[cfg(feature = "pooling-allocator")] pub fn unwrap_static_image(mut self) -> MemoryImageSlot { let mem = self.0.as_any_mut().downcast_mut::().unwrap(); - mem::replace(&mut mem.memory_image, MemoryImageSlot::dummy()) + std::mem::replace(&mut mem.memory_image, MemoryImageSlot::dummy()) } /// If the [Memory] is a [SharedMemory], unwrap it and return a clone to