wasmtime: Refactor how imports are resolved (#2102)

This commit removes all import resolution handling from the
`wasmtime-jit` crate, instead moving the logic to the `wasmtime` crate.
Previously `wasmtime-jit` had a generic `Resolver` trait and would do
all the import type matching itself, but with the upcoming
module-linking implementation this is going to get much trickier.

The goal of this commit is to centralize all meaty "preparation" logic
for instantiation into one location, probably the `wasmtime` crate
itself. Instantiation will soon involve recursive instantiation and
management of alias definitions as well. Having everything in one
location, especially with access to `Store` so we can persist
instances for safety, will be quite convenient.

Additionally the `Resolver` trait isn't really necessary any more since
imports are, at the lowest level, provided as a list rather than a map
of some kind. More generic resolution functionality is provided via
`Linker` or user layers on top of `Instance::new` itself. This makes
matching up provided items to expected imports much easier as well.

Overall this is largely just moving code around, but most of the code
in the previous `resolve_imports` phase can be deleted since a lot of it
is handled by surrounding pieces of `wasmtime` as well.
This commit is contained in:
Alex Crichton
2020-08-07 16:38:01 -05:00
committed by GitHub
parent 08f9eb1725
commit c7cd70fcec
15 changed files with 209 additions and 407 deletions

View File

@@ -262,7 +262,7 @@ pub fn create_handle_with_function(
finished_functions,
trampolines,
Box::new(trampoline_state),
PrimaryMap::new(),
&[],
)
.map(|instance| (instance, trampoline))
}
@@ -298,12 +298,5 @@ pub unsafe fn create_handle_with_raw_function(
let sig_id = store.register_signature(ft.to_wasm_func_type(), sig);
trampolines.insert(sig_id, trampoline);
create_handle(
module,
store,
finished_functions,
trampolines,
state,
PrimaryMap::new(),
)
create_handle(module, store, finished_functions, trampolines, state, &[])
}