Skip to main content

Crate rwasm

Crate rwasm 

Source

Modules§

intrinsic
wasmtime

Macros§

instruction_set
instruction_set_internal

Structs§

BranchOffset
A signed offset for branch instructions.
Bytes
An amount of bytes of a linear memory.
CallStack
A lightweight call stack used by the interpreter to track return addresses. It stores instruction pointers for active calls and allows fast push/pop without heap churn. The capacity grows on demand but is typically small due to Wasm’s structured control flow.
CompilationConfig
Controls how a Wasm module is lowered into rwasm bytecode. Options affect entry routing, import linking, fuel metering, and validation relaxations for tests.
ConstructorParams
Optional binary blob passed to the module constructor via a custom section. When present, it is extracted from the “input” custom section and delivered to the host.
ExecutionEngine
Represents the core execution engine for managing the execution of a program, including the handling of values and function calls.
F32
A NaN preserving f32 type.
F64
A NaN preserving f64 type.
FuelCosts
Type storing all kinds of fuel costs of instructions.
FuncRef
Opaque reference to a function within the module’s function index space. A zero value is reserved for the null reference, mirroring Wasm’s funcref null semantics.
FuncType
Represents a type of a function in a WebAssembly module.
GlobalMemory
Shared linear memory backing store for a running module. Tracks current size in Wasm pages and provides bounds-checked read/write helpers. The buffer is pre-reserved and grown in page-sized steps.
GlobalVariable
Describes a module’s global (type and initial value) as seen at compile time. The value can be materialized into a runtime Value when the type permits.
ImportLinker
ImportLinkerEntity
ImportName
The name or namespace of an imported item.
InstructionPtr
The instruction pointer to the instruction of a function on the call stack.
InstructionSet
Compact, linear sequence of rwasm opcodes produced by the compiler. Acts as the executable bytecode for the interpreter and supports simple editing during lowering. The layout is stable and indexable to allow inexpensive jumps and metadata lookups.
LinearFuelParams
Parameters for the linear fuel charging strategy.
ModuleParser
Single-pass Wasm front-end that validates, translates, and assembles rwasm bytecode. It streams the Wasm module with wasmparser, builds the instruction set and sections, and applies configuration (entry routing, snippets) before finalizing the module.
OpcodeMeta
Pages
An amount of linear memory pages.
QuadraticFuelParams
Parameters for the quadratic fuel charging strategy.
ReusableContext
RwasmCaller
RwasmCompilationResult
RwasmExecutor
The RwasmExecutor struct is a foundational component for executing WebAssembly modules in the rwasm runtime environment. It acts as the primary execution object, coordinating the state and execution flow of a WebAssembly module.
RwasmInstance
RwasmModule
Represents a compiled rWasm module.
RwasmModuleBuilder
RwasmModuleInner
RwasmStore
Host-side store that holds memory, tables, globals, and host context for a rwasm instance. It also tracks fuel for metering and provides access to imported functions and syscalls. The store is passed to host callbacks and persists across invocations of the same module.
SimpleCallContext
StateRouterConfig
Configuration for dispatching to different entry functions based on a runtime state value. The router maps state tags to function indices and optionally provides an opcode to compute the tag.
SyscallName
Fully-qualified syscall name (module + function).
TableEntity
A Wasm table entity.
UntypedValue
An untyped value.
ValueStack
The value stack used to execute Wasm bytecode.
ValueStackPtr
A pointer on the ValueStack.

Enums§

CompilationError
HintType
Type of the hint
Opcode
RwasmError
StrategyDefinition
StrategyError
StrategyExecutor
SyscallFuelParams
Fuel charging policy for a syscall.
TrapCode
TypedCaller
TypedStore
ValType
Represents the types of values in a WebAssembly module.
Value
Runtime representation of a value.

Constants§

