Wasmtime: C++
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Classes | Macros | Typedefs | Enumerations | Functions | Variables
wasmtime.hh File Reference
#include <any>
#include <array>
#include <cstdio>
#include <initializer_list>
#include <iosfwd>
#include <limits>
#include <memory>
#include <optional>
#include <ostream>
#include <variant>
#include <vector>
#include "wasmtime.h"

Go to the source code of this file.

Classes

struct  wasmtime::IsSpan< T >
 Check whether a type is Span More...
 
struct  wasmtime::IsSpan< Span< T, Extent > >
 
class  wasmtime::Span< T, Extent >
 Span class used when c++20 is not available. More...
 
class  wasmtime::Error
 Errors coming from Wasmtime. More...
 
class  wasmtime::Result< T, E >
 Fallible result type used for Wasmtime. More...
 
class  wasmtime::PoolAllocationConfig
 Pool allocation configuration for Wasmtime. More...
 
class  wasmtime::Config
 Configuration for Wasmtime. More...
 
class  wasmtime::Engine
 Global compilation state in Wasmtime. More...
 
class  wasmtime::ValType
 Type information about a WebAssembly value. More...
 
class  wasmtime::ValType::Ref
 Non-owning reference to a ValType, must not be used after the original ValType is deleted. More...
 
class  wasmtime::ValType::ListRef
 Non-owning reference to a list of ValType instances. Must not be used after the original owner is deleted. More...
 
class  wasmtime::MemoryType
 Type information about a WebAssembly linear memory. More...
 
class  wasmtime::MemoryType::Ref
 Non-owning reference to a MemoryType, must not be used after the original owner has been deleted. More...
 
class  wasmtime::TableType
 Type information about a WebAssembly table. More...
 
class  wasmtime::TableType::Ref
 
class  wasmtime::GlobalType
 Type information about a WebAssembly global. More...
 
class  wasmtime::GlobalType::Ref
 
class  wasmtime::FuncType
 Type information for a WebAssembly function. More...
 
class  wasmtime::FuncType::Ref
 
class  wasmtime::ImportType
 Type information about a WebAssembly import. More...
 
class  wasmtime::ImportType::Ref
 
class  wasmtime::ImportType::List
 An owned list of ImportType instances. More...
 
class  wasmtime::ExportType
 Type information about a WebAssembly export. More...
 
class  wasmtime::ExportType::Ref
 Non-owning reference to an ExportType. More...
 
class  wasmtime::ExportType::List
 An owned list of ExportType instances. More...
 
class  wasmtime::ExternType
 Generic type of a WebAssembly item. More...
 
class  wasmtime::FrameRef
 Non-owning reference to a WebAssembly function frame as part of a Trace More...
 
class  wasmtime::Trace
 An owned vector of FrameRef instances representing the WebAssembly call-stack on a trap. More...
 
class  wasmtime::Trap
 Information about a WebAssembly trap. More...
 
struct  wasmtime::TrapError
 Structure used to represent either a Trap or an Error. More...
 
class  wasmtime::Module
 Representation of a compiled WebAssembly module. More...
 
class  wasmtime::WasiConfig
 Configuration for an instance of WASI. More...
 
class  wasmtime::Store
 Owner of all WebAssembly objects. More...
 
class  wasmtime::Store::Context
 An interior pointer into a Store. More...
 
class  wasmtime::ExternRef
 Representation of a WebAssembly externref value. More...
 
struct  wasmtime::V128
 Container for the v128 WebAssembly type. More...
 
class  wasmtime::Val
 Representation of a generic WebAssembly value. More...
 
class  wasmtime::Caller
 Structure provided to host functions to lookup caller information or acquire a Store::Context. More...
 
struct  wasmtime::detail::WasmType< T >
 
struct  wasmtime::detail::WasmType< std::optional< ExternRef > >
 
struct  wasmtime::detail::WasmType< V128 >
 Type information for the V128 host value used as a wasm value. More...
 
struct  wasmtime::detail::WasmTypeList< T >
 
struct  wasmtime::detail::WasmTypeList< std::monostate >
 std::monostate translates to an empty list of types. More...
 
