Skip to content

Commit

Permalink
Fix name: engine_limits -> enforced_limits (#1079)
Browse files Browse the repository at this point in the history
fix engine_limits -> enforced_limits
  • Loading branch information
Robbepop committed Jun 20, 2024
1 parent 6820fcc commit 7783198
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion crates/wasmi/src/engine/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
22 changes: 11 additions & 11 deletions crates/wasmi/src/module/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ impl ModuleParser {
if let Some(validator) = &mut self.validator {
validator.type_section(&section)?;
}
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 {
Expand Down Expand Up @@ -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 }));
}
Expand Down Expand Up @@ -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 }));
}
Expand Down Expand Up @@ -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 }));
}
Expand Down Expand Up @@ -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 }));
}
Expand Down Expand Up @@ -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 {
Expand All @@ -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<usize>) -> 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,
Expand All @@ -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,
Expand Down Expand Up @@ -427,13 +427,13 @@ impl ModuleParser {
range: Range<usize>,
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;
Expand Down

0 comments on commit 7783198

Please sign in to comment.