wasm/execution/config.rs
1/// Trait that allows user specified configuration for various items during interpretation. Additionally, the types
2/// implementing this trait can act as custom user data within an interpreter instance, passed along to each method of
3/// this trait and host functions whenever they are invoked.
4///
5/// The default implementation of all trait methods have the least overhead, i. e. most can be optimized out fully.
6// It must always be checked that there is no additional performance penalty for the default config!
7pub trait Config {
8 /// Maximum number of values in the value stack
9 const MAX_VALUE_STACK_SIZE: usize = 0xf0000; // 64 Kibi-Values
10
11 /// Maximum number of cascading function invocations
12 const MAX_CALL_STACK_SIZE: usize = 0x1000; // 4 Kibi-Functions
13
14 /// A hook which is called before every wasm instruction
15 ///
16 /// This allows the most intricate insight into the interpreters behavior, at the cost of a
17 /// hefty performance penalty
18 #[allow(unused_variables)]
19 #[inline(always)]
20 fn instruction_hook(&mut self, bytecode: &[u8], pc: usize) {}
21}
22
23/// Default implementation of the interpreter configuration, with all hooks empty
24impl Config for () {}