Redesign the interface between the runtime and the backends.

This removes the ProtectedCaller and FuncResolver traits, simplifying call implementations and improving dynamic call throughput.
This commit is contained in:
Lachlan Sneff
2019-04-11 18:01:54 -07:00
parent 11b6a5d02d
commit d8c6f76846
8 changed files with 230 additions and 165 deletions

View File

@ -544,42 +544,23 @@ mod vm_ctx_tests {
fn generate_module() -> ModuleInner {
use super::Func;
use crate::backend::{
sys::Memory, Backend, CacheGen, FuncResolver, ProtectedCaller, Token, UserTrapper,
};
use crate::backend::{sys::Memory, Backend, CacheGen, RunnableModule, UserTrapper};
use crate::cache::Error as CacheError;
use crate::error::RuntimeResult;
use crate::typed_func::Wasm;
use crate::types::{FuncIndex, LocalFuncIndex, SigIndex, Value};
use crate::types::{LocalFuncIndex, SigIndex};
use hashbrown::HashMap;
use std::ptr::NonNull;
struct Placeholder;
impl FuncResolver for Placeholder {
fn get(
impl RunnableModule for Placeholder {
fn get_func(
&self,
_module: &ModuleInner,
_module: &ModuleInfo,
_local_func_index: LocalFuncIndex,
) -> Option<NonNull<Func>> {
None
}
}
impl ProtectedCaller for Placeholder {
fn call(
&self,
_module: &ModuleInner,
_func_index: FuncIndex,
_params: &[Value],
_import_backing: &ImportBacking,
_vmctx: *mut Ctx,
_: Token,
) -> RuntimeResult<Vec<Value>> {
Ok(vec![])
}
fn get_wasm_trampoline(
&self,
_module: &ModuleInner,
_sig_index: SigIndex,
) -> Option<Wasm> {
fn get_trampoline(&self, _module: &ModuleInfo, _sig_index: SigIndex) -> Option<Wasm> {
unimplemented!()
}
fn get_early_trapper(&self) -> Box<dyn UserTrapper> {
@ -596,8 +577,7 @@ mod vm_ctx_tests {
}
ModuleInner {
func_resolver: Box::new(Placeholder),
protected_caller: Box::new(Placeholder),
runnable_module: Box::new(Placeholder),
cache_gen: Box::new(Placeholder),
info: ModuleInfo {
memories: Map::new(),