Struct wasm_smith::Module
source · [−]pub struct Module { /* private fields */ }
Expand description
A pseudo-random WebAssembly module.
Construct instances of this type with the Arbitrary
trait.
Configuring Generated Modules
This uses the DefaultConfig
configuration. If you
want to customize the shape of generated modules, define your own
configuration type, implement the Config
trait for it,
and use ConfiguredModule<YourConfigType>
instead of plain Module
.
Implementations
sourceimpl Module
impl Module
sourcepub fn no_traps(&mut self) -> Result<(), NotSupported<'_>>
pub fn no_traps(&mut self) -> Result<(), NotSupported<'_>>
Ensure that this generated module will never trap.
This will take a number of approaches to avoid traps, such as
-
mask loads’ and stores’ addresses to the associated memory’s size
-
mask
table.get
s’ andtable.set
’s index to the associated table’s size -
ensure that a divisor is never zero
-
replace
unreachable
s with dummy-valuereturn
s -
Masking data and element segments’ offsets to be in bounds of their associated tables or memories
sourceimpl Module
impl Module
sourcepub fn ensure_termination(&mut self, default_fuel: u32) -> u32
pub fn ensure_termination(&mut self, default_fuel: u32) -> u32
Ensure that all of this Wasm module’s functions will terminate when executed.
This adds a new mutable, exported global to the module to keep track of how much “fuel” is left. Fuel is decremented at the head of each loop and function. When fuel reaches zero, a trap is raised.
The index of the fuel global is returned, so that you may control how much fuel the module is given.
Trait Implementations
sourceimpl<'a> Arbitrary<'a> for Module
impl<'a> Arbitrary<'a> for Module
sourcefn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>
fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>
Generate an arbitrary value of Self
from the given unstructured data. Read more
sourcefn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
Generate an arbitrary value of Self
from the entirety of the given
unstructured data. Read more
Auto Trait Implementations
impl !RefUnwindSafe for Module
impl !Send for Module
impl !Sync for Module
impl Unpin for Module
impl !UnwindSafe for Module
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more