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

Method update_module_config

crates/fuzzing/src/generators/config.rs:656–798  ·  view source on GitHub ↗

Updates `config` to be compatible with `self` and the other way around too.

(
        &mut self,
        config: &mut ModuleConfig,
        _u: &mut Unstructured<'_>,
    )

Source from the content-addressed store, hash-verified

654 /// Updates `config` to be compatible with `self` and the other way around
655 /// too.
656 pub fn update_module_config(
657 &mut self,
658 config: &mut ModuleConfig,
659 _u: &mut Unstructured<'_>,
660 ) -> arbitrary::Result<()> {
661 match self.compiler_strategy {
662 CompilerStrategy::CraneliftNative => {}
663
664 CompilerStrategy::Winch => {
665 // Winch is not complete on non-x64 targets, so just abandon this test
666 // case. We don't want to force Cranelift because we change what module
667 // config features are enabled based on the compiler strategy, and we
668 // don't want to make the same fuzz input DNA generate different test
669 // cases on different targets.
670 if cfg!(not(any(target_arch = "x86_64", target_arch = "aarch64"))) {
671 log::warn!(
672 "want to compile with Winch but host architecture does not support it"
673 );
674 return Err(arbitrary::Error::IncorrectFormat);
675 }
676
677 // Winch doesn't support the same set of wasm proposal as Cranelift
678 // at this time, so if winch is selected be sure to disable wasm
679 // proposals in `Config` to ensure that Winch can compile the
680 // module that wasm-smith generates.
681 config.config.relaxed_simd_enabled = false;
682 config.config.gc_enabled = false;
683 config.config.tail_call_enabled = false;
684 config.config.reference_types_enabled = false;
685 config.config.exceptions_enabled = false;
686 config.function_references_enabled = false;
687 config.stack_switching = false;
688
689 // Winch's SIMD implementations require AVX and AVX2.
690 if self
691 .codegen_flag("has_avx")
692 .is_some_and(|value| value == "false")
693 || self
694 .codegen_flag("has_avx2")
695 .is_some_and(|value| value == "false")
696 {
697 config.config.simd_enabled = false;
698 }
699
700 // Account for the proposals that are currently only
701 // supported on x64.
702 if cfg!(target_arch = "aarch64") {
703 config.config.simd_enabled = false;
704 config.config.wide_arithmetic_enabled = false;
705 config.config.threads_enabled = false;
706 }
707
708 // Tuning the following engine options is currently not supported
709 // by Winch.
710 self.signals_based_traps = true;
711 self.table_lazy_init = true;
712 self.debug_info = false;
713 }

Callers 2

newMethod · 0.80
arbitraryMethod · 0.80

Calls 6

OkFunction · 0.85
codegen_flagMethod · 0.80
minMethod · 0.45
try_intoMethod · 0.45
maxMethod · 0.45

Tested by

no test coverage detected