enabled wasmtime built in caching

This commit is contained in:
Iris Pupo 2022-11-08 17:40:50 -05:00
parent b3c60eb73f
commit 05d68ab3c1
1 changed files with 4 additions and 0 deletions

View File

@ -13,12 +13,14 @@ type Linker = wasmtime::Linker<ScriptAbiImpl>;
pub struct WasmtimeBackend {
engine: wasmtime::Engine,
}
impl WasmtimeBackend {
pub fn new() -> anyhow::Result<Self> {
let mut config = wasmtime::Config::new();
config.wasm_simd(true);
config.wasm_bulk_memory(true);
config.cranelift_opt_level(wasmtime::OptLevel::Speed);
config.cache_config_load_default()?;
let engine = wasmtime::Engine::new(&config)?;
@ -26,7 +28,9 @@ impl WasmtimeBackend {
}
}
impl Backend for WasmtimeBackend {
fn load_module(&self, module: &[u8]) -> anyhow::Result<Arc<dyn Instance>> {
let module = wasmtime::Module::new(&self.engine, module)?;
let abi = ScriptAbiImpl::default();