struct  wasmtime::detail::WasmTypeList< std::tuple< T... > >
 std::tuple<> translates to the corresponding list of types More...
 
struct  wasmtime::detail::WasmHostRet< R >
 
struct  wasmtime::detail::WasmHostRet< void >
 Host functions can return nothing. More...
 
struct  wasmtime::detail::WasmHostRet< std::monostate >
 
struct  wasmtime::detail::WasmHostRet< Result< R, Trap > >
 
struct  wasmtime::detail::WasmHostFunc< R(*)(A...)>
 
struct  wasmtime::detail::WasmHostFunc< R(*)(Caller, A...)>
 Function type information, but with a Caller first parameter. More...
 
struct  wasmtime::detail::WasmHostFunc< R(C::*)(A...)>
 Function type information, but with a class method. More...
 
struct  wasmtime::detail::WasmHostFunc< R(C::*)(A...) const >
 Function type information, but with a const class method. More...
 
struct  wasmtime::detail::WasmHostFunc< R(C::*)(Caller, A...)>
 
struct  wasmtime::detail::WasmHostFunc< R(C::*)(Caller, A...) const >
 
struct  wasmtime::detail::WasmHostFunc< T, std::void_t< decltype(&T::operator())> >
 
class  wasmtime::Func
 Representation of a WebAssembly function. More...
 
class  wasmtime::TypedFunc< Params, Results >
 A version of a WebAssembly Func where the type signature of the function is statically known. More...
 
struct  wasmtime::detail::WasmType< std::optional< Func > >
 Definition for the funcref native wasm type. More...
 
class  wasmtime::Global
 A WebAssembly global. More...
 
class  wasmtime::Table
 A WebAssembly table. More...
 
class  wasmtime::Memory
 A WebAssembly linear memory. More...
 
class  wasmtime::Instance
 A WebAssembly instance. More...
 
class  wasmtime::Linker
 Helper class for linking modules together with name-based resolution. More...
 

Macros

#define WASMTIME_FOR_EACH_VAL_KIND(X)
 
#define CASE_KIND_PRINT_NAME(kind, name, ignore)
 
#define CASE_KIND_TO_C(kind, ignore, ckind)
 
#define CASE_C_TO_KIND(kind, ignore, ckind)
 
#define NATIVE_WASM_TYPE(native, valkind, field)
 

Typedefs

template<typename T >
using wasmtime::TrapResult = Result< T, TrapError >
 
typedef std::variant< Func, Global, Memory, Table > wasmtime::Extern
 Representation of an external WebAssembly item.
 

Enumerations

enum class  wasmtime::Strategy { Auto = WASMTIME_STRATEGY_AUTO , Cranelift = WASMTIME_STRATEGY_CRANELIFT }
 Strategies passed to Config::strategy More...
 
enum class  wasmtime::OptLevel { None = WASMTIME_OPT_LEVEL_NONE , Speed = WASMTIME_OPT_LEVEL_SPEED , SpeedAndSize = WASMTIME_OPT_LEVEL_SPEED_AND_SIZE }
 Values passed to Config::cranelift_opt_level More...
 
enum class  wasmtime::ProfilingStrategy { None = WASMTIME_PROFILING_STRATEGY_NONE , Jitdump = WASMTIME_PROFILING_STRATEGY_JITDUMP , Vtune = WASMTIME_PROFILING_STRATEGY_VTUNE }
 Values passed to Config::profiler More...
 
enum class  wasmtime::ValKind {
  I32 , I64 , F32 , F64 ,
  V128 , ExternRef , FuncRef
}
 Different kinds of types accepted by Wasmtime. More...
 

Functions

std::ostream & wasmtime::operator<< (std::ostream &os, const Error &e)
 Used to print an error.
 
Result< std::vector< uint8_t > > wasmtime::wat2wasm (std::string_view wat)
 Converts the WebAssembly text format into the WebAssembly binary format. More...
 
std::ostream & wasmtime::operator<< (std::ostream &os, const ValKind &e)
 Used to print a ValKind.
 

