Trait wasm_smith::Config [−][src]
pub trait Config: 'static + Debug {
Show 40 methods
fn min_types(&self) -> usize { ... }
fn max_types(&self) -> usize { ... }
fn min_imports(&self) -> usize { ... }
fn max_imports(&self) -> usize { ... }
fn min_tags(&self) -> usize { ... }
fn max_tags(&self) -> usize { ... }
fn min_funcs(&self) -> usize { ... }
fn max_funcs(&self) -> usize { ... }
fn min_globals(&self) -> usize { ... }
fn max_globals(&self) -> usize { ... }
fn min_exports(&self) -> usize { ... }
fn max_exports(&self) -> usize { ... }
fn min_element_segments(&self) -> usize { ... }
fn max_element_segments(&self) -> usize { ... }
fn min_elements(&self) -> usize { ... }
fn max_elements(&self) -> usize { ... }
fn min_data_segments(&self) -> usize { ... }
fn max_data_segments(&self) -> usize { ... }
fn max_instructions(&self) -> usize { ... }
fn min_memories(&self) -> u32 { ... }
fn max_memories(&self) -> usize { ... }
fn min_tables(&self) -> u32 { ... }
fn max_tables(&self) -> usize { ... }
fn max_memory_pages(&self, is_64: bool) -> u64 { ... }
fn memory_max_size_required(&self) -> bool { ... }
fn max_instances(&self) -> usize { ... }
fn max_modules(&self) -> usize { ... }
fn memory_offset_choices(&self) -> (u32, u32, u32) { ... }
fn min_uleb_size(&self) -> u8 { ... }
fn bulk_memory_enabled(&self) -> bool { ... }
fn reference_types_enabled(&self) -> bool { ... }
fn simd_enabled(&self) -> bool { ... }
fn exceptions_enabled(&self) -> bool { ... }
fn module_linking_enabled(&self) -> bool { ... }
fn allow_start_export(&self) -> bool { ... }
fn max_aliases(&self) -> usize { ... }
fn max_nesting_depth(&self) -> usize { ... }
fn max_type_size(&self) -> u32 { ... }
fn memory64_enabled(&self) -> bool { ... }
fn canonicalize_nans(&self) -> bool { ... }
}Expand description
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 min_imports(&self) -> usize
fn min_imports(&self) -> usize
The minimum number of imports to generate. Defaults to 0.
Note that if the sum of the maximum function1, table, global and memory counts is less than the minimum number of imports, then it will not be possible to satisfy all constraints (because imports count against the limits for those element kinds). In that case, we strictly follow the max-constraints, and can fail to satisfy this minimum number.
the maximum number of functions is also limited by the number of function types arbitrarily chosen; strictly speaking, then, the maximum number of imports that can be created due to max-constraints is
sum(min(num_func_types, max_funcs), max_tables, max_globals, max_memories). ↩
fn max_imports(&self) -> usize
fn max_imports(&self) -> usize
The maximum number of imports to generate. Defaults to 100.
The minimum number of tags to generate. Defaults to 0.
The maximum number of tags to generate. Defaults to 100.
The minimum number of functions to generate. Defaults to 0. This includes imported functions.
The maximum number of functions to generate. Defaults to 100. This includes imported functions.
fn min_globals(&self) -> usize
fn min_globals(&self) -> usize
The minimum number of globals to generate. Defaults to 0. This includes imported globals.
fn max_globals(&self) -> usize
fn max_globals(&self) -> usize
The maximum number of globals to generate. Defaults to 100. This includes imported globals.
fn min_exports(&self) -> usize
fn min_exports(&self) -> usize
The minimum number of exports to generate. Defaults to 0.
fn max_exports(&self) -> usize
fn max_exports(&self) -> usize
The maximum number of exports to generate. Defaults to 100.
fn min_element_segments(&self) -> usize
fn min_element_segments(&self) -> usize
The minimum number of element segments to generate. Defaults to 0.
fn max_element_segments(&self) -> usize
fn max_element_segments(&self) -> usize
The maximum number of element segments to generate. Defaults to 100.
fn min_elements(&self) -> usize
fn min_elements(&self) -> usize
The minimum number of elements within a segment to generate. Defaults to 0.
fn max_elements(&self) -> usize
fn max_elements(&self) -> usize
The maximum number of elements within a segment to generate. Defaults to 100.
fn min_data_segments(&self) -> usize
fn min_data_segments(&self) -> usize
The minimum number of data segments to generate. Defaults to 0.
fn max_data_segments(&self) -> usize
fn max_data_segments(&self) -> usize
The maximum number of data segments to generate. Defaults to 100.
fn max_instructions(&self) -> usize
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 min_memories(&self) -> u32
fn min_memories(&self) -> u32
The minimum number of memories to use. Defaults to 0. This includes imported memories.
fn max_memories(&self) -> usize
fn max_memories(&self) -> usize
The maximum number of memories to use. Defaults to 1. This includes imported memories.
Note that more than one memory is in the realm of the multi-memory wasm proposal.
fn min_tables(&self) -> u32
fn min_tables(&self) -> u32
The minimum number of tables to use. Defaults to 0. This includes imported tables.
fn max_tables(&self) -> usize
fn max_tables(&self) -> usize
The maximum number of tables to use. Defaults to 1. This includes imported tables.
Note that more than one table is in the realm of the reference types proposal.
fn max_memory_pages(&self, is_64: bool) -> u64
fn max_memory_pages(&self, is_64: bool) -> u64
The maximum, in 64k Wasm pages, of any memory’s initial or maximum size.
Defaults to 2^16 = 65536 for 32-bit Wasm and 2^48 for 64-bit wasm.
fn memory_max_size_required(&self) -> bool
fn memory_max_size_required(&self) -> bool
Whether every Wasm memory must have a maximum size specified. Defaults
to false.
fn max_instances(&self) -> usize
fn max_instances(&self) -> usize
The maximum number of instances to use. Defaults to 10. This includes imported instances.
Note that this is irrelevant unless module linking is enabled.
fn max_modules(&self) -> usize
fn max_modules(&self) -> usize
The maximum number of modules to use. Defaults to 10. This includes imported modules.
Note that this is irrelevant unless module linking is enabled.
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 within0..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 withinmemory.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 rangememory.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).
fn min_uleb_size(&self) -> u8
fn min_uleb_size(&self) -> u8
The minimum size, in bytes, of all leb-encoded integers. Defaults to 1.
This is useful for ensuring that all leb-encoded integers are decoded as such rather than as simply one byte. This will forcibly extend leb integers with an over-long encoding in some locations if the size would otherwise be smaller than number returned here.
fn bulk_memory_enabled(&self) -> bool
fn bulk_memory_enabled(&self) -> bool
Determines whether the bulk memory proposal is enabled for generating
insructions. Defaults to false.
fn reference_types_enabled(&self) -> bool
fn reference_types_enabled(&self) -> bool
Determines whether the reference types proposal is enabled for
generating insructions. Defaults to false.
fn simd_enabled(&self) -> bool
fn simd_enabled(&self) -> bool
Determines whether the SIMD proposal is enabled for
generating insructions. Defaults to false.
fn exceptions_enabled(&self) -> bool
fn exceptions_enabled(&self) -> bool
Determines whether the exception-handling proposal is enabled for
generating insructions. Defaults to false.
fn module_linking_enabled(&self) -> bool
fn module_linking_enabled(&self) -> bool
Determines whether the module linking proposal is enabled.
Defaults to false.
fn allow_start_export(&self) -> bool
fn allow_start_export(&self) -> bool
Determines whether a start export may be included. Defaults to true.
fn max_aliases(&self) -> usize
fn max_aliases(&self) -> usize
Returns the maximal size of the alias section.
fn max_nesting_depth(&self) -> usize
fn max_nesting_depth(&self) -> usize
Returns the maximal nesting depth of modules with the module linking proposal.
fn max_type_size(&self) -> u32
fn max_type_size(&self) -> u32
Returns the maximal effective size of any type generated by wasm-smith.
Note that this number is roughly in units of “how many types would be needed to represent the recursive type”. A function with 8 parameters and 2 results would take 11 types (one for the type, 10 for params/results). A module type with 2 imports and 3 exports would take 6 (module + imports + exports) plus the size of each import/export type. This is a somewhat rough measurement that is not intended to be very precise.
fn memory64_enabled(&self) -> bool
fn memory64_enabled(&self) -> bool
Returns whether 64-bit memories are allowed.
Note that this is the gate for the memory64 proposal to WebAssembly.
fn canonicalize_nans(&self) -> bool
fn canonicalize_nans(&self) -> bool
Returns whether NaN values are canonicalized after all f32/f64 operation.
This can be useful when a generated wasm module is executed in multiple runtimes which may produce different NaN values. This ensures that the generated module will always use the same NaN representation for all instructions which have visible side effects, for example writing floats to memory or float-to-int bitcast instructions.