mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-12 05:18:43 +00:00
Improved trap handling
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
use crate::tunables::BaseTunables;
|
||||
use loupe::MemoryUsage;
|
||||
use std::any::Any;
|
||||
use std::fmt;
|
||||
use std::sync::Arc;
|
||||
#[cfg(all(feature = "compiler", feature = "engine"))]
|
||||
use wasmer_compiler::CompilerConfig;
|
||||
use wasmer_engine::{Engine, Tunables};
|
||||
use wasmer_engine::{is_wasm_pc, Engine, Tunables};
|
||||
use wasmer_vm::{init_traps, SignalHandler, TrapInfo};
|
||||
|
||||
/// The store represents all global state that can be manipulated by
|
||||
/// WebAssembly programs. It consists of the runtime representation
|
||||
@@ -28,10 +30,7 @@ impl Store {
|
||||
where
|
||||
E: Engine + ?Sized,
|
||||
{
|
||||
Self {
|
||||
engine: engine.cloned(),
|
||||
tunables: Arc::new(BaseTunables::for_target(engine.target())),
|
||||
}
|
||||
Self::new_with_tunables(engine, BaseTunables::for_target(engine.target()))
|
||||
}
|
||||
|
||||
/// Creates a new `Store` with a specific [`Engine`] and [`Tunables`].
|
||||
@@ -39,6 +38,10 @@ impl Store {
|
||||
where
|
||||
E: Engine + ?Sized,
|
||||
{
|
||||
// Make sure the signal handlers are installed.
|
||||
// This is required for handling traps.
|
||||
init_traps(is_wasm_pc);
|
||||
|
||||
Self {
|
||||
engine: engine.cloned(),
|
||||
tunables: Arc::new(tunables),
|
||||
@@ -69,6 +72,19 @@ impl PartialEq for Store {
|
||||
}
|
||||
}
|
||||
|
||||
unsafe impl TrapInfo for Store {
|
||||
#[inline]
|
||||
fn as_any(&self) -> &dyn Any {
|
||||
self
|
||||
}
|
||||
fn custom_signal_handler(&self, call: &dyn Fn(&SignalHandler) -> bool) -> bool {
|
||||
// if let Some(handler) = &*self.inner.signal_handler.borrow() {
|
||||
// return call(handler);
|
||||
// }
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
// We only implement default if we have assigned a default compiler and engine
|
||||
#[cfg(all(feature = "default-compiler", feature = "default-engine"))]
|
||||
impl Default for Store {
|
||||
|
||||
Reference in New Issue
Block a user