Variables

constexpr size_t wasmtime::dynamic_extent
 Means number of elements determined at runtime. More...
 

Macro Definition Documentation

◆ CASE_C_TO_KIND

#define CASE_C_TO_KIND (   kind,
  ignore,
  ckind 
)
Value:
case ckind: \
return ValKind::kind;

◆ CASE_KIND_PRINT_NAME

#define CASE_KIND_PRINT_NAME (   kind,
  name,
  ignore 
)
Value:
case ValKind::kind: \
os << name; \
break;

◆ CASE_KIND_TO_C

#define CASE_KIND_TO_C (   kind,
  ignore,
  ckind 
)
Value:
case ValKind::kind: \
return ckind;

◆ NATIVE_WASM_TYPE

#define NATIVE_WASM_TYPE (   native,
  valkind,
  field 
)
Value:
template <> struct WasmType<native> { \
static const bool valid = true; \
static const ValKind kind = ValKind::valkind; \
static void store(Store::Context cx, wasmtime_val_raw_t *p, \
const native &t) { \
p->field = t; \
} \
static native load(Store::Context cx, wasmtime_val_raw_t *p) { \
return p->field; \
} \
};

Helper macro to define WasmType definitions for primitive types like int32_t and such.

◆ WASMTIME_FOR_EACH_VAL_KIND

#define WASMTIME_FOR_EACH_VAL_KIND (   X)
Value:
X(I32, "i32", WASM_I32) \
X(I64, "i64", WASM_I64) \
X(F32, "f32", WASM_F32) \
X(F64, "f64", WASM_F64) \
X(ExternRef, "externref", WASM_EXTERNREF) \
X(FuncRef, "funcref", WASM_FUNCREF) \
X(V128, "v128", WASMTIME_V128)

Helper X macro to construct statement for each enumerator in ValKind. X(enumerator in ValKind, name string, enumerator in wasm_valkind_t)

Typedef Documentation

◆ TrapResult

template<typename T >
using wasmtime::TrapResult = typedef Result<T, TrapError>

Result used by functions which can fail because of invariants being violated (such as a type error) as well as because of a WebAssembly trap.

Enumeration Type Documentation

◆ OptLevel

enum class wasmtime::OptLevel
strong

Values passed to Config::cranelift_opt_level

Enumerator
None 

No extra optimizations performed.

Speed 

Optimize for speed.

SpeedAndSize 

Optimize for speed and generated code size.

◆ ProfilingStrategy

enum class wasmtime::ProfilingStrategy
strong

Values passed to Config::profiler

Enumerator
None 

No profiling enabled.

Jitdump 

Profiling hooks via perf's jitdump.

Vtune 

Profiling hooks via VTune.

◆ Strategy

enum class wasmtime::Strategy
strong

Strategies passed to Config::strategy

Enumerator
Auto 

Automatically selects the compilation strategy.

Cranelift 

Requires Cranelift to be used for compilation.

◆ ValKind

enum class wasmtime::ValKind
strong

Different kinds of types accepted by Wasmtime.

Enumerator
I32 

WebAssembly's i32 type.

I64 

WebAssembly's i64 type.

F32 

WebAssembly's f32 type.

F64 

WebAssembly's f64 type.

V128 

WebAssembly's v128 type from the simd proposal.

ExternRef 

WebAssembly's externref type from the reference types.

FuncRef 

WebAssembly's funcref type from the reference types.

Function Documentation

◆ wat2wasm()

Result< std::vector< uint8_t > > wasmtime::wat2wasm ( std::string_view  wat)
inline

Converts the WebAssembly text format into the WebAssembly binary format.

This will parse the text format and attempt to translate it to the binary format. Note that the text parser assumes that all WebAssembly features are enabled and will parse syntax of future proposals. The exact syntax here parsed may be tweaked over time.

Returns either an error if parsing failed or the wasm binary.

Variable Documentation

◆ dynamic_extent

constexpr size_t wasmtime::dynamic_extent
inlineconstexpr
Initial value:
=
std::numeric_limits<std::size_t>::max()

Means number of elements determined at runtime.