mirror of
https://github.com/fluencelabs/wasmer
synced 2025-06-12 08:31:21 +00:00
Remove UserTrapper trait
This commit is contained in:
@ -65,10 +65,6 @@ pub trait Compiler {
|
||||
unsafe fn from_cache(&self, cache: Artifact, _: Token) -> Result<ModuleInner, CacheError>;
|
||||
}
|
||||
|
||||
pub trait UserTrapper {
|
||||
unsafe fn do_early_trap(&self, data: Box<dyn Any>) -> !;
|
||||
}
|
||||
|
||||
pub trait RunnableModule: Send + Sync {
|
||||
/// This returns a pointer to the function designated by the `local_func_index`
|
||||
/// parameter.
|
||||
@ -83,7 +79,7 @@ pub trait RunnableModule: Send + Sync {
|
||||
/// signature and an invoke function that can call the trampoline.
|
||||
fn get_trampoline(&self, info: &ModuleInfo, sig_index: SigIndex) -> Option<Wasm>;
|
||||
|
||||
fn get_early_trapper(&self) -> Box<dyn UserTrapper>;
|
||||
unsafe fn do_early_trap(&self, data: Box<dyn Any>) -> !;
|
||||
}
|
||||
|
||||
pub trait CacheGen: Send + Sync {
|
||||
|
@ -4,7 +4,6 @@ use crate::{
|
||||
error,
|
||||
import::ImportObject,
|
||||
structures::{Map, TypedIndex},
|
||||
typed_func::EARLY_TRAPPER,
|
||||
types::{
|
||||
FuncIndex, FuncSig, GlobalDescriptor, GlobalIndex, GlobalInit, ImportedFuncIndex,
|
||||
ImportedGlobalIndex, ImportedMemoryIndex, ImportedTableIndex, Initializer,
|
||||
@ -92,10 +91,6 @@ pub struct Module {
|
||||
|
||||
impl Module {
|
||||
pub(crate) fn new(inner: Arc<ModuleInner>) -> Self {
|
||||
unsafe {
|
||||
EARLY_TRAPPER
|
||||
.with(|ucell| *ucell.get() = Some(inner.runnable_module.get_early_trapper()));
|
||||
}
|
||||
Module { inner }
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
use crate::{
|
||||
backend::UserTrapper,
|
||||
error::RuntimeError,
|
||||
export::{Context, Export, FuncPointer},
|
||||
import::IsExport,
|
||||
@ -8,7 +7,6 @@ use crate::{
|
||||
};
|
||||
use std::{
|
||||
any::Any,
|
||||
cell::UnsafeCell,
|
||||
ffi::c_void,
|
||||
fmt,
|
||||
marker::PhantomData,
|
||||
@ -17,10 +15,6 @@ use std::{
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
thread_local! {
|
||||
pub static EARLY_TRAPPER: UnsafeCell<Option<Box<dyn UserTrapper>>> = UnsafeCell::new(None);
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
pub enum WasmTrapInfo {
|
||||
Unreachable = 0,
|
||||
@ -354,12 +348,7 @@ macro_rules! impl_traits {
|
||||
};
|
||||
|
||||
unsafe {
|
||||
if let Some(early_trapper) = &*EARLY_TRAPPER.with(|ucell| ucell.get()) {
|
||||
early_trapper.do_early_trap(err)
|
||||
} else {
|
||||
eprintln!("panic handling not setup");
|
||||
std::process::exit(1)
|
||||
}
|
||||
(&*ctx.module).runnable_module.do_early_trap(err)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ pub struct Ctx {
|
||||
|
||||
local_backing: *mut LocalBacking,
|
||||
import_backing: *mut ImportBacking,
|
||||
module: *const ModuleInner,
|
||||
pub(crate) module: *const ModuleInner,
|
||||
|
||||
pub data: *mut c_void,
|
||||
pub data_finalizer: Option<fn(data: *mut c_void)>,
|
||||
|
Reference in New Issue
Block a user