From 147c8f8ed7b44a171427ede7a20157ad320ba3a7 Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Wed, 20 Oct 2021 16:32:39 -0700 Subject: [PATCH] rename --- crates/runtime/src/lib.rs | 11 +++-------- crates/runtime/src/memory.rs | 12 ++++++------ crates/runtime/src/table.rs | 4 ++-- crates/wasmtime/src/store.rs | 11 +++-------- 4 files changed, 14 insertions(+), 24 deletions(-) diff --git a/crates/runtime/src/lib.rs b/crates/runtime/src/lib.rs index f9afeed984..d3aee4b75e 100644 --- a/crates/runtime/src/lib.rs +++ b/crates/runtime/src/lib.rs @@ -91,17 +91,12 @@ pub unsafe trait Store { ) -> (&mut VMExternRefActivationsTable, &dyn ModuleInfoLookup); /// Callback invoked to allow the store's resource limiter to reject a memory grow operation. - fn limiter_memory_growing( - &mut self, - current: usize, - desired: usize, - maximum: Option, - ) -> bool; + fn memory_growing(&mut self, current: usize, desired: usize, maximum: Option) -> bool; /// Callback invoked to notify the store's resource limiter that a memory grow operation has /// failed. - fn limiter_memory_grow_failed(&mut self, error: &anyhow::Error); + fn memory_grow_failed(&mut self, error: &anyhow::Error); /// Callback invoked to allow the store's resource limiter to reject a table grow operation. - fn limiter_table_growing(&mut self, current: u32, desired: u32, maximum: Option) -> bool; + fn table_growing(&mut self, current: u32, desired: u32, maximum: Option) -> bool; /// Callback invoked whenever fuel runs out by a wasm instance. If an error /// is returned that's raised as a trap. Otherwise wasm execution will diff --git a/crates/runtime/src/memory.rs b/crates/runtime/src/memory.rs index e9dde6689f..2561038b81 100644 --- a/crates/runtime/src/memory.rs +++ b/crates/runtime/src/memory.rs @@ -315,7 +315,7 @@ impl Memory { // calculation overflowed. This means that the `minimum` we're informing // the limiter is lossy and may not be 100% accurate, but for now the // expected uses of limiter means that's ok. - if !store.limiter_memory_growing(0, minimum.unwrap_or(absolute_max), maximum) { + if !store.memory_growing(0, minimum.unwrap_or(absolute_max), maximum) { bail!( "memory minimum size of {} pages exceeds memory limits", plan.memory.minimum @@ -402,14 +402,14 @@ impl Memory { let maximum = self.maximum_byte_size(); // Store limiter gets first chance to reject memory_growing. - if !store.limiter_memory_growing(old_byte_size, new_byte_size, maximum) { + if !store.memory_growing(old_byte_size, new_byte_size, maximum) { return None; } // Never exceed maximum, even if limiter permitted it. if let Some(max) = maximum { if new_byte_size > max { - store.limiter_memory_grow_failed(&format_err!("Memory maximum size exceeded")); + store.memory_grow_failed(&format_err!("Memory maximum size exceeded")); return None; } } @@ -431,7 +431,7 @@ impl Memory { } => { // Never exceed static memory size if new_byte_size > base.len() { - store.limiter_memory_grow_failed(&format_err!("static memory size exceeded")); + store.memory_grow_failed(&format_err!("static memory size exceeded")); return None; } @@ -440,13 +440,13 @@ impl Memory { base.as_mut_ptr().add(old_byte_size), new_byte_size - old_byte_size, ); - r.map_err(|e| store.limiter_memory_grow_failed(&e)).ok()?; + r.map_err(|e| store.memory_grow_failed(&e)).ok()?; *size = new_byte_size; } Memory::Dynamic(mem) => { let r = mem.grow_to(new_byte_size); - r.map_err(|e| store.limiter_memory_grow_failed(&e)).ok()?; + r.map_err(|e| store.memory_grow_failed(&e)).ok()?; } } Some(old_byte_size) diff --git a/crates/runtime/src/table.rs b/crates/runtime/src/table.rs index 690a1ed82a..c5fbfe3f67 100644 --- a/crates/runtime/src/table.rs +++ b/crates/runtime/src/table.rs @@ -168,7 +168,7 @@ impl Table { } fn limit_new(plan: &TablePlan, store: &mut dyn Store) -> Result<()> { - if !store.limiter_table_growing(0, plan.table.minimum, plan.table.maximum) { + if !store.table_growing(0, plan.table.minimum, plan.table.maximum) { bail!( "table minimum size of {} elements exceeds table limits", plan.table.minimum @@ -292,7 +292,7 @@ impl Table { let old_size = self.size(); let new_size = old_size.checked_add(delta)?; - if !store.limiter_table_growing(old_size, new_size, self.maximum()) { + if !store.table_growing(old_size, new_size, self.maximum()) { return None; } diff --git a/crates/wasmtime/src/store.rs b/crates/wasmtime/src/store.rs index 4a72c18959..644633f053 100644 --- a/crates/wasmtime/src/store.rs +++ b/crates/wasmtime/src/store.rs @@ -1526,12 +1526,7 @@ unsafe impl wasmtime_runtime::Store for StoreInner { (&mut inner.externref_activations_table, &inner.modules) } - fn limiter_memory_growing( - &mut self, - current: usize, - desired: usize, - maximum: Option, - ) -> bool { + fn memory_growing(&mut self, current: usize, desired: usize, maximum: Option) -> bool { // Need to borrow async_cx before the mut borrow of the limiter. // self.async_cx() panicks when used with a non-async store, so // wrap this in an option. @@ -1560,7 +1555,7 @@ unsafe impl wasmtime_runtime::Store for StoreInner { } } - fn limiter_memory_grow_failed(&mut self, error: &anyhow::Error) { + fn memory_grow_failed(&mut self, error: &anyhow::Error) { match self.limiter { Some(ResourceLimiterInner::Sync(ref mut limiter)) => { limiter(&mut self.data).memory_grow_failed(error) @@ -1573,7 +1568,7 @@ unsafe impl wasmtime_runtime::Store for StoreInner { } } - fn limiter_table_growing(&mut self, current: u32, desired: u32, maximum: Option) -> bool { + fn table_growing(&mut self, current: u32, desired: u32, maximum: Option) -> bool { // Need to borrow async_cx before the mut borrow of the limiter. // self.async_cx() panicks when used with a non-async store, so // wrap this in an option.