| 1594 | impl<'store> Executor<'store, true> { |
| 1595 | #[inline(always)] |
| 1596 | pub(crate) fn run_with_fuel(&mut self, fuel: u32) -> Result<ExecState, Trap> { |
| 1597 | self.store.execution_fuel = fuel; |
| 1598 | if self.store.execution_fuel == 0 { |
| 1599 | return Ok(ExecState::Suspended(self.cf)); |
| 1600 | } |
| 1601 | |
| 1602 | loop { |
| 1603 | for _ in 0..128 { |
| 1604 | if self.exec()?.is_some() { |
| 1605 | return Ok(ExecState::Completed); |
| 1606 | } |
| 1607 | } |
| 1608 | |
| 1609 | self.store.execution_fuel = self.store.execution_fuel.saturating_sub(128); |
| 1610 | if self.store.execution_fuel == 0 { |
| 1611 | return Ok(ExecState::Suspended(self.cf)); |
| 1612 | } |
| 1613 | } |
| 1614 | } |
| 1615 | } |
| 1616 | |
| 1617 | #[inline(always)] |