Fix call_indirect.

This commit is contained in:
losfair
2019-03-12 11:31:55 +08:00
parent c5ef0a96e9
commit 683cb2090c
6 changed files with 22 additions and 14 deletions

View File

@ -194,7 +194,7 @@ impl LocalBacking {
}
};
elements[init_base + i] = vm::Anyfunc { func, ctx, sig_id };
elements[init_base + i] = vm::Anyfunc { func, ctx, sig_id, func_index: Some(func_index) };
}
});
}
@ -232,7 +232,12 @@ impl LocalBacking {
}
};
elements[init_base + i] = vm::Anyfunc { func, ctx, sig_id };
elements[init_base + i] = vm::Anyfunc {
func,
ctx,
sig_id,
func_index: Some(func_index),
};
}
});
}

View File

@ -428,7 +428,7 @@ pub struct DynFunc<'a> {
pub(crate) signature: Arc<FuncSig>,
module: &'a ModuleInner,
pub(crate) instance_inner: &'a InstanceInner,
func_index: FuncIndex,
pub func_index: FuncIndex,
}
impl<'a> DynFunc<'a> {

View File

@ -110,6 +110,7 @@ impl AnyfuncTable {
func: ptr,
ctx: ptr::null_mut(),
sig_id,
func_index: None,
}
}
AnyfuncInner::Managed(ref func) => {
@ -120,6 +121,7 @@ impl AnyfuncTable {
func: func.raw(),
ctx: func.instance_inner.vmctx,
sig_id,
func_index: Some(func.func_index),
}
}
};

View File

@ -3,7 +3,7 @@ use crate::{
memory::Memory,
module::ModuleInner,
structures::TypedIndex,
types::{LocalOrImport, MemoryIndex},
types::{FuncIndex, LocalOrImport, MemoryIndex},
};
use std::{ffi::c_void, mem, ptr};
@ -283,6 +283,7 @@ pub struct Anyfunc {
pub func: *const Func,
pub ctx: *mut Ctx,
pub sig_id: SigId,
pub func_index: Option<FuncIndex>,
}
impl Anyfunc {
@ -291,6 +292,7 @@ impl Anyfunc {
func: ptr::null(),
ctx: ptr::null_mut(),
sig_id: SigId(u32::max_value()),
func_index: None,
}
}