[][src]Crate wasmer_runtime_core

Wasmer Runtime Core Library

Important Note; Please Read

Wasmer has entirely changed its API (called the “new API” here). This new version of Wasmer improves the performance and the memory consumption, in addition to a ton of new features and much more flexibility! In order to help users to enjoy the performance boost and memory improvements without updating your program that much, we have created a new version of the wasmer-runtime-core crate, which is now a port of the new API but with the old API, as much as possible. Indeed, it was not always possible to provide the exact same API, but changes are subtle.

We have carefully documented most of the differences. It is important to understand the public of this port (see the CHANGES.md) document. We do not recommend to advanced users of Wasmer to use this port. Advanced API, like ModuleInfo or the vm module (incl. vm::Ctx) have not been fully ported because it was very internals to Wasmer. For advanced users, we highly recommend to migrate to the new version of Wasmer, which is awesome by the way (completely neutral opinion). The public for this port is beginners or regular users that do not necesarily have time to update their code immediately but that want to enjoy a performance boost and memory improvements.

Introduction

This crate provides common data structures which are shared by compiler backends to implement a WebAssembly runtime.

This crate also provides an API for users who use wasmer as an embedded wasm runtime which allows operations like compiling, instantiating, providing imports, access exports, memories, and tables for example.

Most wasmer users should prefer the API which is re-exported by the wasmer-runtime library by default. This crate provides additional APIs which may be useful to users that wish to customize the wasmer runtime.

Re-exports

pub use crate::cache::Artifact;
pub use crate::cache::WasmHash;
pub use crate::import::IsExport;
pub use crate::instance::DynFunc;
pub use crate::instance::Exports;
pub use crate::instance::Instance;
pub use crate::module::Module;
pub use crate::new::wasmer_compiler::wasmparser;
pub use crate::typed_func::DynamicFunc;
pub use crate::typed_func::Func;

Modules

backend
cache

The cache module provides the common data structures used by compiler backends to allow serializing compiled wasm code to a binary format. The binary format can be persisted, and loaded to allow skipping compilation and fast startup.

error
export
global
import
instance
memory
module
prelude
structures
table
typed_func
types
units
vm

Macros

func

Helper macro to create a new Func object using the provided function pointer.

imports

Generate an ImportObject easily with the imports! macro.

Structs

Bytes

Units of WebAssembly memory in terms of 8-bit bytes.

Pages

Units of WebAssembly pages (as specified to be 65,536 bytes).

Constants

VERSION

The current version of this crate

WASM_MAX_PAGES

The number of pages we can have before we run out of byte index space.

WASM_MIN_PAGES

The minimum number of pages allowed.

WASM_PAGE_SIZE

WebAssembly page sizes are fixed to be 64KiB. Note: large page support may be added in an opt-in manner in the future.

Functions

compile

Compile WebAssembly binary code into a Module. This function is useful if it is necessary to compile a module before it can be instantiated (otherwise, the instantiate function should be used).

compile_with

Compile a Module using the provided compiler from WebAssembly binary code. This function is useful if it is necessary to a compile a module before it can be instantiated and must be used if you wish to use a different backend from the default.

compile_with_config

The same as compile_with but changes the compiler behavior with the values in the CompilerConfig

get_global_store

Useful if one needs to migrate to the new Wasmer's API gently.

load_cache_with

Creates a new module from the given cache Artifact

validate

Perform validation as defined by the WebAssembly specification. Returns true if validation succeeded, false if validation failed.

wat2wasm

Parses in-memory bytes as either the WebAssembly Text format, or a binary WebAssembly module.