diff --git a/crates/wasmi/src/engine/block_type.rs b/crates/wasmi/src/engine/block_type.rs index 8c2108885c..073eb9eb12 100644 --- a/crates/wasmi/src/engine/block_type.rs +++ b/crates/wasmi/src/engine/block_type.rs @@ -17,7 +17,7 @@ pub enum BlockTypeInner { /// A block type with no parameters and no results. Empty, /// A block type with no parameters and exactly one result. - Returns(ValueType), + Returns, /// A general block type with parameters and results. FuncType(DedupFuncType), } @@ -53,8 +53,8 @@ impl BlockType { } /// Creates a [`BlockType`] with no parameters and a single result type. - fn returns(return_type: ValueType) -> Self { - Self::from_inner(BlockTypeInner::Returns(return_type)) + fn returns(_return_type: ValueType) -> Self { + Self::from_inner(BlockTypeInner::Returns) } /// Creates a [`BlockType`] with parameters and results. @@ -63,22 +63,22 @@ impl BlockType { } /// Returns the number of parameters of the [`BlockType`]. - pub fn len_params(&self, engine: &Engine) -> u32 { + pub fn len_params(&self, engine: &Engine) -> usize { match &self.inner { - BlockTypeInner::Empty | BlockTypeInner::Returns(_) => 0, + BlockTypeInner::Empty | BlockTypeInner::Returns => 0, BlockTypeInner::FuncType(func_type) => { - engine.resolve_func_type(func_type, |func_type| func_type.params().len() as u32) + engine.resolve_func_type(func_type, |func_type| func_type.params().len()) } } } /// Returns the number of results of the [`BlockType`]. - pub fn len_results(&self, engine: &Engine) -> u32 { + pub fn len_results(&self, engine: &Engine) -> usize { match &self.inner { BlockTypeInner::Empty => 0, - BlockTypeInner::Returns(_) => 1, + BlockTypeInner::Returns => 1, BlockTypeInner::FuncType(func_type) => { - engine.resolve_func_type(func_type, |func_type| func_type.results().len() as u32) + engine.resolve_func_type(func_type, |func_type| func_type.results().len()) } } } diff --git a/crates/wasmi/src/engine/translator/control_frame.rs b/crates/wasmi/src/engine/translator/control_frame.rs index 1b33f00947..554ca8ee7f 100644 --- a/crates/wasmi/src/engine/translator/control_frame.rs +++ b/crates/wasmi/src/engine/translator/control_frame.rs @@ -108,7 +108,7 @@ impl BlockControlFrame { /// Returns an iterator over the registers holding the branching parameters of the [`BlockControlFrame`]. pub fn branch_params(&self, engine: &Engine) -> RegisterSpanIter { self.branch_params - .iter(self.block_type().len_results(engine) as usize) + .iter(self.block_type().len_results(engine)) } /// Returns the label for the branch destination of the [`BlockControlFrame`]. @@ -213,7 +213,7 @@ impl LoopControlFrame { /// Returns an iterator over the registers holding the branching parameters of the [`LoopControlFrame`]. pub fn branch_params(&self, engine: &Engine) -> RegisterSpanIter { self.branch_params - .iter(self.block_type().len_params(engine) as usize) + .iter(self.block_type().len_params(engine)) } /// Returns the label for the branch destination of the [`LoopControlFrame`]. @@ -383,7 +383,7 @@ impl IfControlFrame { /// Returns an iterator over the registers holding the branching parameters of the [`IfControlFrame`]. pub fn branch_params(&self, engine: &Engine) -> RegisterSpanIter { self.branch_params - .iter(self.block_type().len_results(engine) as usize) + .iter(self.block_type().len_results(engine)) } /// Returns the label for the branch destination of the [`IfControlFrame`]. diff --git a/crates/wasmi/src/engine/translator/visit.rs b/crates/wasmi/src/engine/translator/visit.rs index dbc37e5b62..6d9c8ab125 100644 --- a/crates/wasmi/src/engine/translator/visit.rs +++ b/crates/wasmi/src/engine/translator/visit.rs @@ -131,8 +131,8 @@ impl<'a> VisitOperator<'a> for FuncTranslator { let fuel_instr = self.fuel_instr(); let stack_height = BlockHeight::new(self.engine(), self.alloc.stack.height(), block_type)?; let end_label = self.alloc.instr_encoder.new_label(); - let len_block_params = block_type.len_params(self.engine()) as usize; - let len_branch_params = block_type.len_results(self.engine()) as usize; + let len_block_params = block_type.len_params(self.engine()); + let len_branch_params = block_type.len_results(self.engine()); let branch_params = self.alloc_branch_params(len_block_params, len_branch_params)?; self.alloc.control_stack.push_frame(BlockControlFrame::new( block_type, @@ -157,7 +157,7 @@ impl<'a> VisitOperator<'a> for FuncTranslator { return Ok(()); } // Copy `loop` parameters over to where it expects its branch parameters. - let len_block_params = block_type.len_params(self.engine()) as usize; + let len_block_params = block_type.len_params(self.engine()); self.alloc .stack .pop_n(len_block_params, &mut self.alloc.buffer.providers); @@ -210,8 +210,8 @@ impl<'a> VisitOperator<'a> for FuncTranslator { let stack_height = BlockHeight::new(self.engine(), self.alloc.stack.height(), block_type)?; self.preserve_locals()?; let end_label = self.alloc.instr_encoder.new_label(); - let len_block_params = block_type.len_params(self.engine()) as usize; - let len_branch_params = block_type.len_results(self.engine()) as usize; + let len_block_params = block_type.len_params(self.engine()); + let len_branch_params = block_type.len_results(self.engine()); let branch_params = self.alloc_branch_params(len_block_params, len_branch_params)?; let (reachability, fuel_instr) = match condition { TypedProvider::Const(condition) => {