BASE_FUEL_COST
Default cost for “ordinary” operators that don’t fall into other buckets.
CALL_FUEL_COST
Cost for direct and indirect calls.
DEFAULT_MEMORY_INDEX
A default memory index in a Wasm binary. According to Wasm validation rules, this value is always 0, since Wasm doesn’t support multiple memory segments yet
DROP_KEEP_PER_FUEL
Drop/keep stack manipulation granularity (must be a power of two).
DROP_KEEP_PER_FUEL_LOG2
log2(DROP_KEEP_PER_FUEL).
ENTITY_FUEL_COST
Cost for operators that touch global/module entities (tables, memories, globals, etc.).
FUEL_MAX_LINEAR_X
Upper bound for the input parameter x used by linear syscall/builtin gas formulas.
FUEL_MAX_QUADRATIC_X
Upper bound for the input parameter x used by quadratic syscall/builtin gas formulas.
LOAD_FUEL_COST
Cost for load instructions.
LOCALS_PER_FUEL
Number of locals that correspond to one unit of fuel (currently 1).
LOCALS_PER_FUEL_LOG2
log2(LOCALS_PER_FUEL) (0 because LOCALS_PER_FUEL == 1).
MEMORY_BYTES_PER_FUEL
Number of memory bytes that correspond to one unit of fuel (must be a power of two).
MEMORY_BYTES_PER_FUEL_LOG2
log2(MEMORY_BYTES_PER_FUEL).
NULL_FUNC_IDX
For null RefFunc/ExternRef types we use 0. We can do this because 0 offset is reserved under an entrypoint that can’t be re-called
N_BYTES_PER_MEMORY_PAGE
This constant is driven by WebAssembly standard, default memory page size is 64kB
N_DEFAULT_MAX_MEMORY_PAGES
A default number of memory pages 1024 pages (64mB)
N_DEFAULT_STACK_SIZE
A default stack size we use for stack allocation.
N_MAX_ALLOWED_MEMORY_PAGES
A hard limit on the maximum number of memory pages that can be allocated. This value is driven from a Wasm standard, the maximum number of memory pages is 32,768.
N_MAX_DATA_SEGMENTS
N_MAX_DATA_SEGMENTS_BITS
N_MAX_ELEM_SEGMENTS
N_MAX_ELEM_SEGMENTS_BITS
N_MAX_RECURSION_DEPTH
N_MAX_STACK_SIZE
N_MAX_TABLES
That maximum possible number of tables allowed, the limited is driven from Wasm standards
N_MAX_TABLE_SIZE
The maximum limit of elements in total can be fit into one table. It means in total you can have 100*1024=102_400 elements.
RWASM_MAGIC_BYTE_0
Rwasm magic bytes 0xef52 (0x52 stands for ‘R’ in ASCII)
RWASM_MAGIC_BYTE_1
RWASM_VERSION_V1
Rwasm binary version
SNIPPET_FUNC_IDX_UNRESOLVED
Placeholder for the function index of a snippet. The actual index is resolved in later compilation stages once the snippet’s final location is known.
STORE_FUEL_COST
Cost for store instructions.
TABLE_ELEMS_PER_FUEL
Number of table elements that correspond to one unit of fuel (must be a power of two).
TABLE_ELEMS_PER_FUEL_LOG2
log2(TABLE_ELEMS_PER_FUEL).

Traits§

ArithmeticOps
Arithmetic operations.
CallerTr
ExtendInto
Convert one type to another by extending with leading zeroes.
Float
Float-point value.
HostError
Trait that allows the host to return a custom error.
I64ValueSplit
Integer
Integer value.
LittleEndianConvert
Types that can be converted from and to little endian bytes.
LoadInto
Allows to efficiently load bytes from memory into a buffer.
SignExtendFrom
Sign-extends Self integer type from T integer type.
StoreFrom
Allows to efficiently write bytes from a buffer into memory.
StoreTr
TransmuteInto
Reinterprets the bits of a value of one type as another type.
TruncateSaturateInto
Convert one type to another by rounding to the nearest integer towards zero.
TryTruncateInto
Convert one type to another by rounding to the nearest integer towards zero.
WithType
Untyped instances that allow to be typed.
WrapInto
Convert one type to another by wrapping.

Functions§

always_failing_syscall_handler
compile_wasm_to_rwasm
for_each_strategy
is_rwasm_operator_disabled
rWasm disable several opcodes, most of them are FPU related
rwasm_fuel_for_operator
Returns the fuel cost for a single WebAssembly operator.

Type Aliases§

AddressOffset
BlockFuel
BranchTableTargets
CompiledFunc
ConstantFuelParams
Constant fuel parameter type.
DataSegmentIdx
ElementSegmentIdx
ExternRef
FuncIdx
FuncTypeIdx
GlobalIdx
InstrLoc
LabelRef
LocalDepth
MaxStackHeight
MemoryIdx
NumLocals
SignatureIdx
SysFuncIdx
SyscallHandler
TableIdx
Max table size can’t exceed 100 elements, so it easily fits into u16