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

Method execute_async

src/commands/wizer.rs:48–157  ·  view source on GitHub ↗
(mut self)

Source from the content-addressed store, hash-verified

46 }
47
48 async fn execute_async(mut self) -> Result<()> {
49 // By default use deterministic relaxed simd operations to guarantee
50 // that if relaxed simd operations are used in a module that they always
51 // produce the same result.
52 if self.run.common.wasm.relaxed_simd_deterministic.is_none() {
53 self.run.common.wasm.relaxed_simd_deterministic = Some(true);
54 }
55
56 // Don't provide any WASI imports by default to wizened components. The
57 // `run` command provides the "cli" world as a default so turn that off
58 // here if the command line flags don't otherwise say what to do.
59 if self.run.common.wasi.cli.is_none() {
60 self.run.common.wasi.cli = Some(false);
61 }
62
63 // Read the input wasm, possibly from stdin.
64 let mut wasm = Vec::new();
65 if self.input.to_str() == Some("-") {
66 io::stdin()
67 .read_to_end(&mut wasm)
68 .context("failed to read input Wasm module from stdin")?;
69 } else {
70 wasm = fs::read(&self.input).context("failed to read input Wasm module")?;
71 }
72
73 #[cfg(feature = "wat")]
74 let wasm = wat::parse_bytes(&wasm)?;
75 let is_component = wasmparser::Parser::is_component(&wasm);
76
77 let mut run = RunCommand {
78 run: self.run,
79 argv0: None,
80 invoke: Some(if is_component {
81 format!("{}()", self.wizer.get_init_func())
82 } else {
83 self.wizer.get_init_func().to_string()
84 }),
85 module_and_args: vec![self.input.clone().into()],
86 preloads: self.preloads.clone(),
87 module_bytes: None,
88 };
89 let engine = run.new_engine()?;
90
91 // Instrument the input wasm with wizer.
92 let (cx, main) = if is_component {
93 #[cfg(feature = "component-model")]
94 {
95 let (cx, wasm) = self.wizer.instrument_component(&wasm)?;
96 (
97 WizerInfo::Component(cx),
98 RunTarget::Component(wasmtime::component::Component::new(&engine, &wasm)?),
99 )
100 }
101 #[cfg(not(feature = "component-model"))]
102 unreachable!();
103 } else {
104 let (cx, wasm) = self.wizer.instrument(&wasm)?;
105 (

Callers 1

executeMethod · 0.80

Calls 15

OkFunction · 0.85
to_strMethod · 0.80
get_init_funcMethod · 0.80
new_engineMethod · 0.80
instrument_componentMethod · 0.80
instrumentMethod · 0.80
new_store_and_linkerMethod · 0.80
instantiate_and_runMethod · 0.80
snapshotMethod · 0.80
snapshot_componentMethod · 0.80
write_allMethod · 0.80
newFunction · 0.50

Tested by

no test coverage detected