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.
-
MultiMemoriesenables to use multiple memories within a single Wasm module.Also see Multiple Memories for Wasm
-
ImportExportMutGlobalssupports mutable imported and exported globals.Also see Import/Export Mutable Globals Proposal.
-
NonTrapFloatToIntConversionssupports the non-trapping float-to-int conversion. -
SignExtensionOperatorssupports new integer instructions for sign-extending 8-bit, 16-bit, and 32-bit values.Also see Sign-extension Operators Proposal.
-
MultiValuesupports functions and instructions with multiple return values, and blocks with inputs.Also see Multi-value Extension.
-
BulkMemoryOperationssupports bulk memory operations.Also see Bulk Memory Operations Proposal.
-
ReferenceTypessupports reference types.Also see Reference Types Proposal.
-
SIMDsupports 128-bit packed SIMD extension to WebAssembly.Also see SIMD Proposal.
-
TailCallsupports tail call optimization.Also see Tail Call Proposal.
-
Annotationssupports annotations in WASM text format.Also see Annotations Proposal.
-
Memory64supports 64-bit memory indexes.Also see Memory64 Proposal.
-
Threadssupports threading feature.Also see Threading Proposal.
-
ExceptionHandlingsupports exception handling.Also see Exception Handling Proposal.
-
FunctionReferencessupports typed function references for WebAssembly.Also see Function References Proposal.
-
-
Host Registrations
-
Wasiturns on theWASIsupport. -
WasmEdgeProcessturns on thewasmedge_processsupport.
-
-
Memory Management
maximum_memory_pagelimits 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
-
O0performs as many optimizations as possible. -
O1optimizes quickly without destroying debuggability. -
02optimizes for fast execution as much as possible without triggering significant incremental compile time or code size growth. -
O3optimizes for fast execution as much as possible. -
Osoptimizes for small code size as much as possible without triggering significant incremental compile time or execution time slowdowns. -
Ozoptimizes for small code size as much as possible.
-
-
Compiler Output Formats
-
Nativespecifies the output format is native dynamic library (*.wasm.so). -
Wasmspecifies the output format is WebAssembly with AOT compiled codes in custom section (*.wasm).
-
-
dump_irdetermines if AOT compiler generates IR or not. -
generic_binarydetermines if AOT compiler generates the generic binary or not. -
interruptibledetermines if AOT compiler generates interruptible binary or not.
The configuration options above are only effective to Compiler.
-
-
Runtime Statistics
-
instr_countingdetermines if measuring the count of instructions when running a compiled or pure WASM. -
cost_measuringdetermines if measuring the instruction costs when running a compiled or pure WASM. -
time_measuringdetermines 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 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 gc(&mut self, enable: bool)
pub fn gc(&mut self, enable: bool)
Enables or disables the GC option. By default, the option is disabled.
§Argument
enable- Whether the option turns on or not.
Sourcepub fn gc_enabled(&self) -> bool
pub fn gc_enabled(&self) -> bool
Checks if the GC 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 theInterruptibleoption.
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.