MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / check_compatible_with_shared_flag

Method check_compatible_with_shared_flag

crates/wasmtime/src/engine.rs:437–525  ·  view source on GitHub ↗

Checks to see whether the "shared flag", something enabled for individual compilers, is compatible with the native host platform. This is used both when validating an engine's compilation settings are compatible with the host as well as when deserializing modules from disk to ensure they're compatible with the current host. Note that most of the settings here are not configured by users that oft

(
        &self,
        flag: &str,
        value: &FlagValue,
    )

Source from the content-addressed store, hash-verified

435 /// `libcall_call_conv`.
436 /// * Some settings do not matter as to their value, such as `opt_level`.
437 pub(crate) fn check_compatible_with_shared_flag(
438 &self,
439 flag: &str,
440 value: &FlagValue,
441 ) -> Result<(), String> {
442 let target = self.target();
443 let ok = match flag {
444 // These settings must all have be enabled, since their value
445 // can affect the way the generated code performs or behaves at
446 // runtime.
447 "libcall_call_conv" => *value == FlagValue::Enum("isa_default"),
448 "preserve_frame_pointers" => *value == FlagValue::Bool(true),
449 "enable_probestack" => *value == FlagValue::Bool(true),
450 "probestack_strategy" => *value == FlagValue::Enum("inline"),
451 "enable_multi_ret_implicit_sret" => *value == FlagValue::Bool(true),
452
453 // Features wasmtime doesn't use should all be disabled, since
454 // otherwise if they are enabled it could change the behavior of
455 // generated code.
456 "enable_llvm_abi_extensions" => *value == FlagValue::Bool(false),
457 "enable_pinned_reg" => *value == FlagValue::Bool(false),
458 "use_colocated_libcalls" => *value == FlagValue::Bool(false),
459 "use_pinned_reg_as_heap_base" => *value == FlagValue::Bool(false),
460
461 // Windows requires unwind info as part of its ABI.
462 "unwind_info" => {
463 if target.operating_system == target_lexicon::OperatingSystem::Windows {
464 *value == FlagValue::Bool(true)
465 } else {
466 return Ok(())
467 }
468 }
469
470 // stack switch model must match the current OS
471 "stack_switch_model" => {
472 if self.features().contains(WasmFeatures::STACK_SWITCHING) {
473 use target_lexicon::OperatingSystem;
474 let expected =
475 match target.operating_system {
476 OperatingSystem::Windows => "update_windows_tib",
477 OperatingSystem::Linux
478 | OperatingSystem::MacOSX(_)
479 | OperatingSystem::Darwin(_) => "basic",
480 _ => { return Err(String::from("stack-switching feature not supported on this platform")); }
481 };
482 *value == FlagValue::Enum(expected)
483 } else {
484 return Ok(())
485 }
486 }
487
488 // These settings don't affect the interface or functionality of
489 // the module itself, so their configuration values shouldn't
490 // matter.
491 "enable_heap_access_spectre_mitigation"
492 | "enable_table_access_spectre_mitigation"
493 | "enable_nan_canonicalization"
494 | "enable_float"

Callers 2

check_shared_flagsMethod · 0.80

Calls 6

EnumClass · 0.85
OkFunction · 0.85
fromFunction · 0.85
targetMethod · 0.45
containsMethod · 0.45
featuresMethod · 0.45

Tested by

no test coverage detected