1- use core:: fmt:: Debug ;
2-
31use alloc:: sync:: Arc ;
42
53/// Global configuration for the WebAssembly interpreter
64///
75/// Can be cheaply cloned and shared across multiple executions and threads.
8- #[ derive( Clone ) ]
6+ #[ derive( Clone , Default ) ]
7+ #[ cfg_attr( feature = "debug" , derive( Debug ) ) ]
98pub struct Engine {
109 pub ( crate ) inner : Arc < EngineInner > ,
1110}
1211
13- impl Debug for Engine {
14- fn fmt ( & self , f : & mut core:: fmt:: Formatter < ' _ > ) -> core:: fmt:: Result {
15- f. debug_struct ( "Engine" ) . finish ( )
16- }
17- }
18-
1912impl Engine {
2013 /// Create a new engine with the given configuration
2114 pub fn new ( config : Config ) -> Self {
@@ -28,15 +21,10 @@ impl Engine {
2821 }
2922}
3023
31- impl Default for Engine {
32- fn default ( ) -> Engine {
33- Engine :: new ( Config :: default ( ) )
34- }
35- }
36-
24+ #[ derive( Default ) ]
25+ #[ cfg_attr( feature = "debug" , derive( Debug ) ) ]
3726pub ( crate ) struct EngineInner {
3827 pub ( crate ) config : Config ,
39- // pub(crate) allocator: Box<dyn Allocator + Send + Sync>,
4028}
4129
4230/// Fuel accounting policy for budgeted execution.
@@ -51,36 +39,36 @@ pub enum FuelPolicy {
5139 Weighted ,
5240}
5341
54- /// Default initial size for the 32-bit value stack (i32, f32 values).
55- pub const DEFAULT_VALUE_STACK_32_SIZE : usize = 64 * 1024 ; // 64k slots
42+ /// Default size for the 32-bit value stack (i32, f32 values).
43+ pub const DEFAULT_VALUE_STACK_32_SIZE : usize = 32 * 1024 ; // 32k slots
5644
57- /// Default initial size for the 64-bit value stack (i64, f64 values).
45+ /// Default size for the 64-bit value stack (i64, f64 values).
5846pub const DEFAULT_VALUE_STACK_64_SIZE : usize = 32 * 1024 ; // 32k slots
5947
60- /// Default initial size for the 128-bit value stack (v128 values).
48+ /// Default size for the 128-bit value stack (v128 values).
6149pub const DEFAULT_VALUE_STACK_128_SIZE : usize = 4 * 1024 ; // 4k slots
6250
63- /// Default initial size for the reference value stack (funcref, externref values).
51+ /// Default size for the reference value stack (funcref, externref values).
6452pub const DEFAULT_VALUE_STACK_REF_SIZE : usize = 4 * 1024 ; // 4k slots
6553
66- /// Default initial size for the call stack (function frames).
67- pub const DEFAULT_CALL_STACK_SIZE : usize = 2048 ; // 1024 frames
54+ /// Default maximum size for the call stack (function frames).
55+ pub const DEFAULT_MAX_CALL_STACK_SIZE : usize = 1024 ; // 1024 frames
6856
6957/// Configuration for the WebAssembly interpreter
7058#[ derive( Clone ) ]
7159#[ cfg_attr( feature = "debug" , derive( Debug ) ) ]
7260#[ non_exhaustive]
7361pub struct Config {
74- /// Initial size of the 32-bit value stack (i32, f32 values).
62+ /// Size of the 32-bit value stack (i32, f32 values).
7563 pub stack_32_size : usize ,
76- /// Initial size of the 64-bit value stack (i64, f64 values).
64+ /// Size of the 64-bit value stack (i64, f64 values).
7765 pub stack_64_size : usize ,
78- /// Initial size of the 128-bit value stack (v128 values).
66+ /// Size of the 128-bit value stack (v128 values).
7967 pub stack_128_size : usize ,
80- /// Initial size of the reference value stack (funcref, externref values).
68+ /// Size of the reference value stack (funcref, externref values).
8169 pub stack_ref_size : usize ,
82- /// Initial size of the call stack.
83- pub call_stack_size : usize ,
70+ /// Maximum size of the call stack
71+ pub max_call_stack_size : usize ,
8472 /// Fuel accounting policy used by budgeted execution.
8573 pub fuel_policy : FuelPolicy ,
8674}
@@ -105,7 +93,7 @@ impl Default for Config {
10593 stack_64_size : DEFAULT_VALUE_STACK_64_SIZE ,
10694 stack_128_size : DEFAULT_VALUE_STACK_128_SIZE ,
10795 stack_ref_size : DEFAULT_VALUE_STACK_REF_SIZE ,
108- call_stack_size : DEFAULT_CALL_STACK_SIZE ,
96+ max_call_stack_size : DEFAULT_MAX_CALL_STACK_SIZE ,
10997 fuel_policy : FuelPolicy :: default ( ) ,
11098 }
11199 }
0 commit comments