Generate trampolines to call exported functions instead of using libffi (#108)

* remove codegen.rs

* Add export trampolines and remove libffi

* Remove unused extern crates
This commit is contained in:
Lachlan Sneff
2019-01-22 15:00:27 -08:00
committed by GitHub
parent ee67bf95db
commit 38b0fbf3c5
13 changed files with 300 additions and 1832 deletions

View File

@ -56,11 +56,10 @@ pub trait ProtectedCaller {
module: &ModuleInner,
func_index: FuncIndex,
params: &[Value],
returns: &mut [Value],
import_backing: &ImportBacking,
vmctx: *mut vm::Ctx,
_: Token,
) -> RuntimeResult<()>;
) -> RuntimeResult<Vec<Value>>;
}
pub trait FuncResolver {

View File

@ -118,9 +118,6 @@ impl Instance {
})?
}
// Create an output vector that's full of dummy values.
let mut returns = vec![Value::I32(0); signature.returns.len()];
let vmctx = match func_index.local_or_import(&self.module) {
LocalOrImport::Local(_) => &mut *self.inner.vmctx,
LocalOrImport::Import(imported_func_index) => {
@ -130,11 +127,10 @@ impl Instance {
let token = Token::generate();
self.module.protected_caller.call(
let returns = self.module.protected_caller.call(
&self.module,
func_index,
args,
&mut returns,
&self.inner.import_backing,
vmctx,
token,

View File

@ -234,7 +234,7 @@ define_local_or_import![
(GlobalIndex | (LocalGlobalIndex, ImportedGlobalIndex): imported_globals),
];
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub struct SigIndex(u32);
impl TypedIndex for SigIndex {
#[doc(hidden)]

View File

@ -587,12 +587,11 @@ mod vm_ctx_tests {
_module: &ModuleInner,
_func_index: FuncIndex,
_params: &[Value],
_returns: &mut [Value],
_import_backing: &ImportBacking,
_vmctx: *mut Ctx,
_: Token,
) -> RuntimeResult<()> {
Ok(())
) -> RuntimeResult<Vec<Value>> {
Ok(vec![])
}
}