Struct wasm_opt::OptimizationOptions
source · [−]pub struct OptimizationOptions {
pub reader: ReaderOptions,
pub writer: WriterOptions,
pub inlining: InliningOptions,
pub passopts: PassOptions,
pub passes: Passes,
}Expand description
Optimization options and optimization builder.
This type declares all supported Binaryen options. It can be modified directly or by its builder-pattern methods.
Call OptimizationOptions::run to execute optimize a wasm module.
Fields
reader: ReaderOptionsOptions for reading the unoptimized wasm module.
writer: WriterOptionsOptions for writing the optimized wasm module.
inlining: InliningOptionsOptions related to inlining.
passopts: PassOptionsOptions that affect how optimization passes behave.
passes: PassesThe set of optimization passes to apply.
Implementations
sourceimpl OptimizationOptions
impl OptimizationOptions
Constructors.
sourcepub fn new_optimize_for_size() -> Self
pub fn new_optimize_for_size() -> Self
Optimize for size.
This corresponds to the -Os argument to wasm-opt,
and also the -O argument to wasm-opt.
It is the same as OptimizationOptions::default.
It applies
sourcepub fn new_optimize_for_size_aggressively() -> Self
pub fn new_optimize_for_size_aggressively() -> Self
Optimize for size, but even more.
It applies
This corresponds to the -Oz argument to wasm-opt.
sourcepub fn new_opt_level_0() -> Self
pub fn new_opt_level_0() -> Self
Do not optimize.
It applies
It adds no default passes.
This corresponds to the -O0 argument to wasm-opt.
sourcepub fn new_opt_level_1() -> Self
pub fn new_opt_level_1() -> Self
Apply basic optimizations.
Useful for fast iteration.
It applies
This corresponds to the -O1 argument to wasm-opt.
sourcepub fn new_opt_level_2() -> Self
pub fn new_opt_level_2() -> Self
Apply most optimizations.
This level of optimization is appropriate for most applications. Higher optimization levels will not necessarily yield better performance, but will take longer to optimize.
It applies
This corresponds to the -O2 argument to wasm-opt.
sourcepub fn new_opt_level_3() -> Self
pub fn new_opt_level_3() -> Self
Apply slower optimizations.
Spends potentially a lot of time on optimizations.
It applies
This corresponds to the -O3 argument to wasm-opt.
sourcepub fn new_opt_level_4() -> Self
pub fn new_opt_level_4() -> Self
Apply the most aggressive optimizations.
Flattens the IR, which can take a lot of time and memory, but may be useful on nested / complex / less-optimized input.
It applies
This corresponds to the -O4 argument to wasm-opt.
sourceimpl OptimizationOptions
impl OptimizationOptions
Builder methods.
pub fn reader_file_type(&mut self, value: FileType) -> &mut Self
pub fn writer_file_type(&mut self, value: FileType) -> &mut Self
pub fn always_inline_max_size(&mut self, value: u32) -> &mut Self
pub fn one_caller_inline_max_size(&mut self, value: u32) -> &mut Self
pub fn flexible_inline_max_size(&mut self, value: u32) -> &mut Self
pub fn allow_functions_with_loops(&mut self, value: bool) -> &mut Self
pub fn partial_inlining_ifs(&mut self, value: u32) -> &mut Self
pub fn validate(&mut self, value: bool) -> &mut Self
pub fn validate_globally(&mut self, value: bool) -> &mut Self
pub fn optimize_level(&mut self, value: OptimizeLevel) -> &mut Self
pub fn shrink_level(&mut self, value: ShrinkLevel) -> &mut Self
pub fn traps_never_happen(&mut self, value: bool) -> &mut Self
pub fn low_memory_unused(&mut self, value: bool) -> &mut Self
pub fn fast_math(&mut self, value: bool) -> &mut Self
pub fn zero_filled_memory(&mut self, value: bool) -> &mut Self
pub fn debug_info(&mut self, value: bool) -> &mut Self
pub fn add_default_passes(&mut self, value: bool) -> &mut Self
pub fn add_pass(&mut self, value: Pass) -> &mut Self
sourceimpl OptimizationOptions
impl OptimizationOptions
Execution.
sourcepub fn run(
&self,
infile: impl AsRef<Path>,
infile_sourcemap: Option<impl AsRef<Path>>,
outfile: impl AsRef<Path>,
outfile_sourcemap: Option<impl AsRef<Path>>
) -> Result<()>
pub fn run(
&self,
infile: impl AsRef<Path>,
infile_sourcemap: Option<impl AsRef<Path>>,
outfile: impl AsRef<Path>,
outfile_sourcemap: Option<impl AsRef<Path>>
) -> Result<()>
Run the Binaryen wasm optimizer.
This loads a module from a file, runs optimization passes, and writes the module back to a file.
The sourcemap arguments are optional, and only have effect when reading or writing binary wasm files. When using wat files the respective sourcemap argument is ignored.
Errors
Returns error on I/O failure, or if the input fails to parse.
If PassOptions::validate is true, it returns an error
if the input module fails to validate, or if the module
fails to validate after any pass.
Trait Implementations
sourceimpl Clone for OptimizationOptions
impl Clone for OptimizationOptions
sourcefn clone(&self) -> OptimizationOptions
fn clone(&self) -> OptimizationOptions
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source. Read more
sourceimpl Debug for OptimizationOptions
impl Debug for OptimizationOptions
sourceimpl Default for OptimizationOptions
impl Default for OptimizationOptions
sourcefn default() -> OptimizationOptions
fn default() -> OptimizationOptions
Returns the “default value” for a type. Read more
Auto Trait Implementations
impl RefUnwindSafe for OptimizationOptions
impl Send for OptimizationOptions
impl Sync for OptimizationOptions
impl Unpin for OptimizationOptions
impl UnwindSafe for OptimizationOptions
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