@@ -95,11 +95,16 @@ impl Stack {
95
95
self . operands . trunc ( height) ;
96
96
}
97
97
98
+ /// Returns `true` is fuel metering is enabled for the associated [`Engine`].
99
+ fn is_fuel_metering_enabled ( & self ) -> bool {
100
+ self . engine . config ( ) . get_consume_fuel ( )
101
+ }
102
+
98
103
/// Pushes a Wasm `block` onto the [`Stack`].
99
104
///
100
105
/// # Note
101
106
///
102
- /// If `consume_fuel` is `None` and fuel metering is enabled this will infer
107
+ /// If `consume_fuel` is `None` and fuel metering is enabled this will inherit
103
108
/// the [`Instruction::ConsumeFuel`] from the last control frame on the [`Stack`].
104
109
///
105
110
/// # Errors
@@ -113,7 +118,7 @@ impl Stack {
113
118
) -> Result < ( ) , Error > {
114
119
let len_params = usize:: from ( ty. len_params ( & self . engine ) ) ;
115
120
let block_height = self . height ( ) - len_params;
116
- let fuel_metering = self . engine . config ( ) . get_consume_fuel ( ) ;
121
+ let fuel_metering = self . is_fuel_metering_enabled ( ) ;
117
122
let consume_fuel = match consume_fuel {
118
123
None if fuel_metering => {
119
124
let consume_instr = self
@@ -151,7 +156,7 @@ impl Stack {
151
156
consume_fuel : Option < Instr > ,
152
157
mut f : impl FnMut ( Operand ) -> Result < ( ) , Error > ,
153
158
) -> Result < ( ) , Error > {
154
- debug_assert ! ( self . engine . config ( ) . get_consume_fuel ( ) == consume_fuel. is_some( ) ) ;
159
+ debug_assert ! ( self . is_fuel_metering_enabled ( ) == consume_fuel. is_some( ) ) ;
155
160
let len_params = usize:: from ( ty. len_params ( & self . engine ) ) ;
156
161
let block_height = self . height ( ) - len_params;
157
162
for depth in 0 ..block_height {
@@ -180,7 +185,7 @@ impl Stack {
180
185
reachability : IfReachability ,
181
186
consume_fuel : Option < Instr > ,
182
187
) -> Result < ( ) , Error > {
183
- debug_assert ! ( self . engine . config ( ) . get_consume_fuel ( ) == consume_fuel. is_some( ) ) ;
188
+ debug_assert ! ( self . is_fuel_metering_enabled ( ) == consume_fuel. is_some( ) ) ;
184
189
let len_params = usize:: from ( ty. len_params ( & self . engine ) ) ;
185
190
let block_height = self . height ( ) - len_params;
186
191
let else_operands = self . operands . peek ( len_params) ;
@@ -213,7 +218,7 @@ impl Stack {
213
218
is_end_of_then_reachable : bool ,
214
219
consume_fuel : Option < Instr > ,
215
220
) -> Result < ( ) , Error > {
216
- debug_assert ! ( self . engine . config ( ) . get_consume_fuel ( ) == consume_fuel. is_some( ) ) ;
221
+ debug_assert ! ( self . is_fuel_metering_enabled ( ) == consume_fuel. is_some( ) ) ;
217
222
let len_params = usize:: from ( ty. len_params ( & self . engine ) ) ;
218
223
let block_height = self . height ( ) - len_params;
219
224
let else_operands = self . controls . push_else (
0 commit comments