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.

  • Host Registrations

    • Wasi turns on the WASI support.

    • WasmEdgeProcess turns on the wasmedge_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

source

pub fn create() -> WasmEdgeResult<Self>

Creates a new Config.

Error

If fail to create, then an error is returned.

source

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.
source

pub fn wasi_enabled(&self) -> bool

Checks if host registration wasi turns on or not.

source

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).
source

pub fn get_max_memory_pages(&self) -> u32

Returns the number of the memory pages available.

source

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.
source

pub fn mutable_globals_enabled(&self) -> bool

Checks if the ImportExportMutGlobals option turns on or not.

source

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.
source

pub fn non_trap_conversions_enabled(&self) -> bool

Checks if the NonTrapFloatToIntConversions option turns on or not.

source

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.
source

pub fn sign_extension_operators_enabled(&self) -> bool

Checks if the SignExtensionOperators option turns on or not.

source

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.
source

pub fn multi_value_enabled(&self) -> bool

Checks if the MultiValue option turns on or not.

source

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.
source

pub fn bulk_memory_operations_enabled(&self) -> bool

Checks if the BulkMemoryOperations option turns on or not.

source

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.
source

pub fn reference_types_enabled(&self) -> bool

Checks if the ReferenceTypes option turns on or not.

source

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.
source

pub fn simd_enabled(&self) -> bool

Checks if the SIMD option turns on or not.

source

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.
source

pub fn tail_call_enabled(&self) -> bool

Checks if the TailCall option turns on or not.

source

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.
source

pub fn annotations_enabled(&self) -> bool

Checks if the Annotations option turns on or not.

source

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.
source

pub fn memory64_enabled(&self) -> bool

Checks if the Memory64 option turns on or not.

source

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.
source

pub fn threads_enabled(&self) -> bool

Checks if the Threads option turns on or not.

source

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.
source

pub fn exception_handling_enabled(&self) -> bool

Checks if the ExceptionHandling option turns on or not.

source

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.
source

pub fn function_references_enabled(&self) -> bool

Checks if the FunctionReferences option turns on or not.

source

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.
source

pub fn multi_memories_enabled(&self) -> bool

Checks if the MultiMemories option turns on or not.

source

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.
source

pub fn interpreter_mode_enabled(&self) -> bool

Checks if the ForceInterpreter option turns on or not.

source

pub fn set_aot_optimization_level( &mut self, opt_level: CompilerOptimizationLevel )

Available on crate feature 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.
source

pub fn get_aot_optimization_level(&self) -> CompilerOptimizationLevel

Available on crate feature aot only.

Returns the optimization level of AOT compiler.

Notice that this function is only available when the aot feature is enabled.

source

pub fn set_aot_compiler_output_format(&mut self, format: CompilerOutputFormat)

Available on crate feature 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.
source

pub fn get_aot_compiler_output_format(&self) -> CompilerOutputFormat

Available on crate feature aot only.

Returns the output binary format of AOT compiler.

Notice that this function is only available when the aot feature is enabled.

source

pub fn dump_ir(&mut self, flag: bool)

Available on crate feature 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.
source

pub fn dump_ir_enabled(&self) -> bool

Available on crate feature 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.

source

pub fn generic_binary(&mut self, flag: bool)

Available on crate feature 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.
source

pub fn generic_binary_enabled(&self) -> bool

Available on crate feature 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.

source

pub fn interruptible(&mut self, enable: bool)

Available on crate feature 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 the Interruptible option.
source

pub fn interruptible_enabled(&self) -> bool

Available on crate feature 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.

source

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.
source

pub fn is_instruction_counting(&self) -> bool

Checks if the instruction counting option turns on or not.

source

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.
source

pub fn is_cost_measuring(&self) -> bool

Checks if the cost measuring option turns on or not.

source

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.
source

pub fn is_time_measuring(&self) -> bool

Checks if the time measuring option turns on or not.

source

pub fn as_ptr(&self) -> *const WasmEdge_ConfigureContext

Available on crate feature ffi only.

Provides a raw pointer to the inner Configure context.

Trait Implementations§

source§

impl Clone for Config

source§

fn clone(&self) -> Config

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Config

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Drop for Config

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V