From 81f896f2cf8f5176d714a1f1eda2f6c8ef2d94c7 Mon Sep 17 00:00:00 2001 From: Valery Antopol Date: Wed, 8 Feb 2023 15:17:07 +0300 Subject: [PATCH] add a non-default constructor of WasmBackend --- core/src/marine_core.rs | 2 +- crates/marine-wasmtime-backend/src/lib.rs | 11 +++++++++++ crates/wasm-backend-traits/src/lib.rs | 2 ++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/core/src/marine_core.rs b/core/src/marine_core.rs index 034d6227..ddd06121 100644 --- a/core/src/marine_core.rs +++ b/core/src/marine_core.rs @@ -49,7 +49,7 @@ pub struct MarineCore { impl MarineCore { pub fn new() -> Self { - let wasm_backend = WB::default(); + let wasm_backend = WB::new(); let store = ::Store::new(&wasm_backend); Self { modules: HashMap::new(), diff --git a/crates/marine-wasmtime-backend/src/lib.rs b/crates/marine-wasmtime-backend/src/lib.rs index 09392a70..1f7c8fde 100644 --- a/crates/marine-wasmtime-backend/src/lib.rs +++ b/crates/marine-wasmtime-backend/src/lib.rs @@ -91,6 +91,17 @@ impl WasmBackend for WasmtimeWasmBackend { inner: module, }) } + + fn new() -> Self { + let mut config = wasmtime::Config::new(); + config + .debug_info(true) + .wasm_backtrace_details(wasmtime::WasmBacktraceDetails::Enable); + let engine = wasmtime::Engine::new(&config).unwrap(); + Self { + engine + } + } } #[derive(Default)] diff --git a/crates/wasm-backend-traits/src/lib.rs b/crates/wasm-backend-traits/src/lib.rs index cc33454e..2bdec36c 100644 --- a/crates/wasm-backend-traits/src/lib.rs +++ b/crates/wasm-backend-traits/src/lib.rs @@ -57,6 +57,8 @@ pub trait WasmBackend: Clone + Default + 'static { type Wasi: WasiImplementation; fn compile(store: &mut Self::Store, wasm: &[u8]) -> CompilationResult; + + fn new() -> Self; } pub struct DelayedContextLifetime {