Simplify instantiation

This commit is contained in:
Syrus
2020-05-20 20:23:17 -07:00
parent 931e9cdb0a
commit 2c66e2ac3c
5 changed files with 11 additions and 84 deletions

View File

@@ -223,19 +223,16 @@ impl Module {
resolver: &dyn Resolver,
) -> Result<InstanceHandle, InstantiationError> {
unsafe {
let instance_handle = self
.store
.engine()
.instantiate(self.artifact.borrow(), resolver)?;
let instance_handle =
self.artifact
.instantiate(self.store.engine().as_ref(), resolver, Box::new(()))?;
// After the instance handle is created, we need to initialize
// the data, call the start function and so. However, if any
// of this steps traps, we still need to keep the instance alive
// as some of the Instance elements may have placed in other
// instance tables.
self.store
.engine()
.finish_instantiation(self.artifact.borrow(), &instance_handle)?;
self.artifact.finish_instantiation(&instance_handle)?;
Ok(instance_handle)
}