Make Instance a refcounting handle around InstanceContents.

This commit is contained in:
Dan Gohman
2019-02-22 11:48:17 -08:00
parent a8cd5ef613
commit 077ee717a8
11 changed files with 205 additions and 189 deletions

View File

@@ -132,8 +132,8 @@ fn main() {
let mut context = Context::with_isa(isa);
// Make spectest available by default.
context.instance(
Some("spectest".to_owned()),
context.name_instance(
"spectest".to_owned(),
instantiate_spectest().expect("instantiating spectest"),
);
@@ -155,14 +155,14 @@ fn handle_module(context: &mut Context, args: &Args, path: &Path) -> Result<(),
let data = read_wasm(path.to_path_buf())?;
// Create a new `Instance` by compiling and instantiating a wasm module.
let index = context
let mut instance = context
.instantiate_module(None, &data)
.map_err(|e| e.to_string())?;
// If a function to invoke was given, invoke it.
if let Some(ref f) = args.flag_invoke {
match context
.invoke_indexed(index, f, &[])
.invoke(&mut instance, f, &[])
.map_err(|e| e.to_string())?
{
ActionOutcome::Returned { .. } => {}