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

Method execute

src/commands/wast.rs:54–113  ·  view source on GitHub ↗

Executes the command.

(mut self)

Source from the content-addressed store, hash-verified

52impl WastCommand {
53 /// Executes the command.
54 pub fn execute(mut self) -> Result<()> {
55 self.common.init_logging()?;
56
57 let async_ = optional_flag_with_default(self.async_, true);
58 let mut config = self.common.config(None)?;
59 config.shared_memory(true);
60
61 let generate_dwarf = optional_flag_with_default(self.generate_dwarf, true);
62 // When DWARF is being generated go ahead and enable backtrace details
63 // unconditionally as that's generally what's intended.
64 if generate_dwarf {
65 config.wasm_backtrace_details(wasmtime::WasmBacktraceDetails::Enable);
66 }
67 let engine = Engine::new(&config)?;
68 let mut wast_context = WastContext::new(
69 &engine,
70 if async_ {
71 wasmtime_wast::Async::Yes
72 } else {
73 wasmtime_wast::Async::No
74 },
75 move |store| {
76 if let Some(fuel) = self.common.wasm.fuel {
77 store.set_fuel(fuel).unwrap();
78 }
79 if let Some(true) = self.common.wasm.epoch_interruption {
80 store.epoch_deadline_trap();
81 store.set_epoch_deadline(1);
82 }
83 },
84 );
85
86 wast_context.generate_dwarf(generate_dwarf);
87 wast_context
88 .register_spectest(&SpectestConfig {
89 use_shared_memory: true,
90 suppress_prints: false,
91 })
92 .expect("error instantiating \"spectest\"");
93 wast_context.ignore_error_messages(self.ignore_error_messages);
94
95 if let Some(path) = &self.precompile_save {
96 wast_context.precompile_save(path);
97 }
98 if let Some(path) = &self.precompile_load {
99 wast_context.precompile_load(path);
100 }
101
102 if self.wasmtime_builtins {
103 wast_context.register_wasmtime()?;
104 }
105
106 for script in self.scripts.iter() {
107 wast_context
108 .run_file(script)
109 .with_context(|| format!("failed to run script file '{}'", script.display()))?;
110 }
111

Callers

nothing calls this directly

Calls 15

OkFunction · 0.85
init_loggingMethod · 0.80
epoch_deadline_trapMethod · 0.80
generate_dwarfMethod · 0.80
register_spectestMethod · 0.80
ignore_error_messagesMethod · 0.80
precompile_saveMethod · 0.80
precompile_loadMethod · 0.80
register_wasmtimeMethod · 0.80
with_contextMethod · 0.80
run_fileMethod · 0.80

Tested by

no test coverage detected