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

Method new_dynamic

crates/wasmtime/src/runtime/vm/table.rs:331–353  ·  view source on GitHub ↗

Create a new dynamic (movable) table instance for the specified table plan.

(
        ty: &wasmtime_environ::Table,
        tunables: &Tunables,
        limiter: Option<&mut StoreResourceLimiter<'_>>,
    )

Source from the content-addressed store, hash-verified

329impl Table {
330 /// Create a new dynamic (movable) table instance for the specified table plan.
331 pub async fn new_dynamic(
332 ty: &wasmtime_environ::Table,
333 tunables: &Tunables,
334 limiter: Option<&mut StoreResourceLimiter<'_>>,
335 ) -> Result<Self> {
336 let (minimum, maximum) = Self::limit_new(ty, limiter).await?;
337 match wasm_to_table_type(ty.ref_type) {
338 TableElementType::Func => Ok(Self::from(DynamicFuncTable {
339 elements: unsafe { alloc_dynamic_table_elements(minimum)? },
340 maximum,
341 lazy_init: tunables.table_lazy_init,
342 })),
343 TableElementType::GcRef => Ok(Self::from(DynamicGcRefTable {
344 elements: unsafe { alloc_dynamic_table_elements(minimum)? },
345 maximum,
346 })),
347 TableElementType::Cont => {
348 let mut elements = TryVec::new();
349 elements.resize_with(minimum, || None)?;
350 Ok(Self::from(DynamicContTable { elements, maximum }))
351 }
352 }
353 }
354
355 /// Create a new static (immovable) table instance for the specified table plan.
356 pub async unsafe fn new_static(

Callers

nothing calls this directly

Calls 6

wasm_to_table_typeFunction · 0.85
OkFunction · 0.85
fromFunction · 0.85
resize_withMethod · 0.80
newFunction · 0.50

Tested by

no test coverage detected