Struct wasmtime_cli_flags::CommonOptions
source · pub struct CommonOptions {Show 25 fields
pub config: Option<PathBuf>,
pub disable_logging: bool,
pub log_to_files: bool,
pub debug_info: bool,
pub disable_cache: bool,
pub disable_parallel_compilation: bool,
pub wasm_features: Option<WasmFeatures>,
pub wasi_modules: Option<WasiModules>,
pub jitdump: bool,
pub vtune: bool,
pub optimize: bool,
pub opt_level: Option<OptLevel>,
pub cranelift_set: Vec<(String, String)>,
pub cranelift_enable: Vec<String>,
pub static_memory_maximum_size: Option<u64>,
pub static_memory_forced: bool,
pub static_memory_guard_size: Option<u64>,
pub dynamic_memory_guard_size: Option<u64>,
pub enable_cranelift_debug_verifier: bool,
pub enable_cranelift_nan_canonicalization: bool,
pub fuel: Option<u64>,
pub epoch_interruption: bool,
pub disable_address_map: bool,
pub disable_memory_init_cow: bool,
pub max_wasm_stack: Option<usize>,
}
Expand description
Common options for commands that translate WebAssembly modules
Fields§
§config: Option<PathBuf>
Use specified configuration file
disable_logging: bool
Disable logging
log_to_files: bool
Log to per-thread log files instead of stderr
debug_info: bool
Generate debug information
disable_cache: bool
Disable cache system
disable_parallel_compilation: bool
Disable parallel compilation
wasm_features: Option<WasmFeatures>
Enable or disable WebAssembly features
wasi_modules: Option<WasiModules>
Enable or disable WASI modules
jitdump: bool
Generate jitdump file (supported on –features=profiling build)
vtune: bool
Generate vtune (supported on –features=vtune build)
optimize: bool
Run optimization passes on translated functions, on by default
opt_level: Option<OptLevel>
Optimization level for generated functions Supported levels: 0 (none), 1, 2 (most), or s (size); default is “most”
cranelift_set: Vec<(String, String)>
Set a Cranelift setting to a given value.
Use wasmtime settings
to list Cranelift settings for a target.
cranelift_enable: Vec<String>
Enable a Cranelift boolean setting or preset.
Use wasmtime settings
to list Cranelift settings for a target.
static_memory_maximum_size: Option<u64>
Maximum size in bytes of wasm memory before it becomes dynamically relocatable instead of up-front-reserved.
static_memory_forced: bool
Force using a “static” style for all wasm memories
static_memory_guard_size: Option<u64>
Byte size of the guard region after static memories are allocated
dynamic_memory_guard_size: Option<u64>
Byte size of the guard region after dynamic memories are allocated
enable_cranelift_debug_verifier: bool
Enable Cranelift’s internal debug verifier (expensive)
enable_cranelift_nan_canonicalization: bool
Enable Cranelift’s internal NaN canonicalization
fuel: Option<u64>
Enable execution fuel with N units fuel, where execution will trap after running out of fuel.
Most WebAssembly instructions consume 1 unit of fuel. Some instructions,
such as nop
, drop
, block
, and loop
, consume 0 units, as any
execution cost associated with them involves other instructions which do
consume fuel.
epoch_interruption: bool
Executing wasm code will yield when a global epoch counter changes, allowing for async operation without blocking the executor.
disable_address_map: bool
Disable the on-by-default address map from native code to wasm code
disable_memory_init_cow: bool
Disable the default of attempting to initialize linear memory via a copy-on-write mapping
max_wasm_stack: Option<usize>
Maximum stack size, in bytes, that wasm is allowed to consume before a stack overflow is reported.
Implementations§
source§impl CommonOptions
impl CommonOptions
pub fn parse_from_str(s: &str) -> Result<Self>
pub fn init_logging(&self)
pub fn config(&self, target: Option<&str>) -> Result<Config>
sourcepub fn enable_wasm_features(&self, config: &mut Config)
pub fn enable_wasm_features(&self, config: &mut Config)
Examples found in repository?
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340
pub fn config(&self, target: Option<&str>) -> Result<Config> {
let mut config = Config::new();
// Set the target before setting any cranelift options, since the
// target will reset any target-specific options.
if let Some(target) = target {
config.target(target)?;
}
config
.cranelift_debug_verifier(self.enable_cranelift_debug_verifier)
.debug_info(self.debug_info)
.cranelift_opt_level(self.opt_level())
.profiler(pick_profiling_strategy(self.jitdump, self.vtune)?)
.cranelift_nan_canonicalization(self.enable_cranelift_nan_canonicalization);
self.enable_wasm_features(&mut config);
for name in &self.cranelift_enable {
unsafe {
config.cranelift_flag_enable(name);
}
}
for (name, value) in &self.cranelift_set {
unsafe {
config.cranelift_flag_set(name, value);
}
}
if !self.disable_cache {
match &self.config {
Some(path) => {
config.cache_config_load(path)?;
}
None => {
config.cache_config_load_default()?;
}
}
}
if self.disable_parallel_compilation {
config.parallel_compilation(false);
}
if let Some(max) = self.static_memory_maximum_size {
config.static_memory_maximum_size(max);
}
config.static_memory_forced(self.static_memory_forced);
if let Some(size) = self.static_memory_guard_size {
config.static_memory_guard_size(size);
}
if let Some(size) = self.dynamic_memory_guard_size {
config.dynamic_memory_guard_size(size);
}
// If fuel has been configured, set the `consume fuel` flag on the config.
if self.fuel.is_some() {
config.consume_fuel(true);
}
config.epoch_interruption(self.epoch_interruption);
config.generate_address_map(!self.disable_address_map);
config.memory_init_cow(!self.disable_memory_init_cow);
#[cfg(feature = "pooling-allocator")]
{
if self.pooling_allocator {
config.allocation_strategy(wasmtime::InstanceAllocationStrategy::pooling());
}
}
if let Some(max) = self.max_wasm_stack {
config.max_wasm_stack(max);
}
Ok(config)
}
sourcepub fn opt_level(&self) -> OptLevel
pub fn opt_level(&self) -> OptLevel
Examples found in repository?
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340
pub fn config(&self, target: Option<&str>) -> Result<Config> {
let mut config = Config::new();
// Set the target before setting any cranelift options, since the
// target will reset any target-specific options.
if let Some(target) = target {
config.target(target)?;
}
config
.cranelift_debug_verifier(self.enable_cranelift_debug_verifier)
.debug_info(self.debug_info)
.cranelift_opt_level(self.opt_level())
.profiler(pick_profiling_strategy(self.jitdump, self.vtune)?)
.cranelift_nan_canonicalization(self.enable_cranelift_nan_canonicalization);
self.enable_wasm_features(&mut config);
for name in &self.cranelift_enable {
unsafe {
config.cranelift_flag_enable(name);
}
}
for (name, value) in &self.cranelift_set {
unsafe {
config.cranelift_flag_set(name, value);
}
}
if !self.disable_cache {
match &self.config {
Some(path) => {
config.cache_config_load(path)?;
}
None => {
config.cache_config_load_default()?;
}
}
}
if self.disable_parallel_compilation {
config.parallel_compilation(false);
}
if let Some(max) = self.static_memory_maximum_size {
config.static_memory_maximum_size(max);
}
config.static_memory_forced(self.static_memory_forced);
if let Some(size) = self.static_memory_guard_size {
config.static_memory_guard_size(size);
}
if let Some(size) = self.dynamic_memory_guard_size {
config.dynamic_memory_guard_size(size);
}
// If fuel has been configured, set the `consume fuel` flag on the config.
if self.fuel.is_some() {
config.consume_fuel(true);
}
config.epoch_interruption(self.epoch_interruption);
config.generate_address_map(!self.disable_address_map);
config.memory_init_cow(!self.disable_memory_init_cow);
#[cfg(feature = "pooling-allocator")]
{
if self.pooling_allocator {
config.allocation_strategy(wasmtime::InstanceAllocationStrategy::pooling());
}
}
if let Some(max) = self.max_wasm_stack {
config.max_wasm_stack(max);
}
Ok(config)
}
Trait Implementations§
source§impl Args for CommonOptions
impl Args for CommonOptions
source§impl CommandFactory for CommonOptions
impl CommandFactory for CommonOptions
source§fn into_app_for_update<'b>() -> Command<'b>
fn into_app_for_update<'b>() -> Command<'b>
CommandFactory::command_for_update
source§impl FromArgMatches for CommonOptions
impl FromArgMatches for CommonOptions
source§fn from_arg_matches(__clap_arg_matches: &ArgMatches) -> Result<Self, Error>
fn from_arg_matches(__clap_arg_matches: &ArgMatches) -> Result<Self, Error>
source§fn from_arg_matches_mut(
__clap_arg_matches: &mut ArgMatches
) -> Result<Self, Error>
fn from_arg_matches_mut(
__clap_arg_matches: &mut ArgMatches
) -> Result<Self, Error>
source§fn update_from_arg_matches(
&mut self,
__clap_arg_matches: &ArgMatches
) -> Result<(), Error>
fn update_from_arg_matches(
&mut self,
__clap_arg_matches: &ArgMatches
) -> Result<(), Error>
ArgMatches
to self
.source§fn update_from_arg_matches_mut(
&mut self,
__clap_arg_matches: &mut ArgMatches
) -> Result<(), Error>
fn update_from_arg_matches_mut(
&mut self,
__clap_arg_matches: &mut ArgMatches
) -> Result<(), Error>
ArgMatches
to self
.