MCPcopy Create free account
hub / github.com/explodingcamera/tinywasm / run_with_fuel

Method run_with_fuel

crates/tinywasm/src/interpreter/executor.rs:1596–1614  ·  view source on GitHub ↗
(&mut self, fuel: u32)

Source from the content-addressed store, hash-verified

1594impl<'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)]

Callers 1

exec_with_fuelMethod · 0.80

Calls 1

execMethod · 0.45

Tested by

no test coverage detected