MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / new_dynamic

Method new_dynamic

crates/wasmtime/src/runtime/vm/memory.rs:241–260  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

239impl 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")]

Callers

nothing calls this directly

Calls 6

OkFunction · 0.85
SharedClass · 0.85
LocalClass · 0.85
newFunction · 0.50
tunablesMethod · 0.45
new_memoryMethod · 0.45

Tested by

no test coverage detected