[][src]Trait wasm_smith::Config

pub trait Config: Arbitrary + Default {
    fn max_imports(&self) -> usize { ... }
fn max_funcs(&self) -> usize { ... }
fn max_globals(&self) -> usize { ... }
fn max_exports(&self) -> usize { ... }
fn max_element_segments(&self) -> usize { ... }
fn max_elements(&self) -> usize { ... }
fn max_data_segments(&self) -> usize { ... }
fn max_instructions(&self) -> usize { ... }
fn max_memories(&self) -> u32 { ... }
fn memory_offset_choices(&self) -> (u32, u32, u32) { ... } }

Configuration for a generated module.

Don't care to configure your generated modules? Just use Module, which internally uses DefaultConfig.

If you want to configure generated modules, then define a MyConfig type, implement this trait for it, and use ConfiguredModule<MyConfig> instead of Module.

Every trait method has a provided default implementation, so that you only need to override the methods for things you want to change away from the default.

Provided methods

fn max_imports(&self) -> usize

The maximum number of imports to generate. Defaults to 100.

fn max_funcs(&self) -> usize

The maximum number of functions to generate. Defaults to 100.

fn max_globals(&self) -> usize

The maximum number of globals to generate. Defaults to 100.

fn max_exports(&self) -> usize

The maximum number of exports to generate. Defaults to 100.

fn max_element_segments(&self) -> usize

The maximum number of element segments to generate. Defaults to 100.

fn max_elements(&self) -> usize

The maximum number of elements within a segment to generate. Defaults to 100.

fn max_data_segments(&self) -> usize

The maximum number of data segments to generate. Defaults to 100.

fn max_instructions(&self) -> usize

The maximum number of instructions to generate in a function body. Defaults to 100.

Note that some additional ends, elses, and unreachables may be appended to the function body to finish block scopes.

fn max_memories(&self) -> u32

The maximum number of memories to use. Defaults to 1.

Note that more than one memory is in the realm of the multi-memory wasm proposal.

fn memory_offset_choices(&self) -> (u32, u32, u32)

Control the probability of generating memory offsets that are in bounds vs. potentially out of bounds.

Return a tuple (a, b, c) where

  • a / (a+b+c) is the probability of generating a memory offset within 0..memory.min_size, i.e. an offset that is definitely in bounds of a non-empty memory. (Note that if a memory is zero-sized, however, no offset will ever be in bounds.)

  • b / (a+b+c) is the probability of generating a memory offset within memory.min_size..memory.max_size, i.e. an offset that is possibly in bounds if the memory has been grown.

  • c / (a+b+c) is the probability of generating a memory offset within the range memory.max_size.., i.e. an offset that is definitely out of bounds.

At least one of a, b, and c must be non-zero.

If you want to always generate memory offsets that are definitely in bounds of a non-zero-sized memory, for example, you could return (1, 0, 0).

By default, returns (75, 24, 1).

Loading content...

Implementors

Loading content...