Skip to content

Commit

Permalink
Access and set FuelCosts
Browse files Browse the repository at this point in the history
  • Loading branch information
jayz22 committed Jun 1, 2023
1 parent 10212cf commit 1a2bc7f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
5 changes: 5 additions & 0 deletions crates/wasmi/src/engine/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,11 @@ impl Config {
self
}

pub fn set_fuel_costs(&mut self, costs: FuelCosts) -> &mut Self {
self.fuel_costs = costs;
self
}

/// Returns the [`FuelConsumptionMode`] for the [`Engine`].
///
/// Returns `None` if fuel metering is disabled for the [`Engine`].
Expand Down
3 changes: 2 additions & 1 deletion crates/wasmi/src/engine/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,8 @@ impl<'ctx, 'engine> Executor<'ctx, 'engine> {
}
}

/// Consume an amount of memory fuel specified by `delta`.
/// Consume an amount of memory fuel specified by `bytes`. The memory fuel cost
/// is always 1 per byte.
#[inline(always)]
fn consume_mem_fuel(&mut self, bytes: u64) -> Result<u64, TrapCode>
{
Expand Down
2 changes: 1 addition & 1 deletion crates/wasmi/src/engine/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ mod tests;
pub use self::{
bytecode::DropKeep,
code_map::CompiledFunc,
config::{Config, FuelConsumptionMode},
config::{Config, FuelConsumptionMode, FuelCosts},
func_builder::{
FuncBuilder,
FuncTranslatorAllocations,
Expand Down
1 change: 1 addition & 0 deletions crates/wasmi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ pub use self::{
Config,
Engine,
FuelConsumptionMode,
FuelCosts,
ResumableCall,
ResumableInvocation,
StackLimits,
Expand Down

0 comments on commit 1a2bc7f

Please sign in to comment.