@@ -239,7 +239,7 @@ fn build_dag<'a>(
239
239
let target = & block_stack[ relative_depth as usize ] ;
240
240
241
241
// The stack part of the input
242
- let mut inputs = t. take_from_stack ( target. stack . len ( ) ) ;
242
+ let mut inputs = t. stack_pop_many ( target. stack . len ( ) ) ;
243
243
assert ! ( types_matches( & t. nodes, & target. stack, & inputs) ) ;
244
244
245
245
// The locals part of the input
@@ -316,7 +316,7 @@ fn build_dag<'a>(
316
316
. unwrap ( ) ;
317
317
318
318
// The stack part of the input
319
- let mut inputs = t. take_from_stack ( largest_stack. len ( ) ) ;
319
+ let mut inputs = t. stack_pop_many ( largest_stack. len ( ) ) ;
320
320
assert ! ( types_matches( & t. nodes, largest_stack, & inputs) ) ;
321
321
322
322
// The locals part of the input is the union of the locals inputs
@@ -376,7 +376,7 @@ fn build_dag<'a>(
376
376
// that consumes some inputs and produces some outputs.
377
377
Ins :: WASMOp ( op) => {
378
378
let ( inputs_types, output_types) = t. get_operator_type ( & op) . unwrap ( ) ;
379
- let inputs = t. take_from_stack ( inputs_types. len ( ) ) ;
379
+ let inputs = t. stack_pop_many ( inputs_types. len ( ) ) ;
380
380
assert ! ( types_matches( & t. nodes, & inputs_types, & inputs) ) ;
381
381
382
382
let node_idx = t. nodes . len ( ) ;
@@ -400,7 +400,7 @@ fn build_dag<'a>(
400
400
// values from the locals and the stack.
401
401
402
402
// Block inputs are the concatenation of the stack inputs and the locals inputs.
403
- let mut inputs = t. take_from_stack ( block. interface_type . ty . params ( ) . len ( ) ) ;
403
+ let mut inputs = t. stack_pop_many ( block. interface_type . ty . params ( ) . len ( ) ) ;
404
404
405
405
// Sanity check the types
406
406
assert ! ( types_matches(
@@ -645,9 +645,9 @@ impl StackTracker<'_, '_> {
645
645
node. output_types [ val_type. output_idx as usize ]
646
646
}
647
647
648
- /// Takes the last `count` elements from the stack, converts them to NodeInput,
648
+ /// Takes the last `count` elements from the end of the stack, converts them to NodeInput,
649
649
/// and truncates the stack. More efficient than split_off as it avoids one allocation.
650
- fn take_from_stack ( & mut self , count : usize ) -> Vec < NodeInput > {
650
+ fn stack_pop_many ( & mut self , count : usize ) -> Vec < NodeInput > {
651
651
let start = self . stack . len ( ) - count;
652
652
let inputs: Vec < NodeInput > = self . stack [ start..] . iter ( ) . map ( |& v| v. into ( ) ) . collect ( ) ;
653
653
self . stack . truncate ( start) ;
0 commit comments