mirror of
https://github.com/fluencelabs/wasmer
synced 2024-12-13 06:15:33 +00:00
Warnings and unused code cleanup
This commit is contained in:
parent
4e17ff8571
commit
051d435423
@ -78,7 +78,7 @@ impl Module {
|
|||||||
Arc::clone(&func_resolver.memory),
|
Arc::clone(&func_resolver.memory),
|
||||||
));
|
));
|
||||||
|
|
||||||
let runnable_module = Caller::new(&self.info, handler_data, trampolines, func_resolver);
|
let runnable_module = Caller::new(handler_data, trampolines, func_resolver);
|
||||||
|
|
||||||
Ok(ModuleInner {
|
Ok(ModuleInner {
|
||||||
runnable_module: Box::new(runnable_module),
|
runnable_module: Box::new(runnable_module),
|
||||||
@ -107,7 +107,7 @@ impl Module {
|
|||||||
Arc::clone(&func_resolver.memory),
|
Arc::clone(&func_resolver.memory),
|
||||||
));
|
));
|
||||||
|
|
||||||
let runnable_module = Caller::new(&info, handler_data, trampolines, func_resolver);
|
let runnable_module = Caller::new(handler_data, trampolines, func_resolver);
|
||||||
|
|
||||||
Ok(ModuleInner {
|
Ok(ModuleInner {
|
||||||
runnable_module: Box::new(runnable_module),
|
runnable_module: Box::new(runnable_module),
|
||||||
|
@ -21,7 +21,6 @@ use wasmer_runtime_core::cache::Error as CacheError;
|
|||||||
use wasmer_runtime_core::{
|
use wasmer_runtime_core::{
|
||||||
self,
|
self,
|
||||||
backend::{
|
backend::{
|
||||||
self,
|
|
||||||
sys::{Memory, Protect},
|
sys::{Memory, Protect},
|
||||||
SigRegistry,
|
SigRegistry,
|
||||||
},
|
},
|
||||||
|
@ -1,16 +1,14 @@
|
|||||||
use crate::relocation::{TrapData, TrapSink};
|
use crate::relocation::{TrapData, TrapSink};
|
||||||
use crate::resolver::FuncResolver;
|
use crate::resolver::FuncResolver;
|
||||||
use crate::trampoline::Trampolines;
|
use crate::trampoline::Trampolines;
|
||||||
use hashbrown::HashSet;
|
|
||||||
use libc::c_void;
|
use libc::c_void;
|
||||||
use std::{any::Any, cell::Cell, ptr::NonNull, sync::Arc};
|
use std::{any::Any, cell::Cell, ptr::NonNull, sync::Arc};
|
||||||
use wasmer_runtime_core::{
|
use wasmer_runtime_core::{
|
||||||
backend::{RunnableModule, UserTrapper},
|
backend::{RunnableModule, UserTrapper},
|
||||||
export::Context,
|
module::ModuleInfo,
|
||||||
module::{ExportIndex, ModuleInfo, ModuleInner},
|
|
||||||
typed_func::{Wasm, WasmTrapInfo},
|
typed_func::{Wasm, WasmTrapInfo},
|
||||||
types::{FuncIndex, FuncSig, LocalFuncIndex, LocalOrImport, SigIndex, Type, Value},
|
types::{LocalFuncIndex, SigIndex},
|
||||||
vm::{self, ImportBacking},
|
vm,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
@ -39,7 +37,6 @@ impl UserTrapper for Trapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub struct Caller {
|
pub struct Caller {
|
||||||
func_export_set: HashSet<FuncIndex>,
|
|
||||||
handler_data: HandlerData,
|
handler_data: HandlerData,
|
||||||
trampolines: Arc<Trampolines>,
|
trampolines: Arc<Trampolines>,
|
||||||
resolver: FuncResolver,
|
resolver: FuncResolver,
|
||||||
@ -47,23 +44,11 @@ pub struct Caller {
|
|||||||
|
|
||||||
impl Caller {
|
impl Caller {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
module: &ModuleInfo,
|
|
||||||
handler_data: HandlerData,
|
handler_data: HandlerData,
|
||||||
trampolines: Arc<Trampolines>,
|
trampolines: Arc<Trampolines>,
|
||||||
resolver: FuncResolver,
|
resolver: FuncResolver,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let mut func_export_set = HashSet::new();
|
|
||||||
for export_index in module.exports.values() {
|
|
||||||
if let ExportIndex::Func(func_index) = export_index {
|
|
||||||
func_export_set.insert(*func_index);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if let Some(start_func_index) = module.start_func {
|
|
||||||
func_export_set.insert(start_func_index);
|
|
||||||
}
|
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
func_export_set,
|
|
||||||
handler_data,
|
handler_data,
|
||||||
trampolines,
|
trampolines,
|
||||||
resolver,
|
resolver,
|
||||||
@ -83,13 +68,13 @@ impl RunnableModule for Caller {
|
|||||||
func: NonNull<vm::Func>,
|
func: NonNull<vm::Func>,
|
||||||
args: *const u64,
|
args: *const u64,
|
||||||
rets: *mut u64,
|
rets: *mut u64,
|
||||||
trap_info: *mut WasmTrapInfo,
|
_trap_info: *mut WasmTrapInfo,
|
||||||
invoke_env: Option<NonNull<c_void>>,
|
invoke_env: Option<NonNull<c_void>>,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let handler_data = &*invoke_env.unwrap().cast().as_ptr();
|
let handler_data = &*invoke_env.unwrap().cast().as_ptr();
|
||||||
|
|
||||||
#[cfg(not(target_os = "windows"))]
|
#[cfg(not(target_os = "windows"))]
|
||||||
let res = call_protected(handler_data, || unsafe {
|
let res = call_protected(handler_data, || {
|
||||||
// Leap of faith.
|
// Leap of faith.
|
||||||
trampoline(ctx, func, args, rets);
|
trampoline(ctx, func, args, rets);
|
||||||
})
|
})
|
||||||
@ -121,40 +106,6 @@ impl RunnableModule for Caller {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_func_from_index<'a>(
|
|
||||||
module: &'a ModuleInner,
|
|
||||||
import_backing: &ImportBacking,
|
|
||||||
func_index: FuncIndex,
|
|
||||||
) -> (NonNull<vm::Func>, Context, &'a FuncSig, SigIndex) {
|
|
||||||
let sig_index = *module
|
|
||||||
.info
|
|
||||||
.func_assoc
|
|
||||||
.get(func_index)
|
|
||||||
.expect("broken invariant, incorrect func index");
|
|
||||||
|
|
||||||
let (func_ptr, ctx) = match func_index.local_or_import(&module.info) {
|
|
||||||
LocalOrImport::Local(local_func_index) => (
|
|
||||||
module
|
|
||||||
.runnable_module
|
|
||||||
.get_func(&module.info, local_func_index)
|
|
||||||
.expect("broken invariant, func resolver not synced with module.exports")
|
|
||||||
.cast(),
|
|
||||||
Context::Internal,
|
|
||||||
),
|
|
||||||
LocalOrImport::Import(imported_func_index) => {
|
|
||||||
let imported_func = import_backing.imported_func(imported_func_index);
|
|
||||||
(
|
|
||||||
NonNull::new(imported_func.func as *mut _).unwrap(),
|
|
||||||
Context::External(imported_func.vmctx),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
let signature = &module.info.signatures[sig_index];
|
|
||||||
|
|
||||||
(func_ptr, ctx, signature, sig_index)
|
|
||||||
}
|
|
||||||
|
|
||||||
unsafe impl Send for HandlerData {}
|
unsafe impl Send for HandlerData {}
|
||||||
unsafe impl Sync for HandlerData {}
|
unsafe impl Sync for HandlerData {}
|
||||||
|
|
||||||
|
@ -6,7 +6,6 @@ use cranelift_codegen::{
|
|||||||
isa, Context,
|
isa, Context,
|
||||||
};
|
};
|
||||||
use hashbrown::HashMap;
|
use hashbrown::HashMap;
|
||||||
use std::ffi::c_void;
|
|
||||||
use std::{iter, mem, ptr::NonNull};
|
use std::{iter, mem, ptr::NonNull};
|
||||||
use wasmer_runtime_core::{
|
use wasmer_runtime_core::{
|
||||||
backend::sys::{Memory, Protect},
|
backend::sys::{Memory, Protect},
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
backend::{RunnableModule, Token},
|
backend::RunnableModule,
|
||||||
backing::{ImportBacking, LocalBacking},
|
backing::{ImportBacking, LocalBacking},
|
||||||
error::{CallError, CallResult, ResolveError, ResolveResult, Result, RuntimeError},
|
error::{CallError, CallResult, ResolveError, ResolveResult, Result, RuntimeError},
|
||||||
export::{Context, Export, ExportIter, FuncPointer},
|
export::{Context, Export, ExportIter, FuncPointer},
|
||||||
|
Loading…
Reference in New Issue
Block a user