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

Function build

crates/fuzzing/src/oracles/engine.rs:13–50  ·  view source on GitHub ↗

Returns a function which can be used to build the engine name specified. `None` is returned if the named engine does not have support compiled into this crate.

(
    u: &mut Unstructured<'_>,
    name: &str,
    config: &mut Config,
)

Source from the content-addressed store, hash-verified

11/// `None` is returned if the named engine does not have support compiled into
12/// this crate.
13pub fn build(
14 u: &mut Unstructured<'_>,
15 name: &str,
16 config: &mut Config,
17) -> arbitrary::Result<Option<Box<dyn DiffEngine>>> {
18 let engine: Box<dyn DiffEngine> = match name {
19 "wasmtime" => Box::new(WasmtimeEngine::new(
20 u,
21 config,
22 CompilerStrategy::CraneliftNative,
23 )?),
24 "pulley" => Box::new(WasmtimeEngine::new(
25 u,
26 config,
27 CompilerStrategy::CraneliftPulley,
28 )?),
29 "wasmi" => Box::new(WasmiEngine::new(config)),
30
31 #[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))]
32 "winch" => Box::new(WasmtimeEngine::new(u, config, CompilerStrategy::Winch)?),
33 #[cfg(not(any(target_arch = "x86_64", target_arch = "aarch64")))]
34 "winch" => return Ok(None),
35
36 #[cfg(feature = "fuzz-spec-interpreter")]
37 "spec" => Box::new(crate::oracles::diff_spec::SpecInterpreter::new(config)),
38 #[cfg(not(feature = "fuzz-spec-interpreter"))]
39 "spec" => return Ok(None),
40
41 #[cfg(feature = "v8")]
42 "v8" => Box::new(crate::oracles::diff_v8::V8Engine::new(config)),
43 #[cfg(not(feature = "v8"))]
44 "v8" => return Ok(None),
45
46 _ => panic!("unknown engine {name}"),
47 };
48
49 Ok(Some(engine))
50}
51
52/// Provide a way to instantiate Wasm modules.
53pub trait DiffEngine {

Callers 3

parseMethod · 0.50
buildMethod · 0.50
execute_oneFunction · 0.50

Calls 2

OkFunction · 0.85
newFunction · 0.50

Tested by

no test coverage detected