(&self, block_id: BlockId, cfg: &dyn ControlFlowGraph)
| 42 | } |
| 43 | |
| 44 | fn verify_block(&self, block_id: BlockId, cfg: &dyn ControlFlowGraph) -> PartialVMResult<()> { |
| 45 | let code = &self.code.code; |
| 46 | let mut stack_size_increment = 0; |
| 47 | let block_start = cfg.block_start(block_id); |
| 48 | for i in block_start..=cfg.block_end(block_id) { |
| 49 | let (num_pops, num_pushes) = self.instruction_effect(&code[i as usize])?; |
| 50 | // Check that the stack height is sufficient to accommodate the number |
| 51 | // of pops this instruction does |
| 52 | if stack_size_increment < num_pops { |
| 53 | return Err( |
| 54 | PartialVMError::new(StatusCode::NEGATIVE_STACK_SIZE_WITHIN_BLOCK) |
| 55 | .at_code_offset(self.current_function(), block_start), |
| 56 | ); |
| 57 | } |
| 58 | stack_size_increment -= num_pops; |
| 59 | stack_size_increment += num_pushes; |
| 60 | } |
| 61 | |
| 62 | if stack_size_increment == 0 { |
| 63 | Ok(()) |
| 64 | } else { |
| 65 | Err( |
| 66 | PartialVMError::new(StatusCode::POSITIVE_STACK_SIZE_AT_BLOCK_END) |
| 67 | .at_code_offset(self.current_function(), block_start), |
| 68 | ) |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | /// The effect of an instruction is a tuple where the first element |
| 73 | /// is the number of pops it does, and the second element is the number |
no test coverage detected