Create a new dynamic (movable) memory instance for the specified plan.
(
ty: &wasmtime_environ::Memory,
engine: &Engine,
creator: &dyn RuntimeMemoryCreator,
memory_image: Option<&Arc<MemoryImage>>,
limiter: Option<&mut StoreResourc
| 239 | impl Memory { |
| 240 | /// Create a new dynamic (movable) memory instance for the specified plan. |
| 241 | pub async fn new_dynamic( |
| 242 | ty: &wasmtime_environ::Memory, |
| 243 | engine: &Engine, |
| 244 | creator: &dyn RuntimeMemoryCreator, |
| 245 | memory_image: Option<&Arc<MemoryImage>>, |
| 246 | limiter: Option<&mut StoreResourceLimiter<'_>>, |
| 247 | kind: MemoryKind, |
| 248 | ) -> Result<Self> { |
| 249 | let (minimum, maximum) = Self::limit_new(ty, limiter).await?; |
| 250 | let tunables = engine.tunables(); |
| 251 | let memory_tunables = MemoryTunables::new(tunables, kind); |
| 252 | let allocation = creator.new_memory(ty, &memory_tunables, minimum, maximum)?; |
| 253 | |
| 254 | let memory = LocalMemory::new(ty, &memory_tunables, allocation, memory_image)?; |
| 255 | Ok(if ty.shared { |
| 256 | Memory::Shared(SharedMemory::wrap(engine, ty, memory)?) |
| 257 | } else { |
| 258 | Memory::Local(memory) |
| 259 | }) |
| 260 | } |
| 261 | |
| 262 | /// Create a new static (immovable) memory instance for the specified plan. |
| 263 | #[cfg(feature = "pooling-allocator")] |