Struct wasmedge_sys::Config
source · pub struct Config { /* private fields */ }
Expand description
Defines Config struct used to check/set the configuration options.
Config manages the configuration options, which are used to initiate Loader, Validator, Executor, and Compiler.
The configuration options are categorized into the following four groups:
-
WebAssembly Proposals
This group of options are used to turn on/off the WebAssembly proposals. They are effective to any WasmEdge context created with Config.
-
MultiMemories
enables to use multiple memories within a single Wasm module.Also see Multiple Memories for Wasm
-
ImportExportMutGlobals
supports mutable imported and exported globals.Also see Import/Export Mutable Globals Proposal.
-
NonTrapFloatToIntConversions
supports the non-trapping float-to-int conversion. -
SignExtensionOperators
supports new integer instructions for sign-extending 8-bit, 16-bit, and 32-bit values.Also see Sign-extension Operators Proposal.
-
MultiValue
supports functions and instructions with multiple return values, and blocks with inputs.Also see Multi-value Extension.
-
BulkMemoryOperations
supports bulk memory operations.Also see Bulk Memory Operations Proposal.
-
ReferenceTypes
supports reference types.Also see Reference Types Proposal.
-
SIMD
supports 128-bit packed SIMD extension to WebAssembly.Also see SIMD Proposal.
-
TailCall
supports tail call optimization.Also see Tail Call Proposal.
-
Annotations
supports annotations in WASM text format.Also see Annotations Proposal.
-
Memory64
supports 64-bit memory indexes.Also see Memory64 Proposal.
-
Threads
supports threading feature.Also see Threading Proposal.
-
ExceptionHandling
supports exception handling.Also see Exception Handling Proposal.
-
FunctionReferences
supports typed function references for WebAssembly.Also see Function References Proposal.
-
-
Host Registrations
-
Wasi
turns on theWASI
support. -
WasmEdgeProcess
turns on thewasmedge_process
support.
-
-
Memory Management
maximum_memory_page
limits the page size of Memory.
-
AOT Compilation
The AOT compiler options configure the behavior about optimization level, output format, dump IR, and generic binary.
-
Compiler Optimization Levels
-
O0
performs as many optimizations as possible. -
O1
optimizes quickly without destroying debuggability. -
02
optimizes for fast execution as much as possible without triggering significant incremental compile time or code size growth. -
O3
optimizes for fast execution as much as possible. -
Os
optimizes for small code size as much as possible without triggering significant incremental compile time or execution time slowdowns. -
Oz
optimizes for small code size as much as possible.
-
-
Compiler Output Formats
-
Native
specifies the output format is native dynamic library (*.wasm.so
). -
Wasm
specifies the output format is WebAssembly with AOT compiled codes in custom section (*.wasm
).
-
-
dump_ir
determines if AOT compiler generates IR or not. -
generic_binary
determines if AOT compiler generates the generic binary or not. -
interruptible
determines if AOT compiler generates interruptible binary or not.
The configuration options above are only effective to Compiler.
-
-
Runtime Statistics
-
instr_counting
determines if measuring the count of instructions when running a compiled or pure WASM. -
cost_measuring
determines if measuring the instruction costs when running a compiled or pure WASM. -
time_measuring
determines if measuring the running time when running a compiled or pure WASM.
-
API users can first set the options of interest, such as those related to the WebAssembly proposals, host registrations, AOT compiler options, and etc., then apply the configuration to create other WasmEdge runtime structs.
Implementations§
source§impl Config
impl Config
sourcepub fn create() -> WasmEdgeResult<Self>
pub fn create() -> WasmEdgeResult<Self>
sourcepub fn wasi(&mut self, enable: bool)
pub fn wasi(&mut self, enable: bool)
Enables or disables host registration wasi. By default, the option is disabled.
Argument
enable
- Whether the option turns on or not.
sourcepub fn wasi_enabled(&self) -> bool
pub fn wasi_enabled(&self) -> bool
Checks if host registration wasi turns on or not.
sourcepub fn set_max_memory_pages(&mut self, count: u32)
pub fn set_max_memory_pages(&mut self, count: u32)
Sets the maximum number of the memory pages available.
Argument
count
- The page count (64KB per page).
sourcepub fn get_max_memory_pages(&self) -> u32
pub fn get_max_memory_pages(&self) -> u32
Returns the number of the memory pages available.
sourcepub fn mutable_globals(&mut self, enable: bool)
pub fn mutable_globals(&mut self, enable: bool)
Enables or disables the ImportExportMutGlobals option. By default, the option is enabled.
Argument
enable
- Whether the option turns on or not.
sourcepub fn mutable_globals_enabled(&self) -> bool
pub fn mutable_globals_enabled(&self) -> bool
Checks if the ImportExportMutGlobals option turns on or not.
sourcepub fn non_trap_conversions(&mut self, enable: bool)
pub fn non_trap_conversions(&mut self, enable: bool)
Enables or disables the NonTrapFloatToIntConversions option. By default, the option is enabled.
Argument
enable
- Whether the option turns on or not.
sourcepub fn non_trap_conversions_enabled(&self) -> bool
pub fn non_trap_conversions_enabled(&self) -> bool
Checks if the NonTrapFloatToIntConversions option turns on or not.
sourcepub fn sign_extension_operators(&mut self, enable: bool)
pub fn sign_extension_operators(&mut self, enable: bool)
Enables or disables the SignExtensionOperators option. By default, the option is enabled.
Argument
enable
- Whether the option turns on or not.
sourcepub fn sign_extension_operators_enabled(&self) -> bool
pub fn sign_extension_operators_enabled(&self) -> bool
Checks if the SignExtensionOperators option turns on or not.
sourcepub fn multi_value(&mut self, enable: bool)
pub fn multi_value(&mut self, enable: bool)
Enables or disables the MultiValue option. By default, the option is enabled.
Argument
enable
- Whether the option turns on or not.
sourcepub fn multi_value_enabled(&self) -> bool
pub fn multi_value_enabled(&self) -> bool
Checks if the MultiValue option turns on or not.
sourcepub fn bulk_memory_operations(&mut self, enable: bool)
pub fn bulk_memory_operations(&mut self, enable: bool)
Enables or disables the BulkMemoryOperations option. By default, the option is enabled.
Argument
enable
- Whether the option turns on or not.
sourcepub fn bulk_memory_operations_enabled(&self) -> bool
pub fn bulk_memory_operations_enabled(&self) -> bool
Checks if the BulkMemoryOperations option turns on or not.
sourcepub fn reference_types(&mut self, enable: bool)
pub fn reference_types(&mut self, enable: bool)
Enables or disables the ReferenceTypes option. By default, the option is enabled.
Argument
enable
- Whether the option turns on or not.
sourcepub fn reference_types_enabled(&self) -> bool
pub fn reference_types_enabled(&self) -> bool
Checks if the ReferenceTypes option turns on or not.
sourcepub fn simd(&mut self, enable: bool)
pub fn simd(&mut self, enable: bool)
Enables or disables the SIMD option. By default, the option is enabled.
Argument
enable
- Whether the option turns on or not.
sourcepub fn simd_enabled(&self) -> bool
pub fn simd_enabled(&self) -> bool
Checks if the SIMD option turns on or not.
sourcepub fn tail_call(&mut self, enable: bool)
pub fn tail_call(&mut self, enable: bool)
Enables or disables the TailCall option. By default, the option is disabled.
Argument
enable
- Whether the option turns on or not.
sourcepub fn tail_call_enabled(&self) -> bool
pub fn tail_call_enabled(&self) -> bool
Checks if the TailCall option turns on or not.
sourcepub fn annotations(&mut self, enable: bool)
pub fn annotations(&mut self, enable: bool)
Enables or disables the Annotations option. By default, the option is disabled.
Argument
enable
- Whether the option turns on or not.
sourcepub fn annotations_enabled(&self) -> bool
pub fn annotations_enabled(&self) -> bool
Checks if the Annotations option turns on or not.
sourcepub fn memory64(&mut self, enable: bool)
pub fn memory64(&mut self, enable: bool)
Enables or disables the Memory64 option. By default, the option is disabled.
Argument
enable
- Whether the option turns on or not.
sourcepub fn memory64_enabled(&self) -> bool
pub fn memory64_enabled(&self) -> bool
Checks if the Memory64 option turns on or not.
sourcepub fn threads(&mut self, enable: bool)
pub fn threads(&mut self, enable: bool)
Enables or disables the Threads option. By default, the option is disabled.
Argument
enable
- Whether the option turns on or not.
sourcepub fn threads_enabled(&self) -> bool
pub fn threads_enabled(&self) -> bool
Checks if the Threads option turns on or not.
sourcepub fn exception_handling(&mut self, enable: bool)
pub fn exception_handling(&mut self, enable: bool)
Enables or disables the ExceptionHandling option. By default, the option is disabled.
Argument
enable
- Whether the option turns on or not.
sourcepub fn exception_handling_enabled(&self) -> bool
pub fn exception_handling_enabled(&self) -> bool
Checks if the ExceptionHandling option turns on or not.
sourcepub fn function_references(&mut self, enable: bool)
pub fn function_references(&mut self, enable: bool)
Enables or disables the FunctionReferences option. By default, the option is disabled.
Argument
enable
- Whether the option turns on or not.
sourcepub fn function_references_enabled(&self) -> bool
pub fn function_references_enabled(&self) -> bool
Checks if the FunctionReferences option turns on or not.
sourcepub fn multi_memories(&mut self, enable: bool)
pub fn multi_memories(&mut self, enable: bool)
Enables or disables the MultiMemories option. By default, the option is disabled.
Argument
enable
- Whether the option turns on or not.
sourcepub fn multi_memories_enabled(&self) -> bool
pub fn multi_memories_enabled(&self) -> bool
Checks if the MultiMemories option turns on or not.
sourcepub fn interpreter_mode(&mut self, enable: bool)
pub fn interpreter_mode(&mut self, enable: bool)
Enables or disables the ForceInterpreter
option. By default, the option is disabled.
Argument
enable
- Whether the option turns on or not.
sourcepub fn interpreter_mode_enabled(&self) -> bool
pub fn interpreter_mode_enabled(&self) -> bool
Checks if the ForceInterpreter
option turns on or not.
sourcepub fn set_aot_optimization_level(
&mut self,
opt_level: CompilerOptimizationLevel
)
Available on crate feature aot
only.
pub fn set_aot_optimization_level( &mut self, opt_level: CompilerOptimizationLevel )
aot
only.Sets the optimization level of AOT compiler. By default, the optimization level is O3
.
Notice that this function is only available when the aot
feature is enabled.
Argument
opt_level
- The optimization level of AOT compiler.
sourcepub fn get_aot_optimization_level(&self) -> CompilerOptimizationLevel
Available on crate feature aot
only.
pub fn get_aot_optimization_level(&self) -> CompilerOptimizationLevel
aot
only.Returns the optimization level of AOT compiler.
Notice that this function is only available when the aot
feature is enabled.
sourcepub fn set_aot_compiler_output_format(&mut self, format: CompilerOutputFormat)
Available on crate feature aot
only.
pub fn set_aot_compiler_output_format(&mut self, format: CompilerOutputFormat)
aot
only.Sets the output binary format of AOT compiler. By default, the compiler output format is Wasm
.
Notice that this function is only available when the aot
feature is enabled.
Argument
format
- The format of the output binary.
sourcepub fn get_aot_compiler_output_format(&self) -> CompilerOutputFormat
Available on crate feature aot
only.
pub fn get_aot_compiler_output_format(&self) -> CompilerOutputFormat
aot
only.Returns the output binary format of AOT compiler.
Notice that this function is only available when the aot
feature is enabled.
sourcepub fn dump_ir(&mut self, flag: bool)
Available on crate feature aot
only.
pub fn dump_ir(&mut self, flag: bool)
aot
only.Sets the dump IR option of AOT compiler. By default, the option is disabled.
Notice that this function is only available when the aot
feature is enabled.
Argument
flag
- Whether dump ir or not.
sourcepub fn dump_ir_enabled(&self) -> bool
Available on crate feature aot
only.
pub fn dump_ir_enabled(&self) -> bool
aot
only.Checks if the dump IR option turns on or not.
Notice that this function is only available when the aot
feature is enabled.
sourcepub fn generic_binary(&mut self, flag: bool)
Available on crate feature aot
only.
pub fn generic_binary(&mut self, flag: bool)
aot
only.Sets the generic binary option of AOT compiler. By default, the option is disabled.
Notice that this function is only available when the aot
feature is enabled.
Argument
flag
- Whether generate the generic binary or not when perform AOT compilation.
sourcepub fn generic_binary_enabled(&self) -> bool
Available on crate feature aot
only.
pub fn generic_binary_enabled(&self) -> bool
aot
only.Checks if the generic binary option of AOT compiler turns on or not.
Notice that this function is only available when the aot
feature is enabled.
sourcepub fn interruptible(&mut self, enable: bool)
Available on crate feature aot
only.
pub fn interruptible(&mut self, enable: bool)
aot
only.Enables or Disables the Interruptible
option of AOT compiler. This option determines to generate interruptible binary or not when compilation in AOT compiler. By default, the option is disabled.
Notice that this function is only available when the aot
feature is enabled.
Argument
enable
- Whether turn on theInterruptible
option.
sourcepub fn interruptible_enabled(&self) -> bool
Available on crate feature aot
only.
pub fn interruptible_enabled(&self) -> bool
aot
only.Checks if the Interruptible
option of AOT Compiler turns on or not.
Notice that this function is only available when the aot
feature is enabled.
sourcepub fn count_instructions(&mut self, flag: bool)
pub fn count_instructions(&mut self, flag: bool)
Sets the instruction counting option. By default, the option is disabled.
Argument
flag
- Whether support instruction counting or not when execution after AOT compilation.
sourcepub fn is_instruction_counting(&self) -> bool
pub fn is_instruction_counting(&self) -> bool
Checks if the instruction counting option turns on or not.
sourcepub fn measure_cost(&mut self, flag: bool)
pub fn measure_cost(&mut self, flag: bool)
Sets the cost measuring option. By default, the option is disabled.
Argument
flag
- Whether support cost measuring or not when execution after AOT compilation.
sourcepub fn is_cost_measuring(&self) -> bool
pub fn is_cost_measuring(&self) -> bool
Checks if the cost measuring option turns on or not.
sourcepub fn measure_time(&mut self, flag: bool)
pub fn measure_time(&mut self, flag: bool)
Sets the time measuring option. By default, the option is disabled.
Argument
flag
- Whether support time measuring or not when execution after AOT compilation.
sourcepub fn is_time_measuring(&self) -> bool
pub fn is_time_measuring(&self) -> bool
Checks if the time measuring option turns on or not.
sourcepub fn as_ptr(&self) -> *const WasmEdge_ConfigureContext
Available on crate feature ffi
only.
pub fn as_ptr(&self) -> *const WasmEdge_ConfigureContext
ffi
only.Provides a raw pointer to the inner Configure context.