wasm/execution/hooks.rs
1/// Trait that allows user specified hooks for various events during interpretation
2///
3/// The default implementation of all trait methods are empty, i. e. can be optimized out fully.
4// It mus always be checked that there is no performance penalty for an empty hook!
5pub trait HookSet: Default {
6 /// A hook which is called before every wasm instruction
7 ///
8 /// This allows the most intricate insight into the interpreters behavior, at the cost of a
9 /// hefty performance penalty
10 #[allow(unused_variables)]
11 fn instruction_hook(&mut self, bytecode: &[u8], pc: usize) {}
12}
13
14/// Default implementation of a hookset, with all hooks empty
15#[derive(Default, Debug)]
16pub struct EmptyHookSet;
17
18impl HookSet for EmptyHookSet {}