Reuse the same parity_wasm::Module instance for wasmi

Since `wasmi` already has a public dependency on `parity_wasm` let's just use
it! A `clone` is much faster than a serialize + parse, reducing a `wasm-bindgen`
invocation on my machine from 0.2s to 0.18s.
This commit is contained in:
Alex Crichton
2018-07-25 15:42:44 -07:00
parent 9b5d47f5e1
commit 764302cfcc

View File

@ -134,7 +134,9 @@ impl Bindgen {
// This means that whenever we encounter an import or export we'll
// execute a shim function which informs us about its type so we can
// then generate the appropriate bindings.
let instance = wasmi::Module::from_buffer(&contents)
//
// TODO: avoid a `clone` here of the module if we can
let instance = wasmi::Module::from_parity_wasm_module(module.clone())
.with_context(|_| "failed to create wasmi module")?;
let instance = wasmi::ModuleInstance::new(&instance, &MyResolver)
.with_context(|_| "failed to instantiate wasm module")?;