pub unsafe trait InstanceAllocator: Send + Sync {
    unsafe fn allocate(
        &self,
        req: InstanceAllocationRequest<'_>
    ) -> Result<InstanceHandle, InstantiationError>;
unsafe fn initialize(
        &self,
        handle: &mut InstanceHandle,
        module: &Module,
        is_bulk_memory: bool
    ) -> Result<(), InstantiationError>;
unsafe fn deallocate(&self, handle: &InstanceHandle);
fn allocate_fiber_stack(&self) -> Result<FiberStack, FiberStackError>;
unsafe fn deallocate_fiber_stack(&self, stack: &FiberStack); fn validate(&self, module: &Module) -> Result<()> { ... }
fn adjust_tunables(&self, tunables: &mut Tunables) { ... } }
Expand description

Represents a runtime instance allocator.

Safety

This trait is unsafe as it requires knowledge of Wasmtime’s runtime internals to implement correctly.

Required methods

Allocates an instance for the given allocation request.

Safety

This method is not inherently unsafe, but care must be made to ensure pointers passed in the allocation request outlive the returned instance.

Finishes the instantiation process started by an instance allocator.

Safety

This method is only safe to call immediately after an instance has been allocated.

Deallocates a previously allocated instance.

Safety

This function is unsafe because there are no guarantees that the given handle is the only owner of the underlying instance to deallocate.

Use extreme care when deallocating an instance so that there are no dangling instance pointers.

Allocates a fiber stack for calling async functions on.

Deallocates a fiber stack that was previously allocated with allocate_fiber_stack.

Safety

The provided stack is required to have been allocated with allocate_fiber_stack.

Provided methods

Validates that a module is supported by the allocator.

Adjusts the tunables prior to creation of any JIT compiler.

This method allows the instance allocator control over tunables passed to a wasmtime_jit::Compiler.

Implementors