From 7783198aeeef05801bf77bc7d9d18265c26781fd Mon Sep 17 00:00:00 2001 From: Robin Freyler Date: Thu, 20 Jun 2024 09:04:30 +0200 Subject: [PATCH] Fix name: `engine_limits` -> `enforced_limits` (#1079) fix engine_limits -> enforced_limits --- CHANGELOG.md | 2 +- crates/wasmi/src/engine/config.rs | 2 +- crates/wasmi/src/module/parser.rs | 22 +++++++++++----------- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b2260e89a..9ad80665b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -95,7 +95,7 @@ Dates in this file are formattes as `YYYY-MM-DD`. With this change they can enable this new strict mode using ```rust let mut config = wasmi::Config::default(); - config.engine_limits(wasmi::EnforcedLimits::strict()); + config.enforced_limits(wasmi::EnforcedLimits::strict()); ``` In future updates we might relax this to make `EnforcedLimits` fully customizable. - Added `EngineWeak` constructed via `Engine::weak`. (https://github.com/wasmi-labs/wasmi/pull/1003) diff --git a/crates/wasmi/src/engine/config.rs b/crates/wasmi/src/engine/config.rs index 42cac0333f..4298cc5e84 100644 --- a/crates/wasmi/src/engine/config.rs +++ b/crates/wasmi/src/engine/config.rs @@ -383,7 +383,7 @@ impl Config { /// Returns the [`EnforcedLimits`] used for the [`Engine`]. /// /// [`Engine`]: crate::Engine - pub(crate) fn get_engine_limits(&self) -> &EnforcedLimits { + pub(crate) fn get_enforced_limits(&self) -> &EnforcedLimits { &self.limits } diff --git a/crates/wasmi/src/module/parser.rs b/crates/wasmi/src/module/parser.rs index ef38277b8b..da89c9f2d7 100644 --- a/crates/wasmi/src/module/parser.rs +++ b/crates/wasmi/src/module/parser.rs @@ -109,7 +109,7 @@ impl ModuleParser { if let Some(validator) = &mut self.validator { validator.type_section(§ion)?; } - let limits = self.engine.config().get_engine_limits(); + let limits = self.engine.config().get_enforced_limits(); let func_types = section.into_iter().map(|result| { let wasmparser::Type::Func(ty) = result?; if let Some(limit) = limits.max_params { @@ -169,7 +169,7 @@ impl ModuleParser { section: FunctionSectionReader, header: &mut ModuleHeaderBuilder, ) -> Result<(), Error> { - if let Some(limit) = self.engine.config().get_engine_limits().max_functions { + if let Some(limit) = self.engine.config().get_enforced_limits().max_functions { if section.count() > limit { return Err(Error::from(EnforcedLimitsError::TooManyFunctions { limit })); } @@ -198,7 +198,7 @@ impl ModuleParser { section: TableSectionReader, header: &mut ModuleHeaderBuilder, ) -> Result<(), Error> { - if let Some(limit) = self.engine.config().get_engine_limits().max_tables { + if let Some(limit) = self.engine.config().get_enforced_limits().max_tables { if section.count() > limit { return Err(Error::from(EnforcedLimitsError::TooManyTables { limit })); } @@ -227,7 +227,7 @@ impl ModuleParser { section: MemorySectionReader, header: &mut ModuleHeaderBuilder, ) -> Result<(), Error> { - if let Some(limit) = self.engine.config().get_engine_limits().max_memories { + if let Some(limit) = self.engine.config().get_enforced_limits().max_memories { if section.count() > limit { return Err(Error::from(EnforcedLimitsError::TooManyMemories { limit })); } @@ -256,7 +256,7 @@ impl ModuleParser { section: GlobalSectionReader, header: &mut ModuleHeaderBuilder, ) -> Result<(), Error> { - if let Some(limit) = self.engine.config().get_engine_limits().max_globals { + if let Some(limit) = self.engine.config().get_enforced_limits().max_globals { if section.count() > limit { return Err(Error::from(EnforcedLimitsError::TooManyGlobals { limit })); } @@ -337,7 +337,7 @@ impl ModuleParser { if let Some(limit) = self .engine .config() - .get_engine_limits() + .get_enforced_limits() .max_element_segments { if section.count() > limit { @@ -363,7 +363,7 @@ impl ModuleParser { /// This is part of the bulk memory operations Wasm proposal and not yet supported /// by Wasmi. fn process_data_count(&mut self, count: u32, range: Range) -> Result<(), Error> { - if let Some(limit) = self.engine.config().get_engine_limits().max_data_segments { + if let Some(limit) = self.engine.config().get_enforced_limits().max_data_segments { if count > limit { return Err(Error::from(EnforcedLimitsError::TooManyDataSegments { limit, @@ -390,7 +390,7 @@ impl ModuleParser { section: DataSectionReader, builder: &mut ModuleBuilder, ) -> Result<(), Error> { - if let Some(limit) = self.engine.config().get_engine_limits().max_data_segments { + if let Some(limit) = self.engine.config().get_enforced_limits().max_data_segments { if section.count() > limit { return Err(Error::from(EnforcedLimitsError::TooManyDataSegments { limit, @@ -427,13 +427,13 @@ impl ModuleParser { range: Range, size: u32, ) -> Result<(), Error> { - let engine_limits = self.engine.config().get_engine_limits(); - if let Some(limit) = engine_limits.max_functions { + let enforced_limits = self.engine.config().get_enforced_limits(); + if let Some(limit) = enforced_limits.max_functions { if count > limit { return Err(Error::from(EnforcedLimitsError::TooManyFunctions { limit })); } } - if let Some(limit) = engine_limits.min_avg_bytes_per_function { + if let Some(limit) = enforced_limits.min_avg_bytes_per_function { if size >= limit.req_funcs_bytes { let limit = limit.min_avg_bytes_per_function; let avg = size / count;