Refactor away the Instantiator type in Wasmtime (#3972)
* Refactor away the `Instantiator` type in Wasmtime This internal type in Wasmtime was primarily used for the module linking proposal to handle instantiation of many instances and refactor out the sync and async parts to minimize duplication. With the removal of the module linking proposal, however, this type isn't really necessary any longer. In working to implement the component model proposal I was looking already to refactor this and I figured it'd be good to land that ahead of time on `main` separate of other refactorings. This commit removes the `Instantiator` type in the `instance` module. The type was already private to Wasmtime so this shouldn't have any impact on consumers. This allows simplifying various code paths to avoid another abstraction. The meat of instantiation is moved to `Instance::new_raw` which should be reusable for the component model as well. One bug is actually fixed in this commit as well where `Linker::instantiate` and `InstancePre::instantiate` failed to check that async support was disabled on a store. This means that they could have led to a panic if used with an async store and a start function called an async import (or an async resource limiter yielded). A few tests were updated with this. * Review comments
This commit is contained in:
@@ -614,7 +614,7 @@ async fn basic_async_hook() -> Result<(), Error> {
|
||||
"#;
|
||||
let module = Module::new(&engine, wat)?;
|
||||
|
||||
let inst = linker.instantiate(&mut store, &module)?;
|
||||
let inst = linker.instantiate_async(&mut store, &module).await?;
|
||||
let export = inst
|
||||
.get_export(&mut store, "export")
|
||||
.expect("get export")
|
||||
@@ -694,7 +694,7 @@ async fn timeout_async_hook() -> Result<(), Error> {
|
||||
"#;
|
||||
let module = Module::new(&engine, wat)?;
|
||||
|
||||
let inst = linker.instantiate(&mut store, &module)?;
|
||||
let inst = linker.instantiate_async(&mut store, &module).await?;
|
||||
let export = inst
|
||||
.get_typed_func::<(), (), _>(&mut store, "export")
|
||||
.expect("export is func");
|
||||
@@ -764,7 +764,7 @@ async fn drop_suspended_async_hook() -> Result<(), Error> {
|
||||
"#;
|
||||
let module = Module::new(&engine, wat)?;
|
||||
|
||||
let inst = linker.instantiate(&mut store, &module)?;
|
||||
let inst = linker.instantiate_async(&mut store, &module).await?;
|
||||
assert_eq!(*store.data(), 0);
|
||||
let export = inst
|
||||
.get_typed_func::<(), (), _>(&mut store, "")
|
||||
|
||||
Reference in New Issue
Block a user