diff --git a/crates/c-api/include/wasmtime/config.h b/crates/c-api/include/wasmtime/config.h index e7f8ecc91065..2130d4ff6c91 100644 --- a/crates/c-api/include/wasmtime/config.h +++ b/crates/c-api/include/wasmtime/config.h @@ -334,20 +334,12 @@ WASMTIME_CONFIG_PROP(void, static_memory_forced, bool) WASMTIME_CONFIG_PROP(void, static_memory_maximum_size, uint64_t) /** - * \brief Configures the guard region size for "static" memory. + * \brief Configures the guard region size for linear memory. * * For more information see the Rust documentation at - * https://bytecodealliance.github.io/wasmtime/api/wasmtime/struct.Config.html#method.static_memory_guard_size. + * https://bytecodealliance.github.io/wasmtime/api/wasmtime/struct.Config.html#method.memory_guard_size. */ -WASMTIME_CONFIG_PROP(void, static_memory_guard_size, uint64_t) - -/** - * \brief Configures the guard region size for "dynamic" memory. - * - * For more information see the Rust documentation at - * https://bytecodealliance.github.io/wasmtime/api/wasmtime/struct.Config.html#method.dynamic_memory_guard_size. - */ -WASMTIME_CONFIG_PROP(void, dynamic_memory_guard_size, uint64_t) +WASMTIME_CONFIG_PROP(void, memory_guard_size, uint64_t) /** * \brief Configures the size, in bytes, of the extra virtual memory space diff --git a/crates/c-api/src/config.rs b/crates/c-api/src/config.rs index 27035283e8c3..f2c149d29076 100644 --- a/crates/c-api/src/config.rs +++ b/crates/c-api/src/config.rs @@ -232,13 +232,8 @@ pub extern "C" fn wasmtime_config_static_memory_maximum_size_set(c: &mut wasm_co } #[no_mangle] -pub extern "C" fn wasmtime_config_static_memory_guard_size_set(c: &mut wasm_config_t, size: u64) { - c.config.static_memory_guard_size(size); -} - -#[no_mangle] -pub extern "C" fn wasmtime_config_dynamic_memory_guard_size_set(c: &mut wasm_config_t, size: u64) { - c.config.dynamic_memory_guard_size(size); +pub extern "C" fn wasmtime_config_memory_guard_size_set(c: &mut wasm_config_t, size: u64) { + c.config.memory_guard_size(size); } #[no_mangle] diff --git a/crates/cli-flags/src/lib.rs b/crates/cli-flags/src/lib.rs index 8251379aaea8..746302699f97 100644 --- a/crates/cli-flags/src/lib.rs +++ b/crates/cli-flags/src/lib.rs @@ -42,9 +42,6 @@ wasmtime_option_group! { /// Optimization level of generated code (0-2, s; default: 2) pub opt_level: Option, - /// Byte size of the guard region after dynamic memories are allocated - pub dynamic_memory_guard_size: Option, - /// Force using a "static" style for all wasm memories pub static_memory_forced: Option, @@ -52,8 +49,8 @@ wasmtime_option_group! { /// relocatable instead of up-front-reserved. pub static_memory_maximum_size: Option, - /// Byte size of the guard region after static memories are allocated - pub static_memory_guard_size: Option, + /// Size, in bytes, of guard pages for linear memories. + pub memory_guard_size: Option, /// Bytes to reserve at the end of linear memory for growth for dynamic /// memories. @@ -167,6 +164,12 @@ wasmtime_option_group! { /// Enable or disable the use of host signal handlers for traps. pub signals_based_traps: Option, + + /// DEPRECATED: Use `-Cmemory-guard-size=N` instead. + pub dynamic_memory_guard_size: Option, + + /// DEPRECATED: Use `-Cmemory-guard-size=N` instead. + pub static_memory_guard_size: Option, } enum Optimize { @@ -636,13 +639,15 @@ impl CommonOptions { config.static_memory_forced(enable); } - if let Some(size) = self.opts.static_memory_guard_size { - config.static_memory_guard_size(size); + if let Some(size) = self + .opts + .static_memory_guard_size + .or(self.opts.dynamic_memory_guard_size) + .or(self.opts.memory_guard_size) + { + config.memory_guard_size(size); } - if let Some(size) = self.opts.dynamic_memory_guard_size { - config.dynamic_memory_guard_size(size); - } if let Some(size) = self.opts.dynamic_memory_reserved_for_growth { config.dynamic_memory_reserved_for_growth(size); } diff --git a/crates/environ/src/module.rs b/crates/environ/src/module.rs index 3cbac867ac7e..176e9dd30f1f 100644 --- a/crates/environ/src/module.rs +++ b/crates/environ/src/module.rs @@ -58,7 +58,7 @@ impl MemoryStyle { Self::Static { byte_reservation: tunables.static_memory_reservation, }, - tunables.static_memory_offset_guard_size, + tunables.memory_guard_size, ); } @@ -67,7 +67,7 @@ impl MemoryStyle { Self::Dynamic { reserve: tunables.dynamic_memory_growth_reserve, }, - tunables.dynamic_memory_offset_guard_size, + tunables.memory_guard_size, ) } } diff --git a/crates/environ/src/tunables.rs b/crates/environ/src/tunables.rs index dec38a8b70ba..142b9c172ea0 100644 --- a/crates/environ/src/tunables.rs +++ b/crates/environ/src/tunables.rs @@ -15,11 +15,8 @@ pub struct Tunables { /// the heap. pub static_memory_reservation: u64, - /// The size in bytes of the offset guard for static heaps. - pub static_memory_offset_guard_size: u64, - - /// The size in bytes of the offset guard for dynamic heaps. - pub dynamic_memory_offset_guard_size: u64, + /// The size, in bytes, of the guard page region for linear memories. + pub memory_guard_size: u64, /// The size, in bytes, of reserved memory at the end of a "dynamic" memory, /// before the guard page, that memory can grow into. This is intended to @@ -108,8 +105,7 @@ impl Tunables { // No virtual memory tricks are available on miri so make these // limits quite conservative. static_memory_reservation: 1 << 20, - static_memory_offset_guard_size: 0, - dynamic_memory_offset_guard_size: 0, + memory_guard_size: 0, dynamic_memory_growth_reserve: 0, // General options which have the same defaults regardless of @@ -136,8 +132,7 @@ impl Tunables { // impacts performance severely but allows us to have more than a // few instances running around. static_memory_reservation: 10 * (1 << 20), - static_memory_offset_guard_size: 0x1_0000, - dynamic_memory_offset_guard_size: 0x1_0000, + memory_guard_size: 0x1_0000, dynamic_memory_growth_reserve: 1 << 20, // 1MB ..Tunables::default_miri() @@ -154,13 +149,7 @@ impl Tunables { // Coupled with a 2 GiB address space guard it lets us translate // wasm offsets into x86 offsets as aggressively as we can. static_memory_reservation: 1 << 32, - static_memory_offset_guard_size: 0x8000_0000, - - // Size in bytes of the offset guard for dynamic memories. - // - // Allocate a small guard to optimize common cases but without - // wasting too much memory. - dynamic_memory_offset_guard_size: 0x1_0000, + memory_guard_size: 0x8000_0000, // We've got lots of address space on 64-bit so use a larger // grow-into-this area, but on 32-bit we aren't as lucky. Miri is diff --git a/crates/fuzzing/src/generators/config.rs b/crates/fuzzing/src/generators/config.rs index 1791d1f37f1c..1f79cda5a473 100644 --- a/crates/fuzzing/src/generators/config.rs +++ b/crates/fuzzing/src/generators/config.rs @@ -267,8 +267,7 @@ impl Config { let memory_config = if pcc { MemoryConfig::Normal(NormalMemoryConfig { static_memory_maximum_size: Some(4 << 30), // 4 GiB - static_memory_guard_size: Some(2 << 30), // 2 GiB - dynamic_memory_guard_size: Some(0), + memory_guard_size: Some(2 << 30), // 2 GiB dynamic_memory_reserved_for_growth: Some(0), guard_before_linear_memory: false, memory_init_cow: true, @@ -286,9 +285,8 @@ impl Config { MemoryConfig::CustomUnaligned => { cfg.with_host_memory(Arc::new(UnalignedMemoryCreator)) .static_memory_maximum_size(0) - .dynamic_memory_guard_size(0) + .memory_guard_size(0) .dynamic_memory_reserved_for_growth(0) - .static_memory_guard_size(0) .guard_before_linear_memory(false) .memory_init_cow(false); } diff --git a/crates/fuzzing/src/generators/memory.rs b/crates/fuzzing/src/generators/memory.rs index 282adc3dc964..d6eb7554f3bf 100644 --- a/crates/fuzzing/src/generators/memory.rs +++ b/crates/fuzzing/src/generators/memory.rs @@ -136,8 +136,7 @@ pub enum MemoryConfig { #[allow(missing_docs)] pub struct NormalMemoryConfig { pub static_memory_maximum_size: Option, - pub static_memory_guard_size: Option, - pub dynamic_memory_guard_size: Option, + pub memory_guard_size: Option, pub dynamic_memory_reserved_for_growth: Option, pub guard_before_linear_memory: bool, pub cranelift_enable_heap_access_spectre_mitigations: Option, @@ -148,23 +147,15 @@ impl<'a> Arbitrary<'a> for NormalMemoryConfig { fn arbitrary(u: &mut Unstructured<'a>) -> arbitrary::Result { // This attempts to limit memory and guard sizes to 32-bit ranges so // we don't exhaust a 64-bit address space easily. - let mut ret = Self { + Ok(Self { static_memory_maximum_size: as Arbitrary>::arbitrary(u)?.map(Into::into), - static_memory_guard_size: as Arbitrary>::arbitrary(u)?.map(Into::into), - dynamic_memory_guard_size: as Arbitrary>::arbitrary(u)?.map(Into::into), + memory_guard_size: as Arbitrary>::arbitrary(u)?.map(Into::into), dynamic_memory_reserved_for_growth: as Arbitrary>::arbitrary(u)? .map(Into::into), guard_before_linear_memory: u.arbitrary()?, cranelift_enable_heap_access_spectre_mitigations: u.arbitrary()?, memory_init_cow: u.arbitrary()?, - }; - - if let Some(dynamic) = ret.dynamic_memory_guard_size { - let statik = ret.static_memory_guard_size.unwrap_or(2 << 30); - ret.static_memory_guard_size = Some(statik.max(dynamic)); - } - - Ok(ret) + }) } } @@ -173,8 +164,7 @@ impl NormalMemoryConfig { pub fn apply_to(&self, config: &mut wasmtime::Config) { config .static_memory_maximum_size(self.static_memory_maximum_size.unwrap_or(0)) - .static_memory_guard_size(self.static_memory_guard_size.unwrap_or(0)) - .dynamic_memory_guard_size(self.dynamic_memory_guard_size.unwrap_or(0)) + .memory_guard_size(self.memory_guard_size.unwrap_or(0)) .dynamic_memory_reserved_for_growth( self.dynamic_memory_reserved_for_growth.unwrap_or(0), ) diff --git a/crates/misc/component-test-util/src/lib.rs b/crates/misc/component-test-util/src/lib.rs index 9f463a7ffac9..c5f42b874f1c 100644 --- a/crates/misc/component-test-util/src/lib.rs +++ b/crates/misc/component-test-util/src/lib.rs @@ -56,7 +56,7 @@ pub fn config() -> Config { // try to cut down on virtual memory usage by avoiding 4G reservations. if std::env::var("WASMTIME_TEST_NO_HOG_MEMORY").is_ok() { config.static_memory_maximum_size(0); - config.dynamic_memory_guard_size(0); + config.memory_guard_size(0); } config } diff --git a/crates/wasmtime/src/config.rs b/crates/wasmtime/src/config.rs index aad07ca3fa50..1d051415edea 100644 --- a/crates/wasmtime/src/config.rs +++ b/crates/wasmtime/src/config.rs @@ -148,8 +148,7 @@ pub struct Config { #[derive(Default, Clone)] struct ConfigTunables { static_memory_reservation: Option, - static_memory_offset_guard_size: Option, - dynamic_memory_offset_guard_size: Option, + memory_guard_size: Option, dynamic_memory_growth_reserve: Option, generate_native_debuginfo: Option, parse_wasm_debuginfo: Option, @@ -1305,7 +1304,7 @@ impl Config { /// When using the pooling instance allocation strategy, all linear memories /// will be created as "static" and the /// [`Config::static_memory_maximum_size`] and - /// [`Config::static_memory_guard_size`] options will be used to configure + /// [`Config::memory_guard_size`] options will be used to configure /// the virtual memory allocations of linear memories. pub fn allocation_strategy(&mut self, strategy: InstanceAllocationStrategy) -> &mut Self { self.allocation_strategy = strategy; @@ -1426,7 +1425,7 @@ impl Config { } /// Configures the size, in bytes, of the guard region used at the end of a - /// static memory's address space reservation. + /// linear memory's address space reservation. /// /// > Note: this value has important performance ramifications, be sure to /// > understand what this value does before tweaking it and benchmarking. @@ -1437,16 +1436,12 @@ impl Config { /// Accelerating these memory accesses is the motivation for a guard after a /// memory allocation. /// - /// Memories (both static and dynamic) can be configured with a guard at the - /// end of them which consists of unmapped virtual memory. This unmapped - /// memory will trigger a memory access violation (e.g. segfault) if - /// accessed. This allows JIT code to elide bounds checks if it can prove - /// that an access, if out of bounds, would hit the guard region. This means - /// that having such a guard of unmapped memory can remove the need for - /// bounds checks in JIT code. - /// - /// For the difference between static and dynamic memories, see the - /// [`Config::static_memory_maximum_size`]. + /// Memories can be configured with a guard at the end of them which + /// consists of unmapped virtual memory. This unmapped memory will trigger + /// a memory access violation (e.g. segfault) if accessed. This allows JIT + /// code to elide bounds checks if it can prove that an access, if out of + /// bounds, would hit the guard region. This means that having such a guard + /// of unmapped memory can remove the need for bounds checks in JIT code. /// /// ## How big should the guard be? /// @@ -1470,45 +1465,8 @@ impl Config { /// allows eliminating almost all bounds checks on loads/stores with an /// immediate offset of less than 2GB. On 32-bit platforms this defaults to /// 64KB. - /// - /// ## Errors - /// - /// The `Engine::new` method will return an error if this option is smaller - /// than the value configured for [`Config::dynamic_memory_guard_size`]. - pub fn static_memory_guard_size(&mut self, guard_size: u64) -> &mut Self { - self.tunables.static_memory_offset_guard_size = Some(guard_size); - self - } - - /// Configures the size, in bytes, of the guard region used at the end of a - /// dynamic memory's address space reservation. - /// - /// For the difference between static and dynamic memories, see the - /// [`Config::static_memory_maximum_size`] - /// - /// For more information about what a guard is, see the documentation on - /// [`Config::static_memory_guard_size`]. - /// - /// Note that the size of the guard region for dynamic memories is not super - /// critical for performance. Making it reasonably-sized can improve - /// generated code slightly, but for maximum performance you'll want to lean - /// towards static memories rather than dynamic anyway. - /// - /// Also note that the dynamic memory guard size must be smaller than the - /// static memory guard size, so if a large dynamic memory guard is - /// specified then the static memory guard size will also be automatically - /// increased. - /// - /// ## Default - /// - /// This value defaults to 64KB. - /// - /// ## Errors - /// - /// The `Engine::new` method will return an error if this option is larger - /// than the value configured for [`Config::static_memory_guard_size`]. - pub fn dynamic_memory_guard_size(&mut self, guard_size: u64) -> &mut Self { - self.tunables.dynamic_memory_offset_guard_size = Some(guard_size); + pub fn memory_guard_size(&mut self, guard_size: u64) -> &mut Self { + self.tunables.memory_guard_size = Some(guard_size); self } @@ -1974,8 +1932,7 @@ impl Config { set_fields! { static_memory_reservation - static_memory_offset_guard_size - dynamic_memory_offset_guard_size + memory_guard_size dynamic_memory_growth_reserve generate_native_debuginfo parse_wasm_debuginfo @@ -2012,10 +1969,6 @@ impl Config { None }; - if tunables.static_memory_offset_guard_size < tunables.dynamic_memory_offset_guard_size { - bail!("static memory guard size cannot be smaller than dynamic memory guard size"); - } - Ok((tunables, features)) } @@ -2392,11 +2345,8 @@ impl fmt::Debug for Config { if let Some(size) = self.tunables.static_memory_reservation { f.field("static_memory_maximum_reservation", &size); } - if let Some(size) = self.tunables.static_memory_offset_guard_size { - f.field("static_memory_guard_size", &size); - } - if let Some(size) = self.tunables.dynamic_memory_offset_guard_size { - f.field("dynamic_memory_guard_size", &size); + if let Some(size) = self.tunables.memory_guard_size { + f.field("memory_guard_size", &size); } if let Some(enable) = self.tunables.guard_before_linear_memory { f.field("guard_before_linear_memory", &enable); diff --git a/crates/wasmtime/src/engine/serialization.rs b/crates/wasmtime/src/engine/serialization.rs index 2b45480a34c5..1c1818b102c2 100644 --- a/crates/wasmtime/src/engine/serialization.rs +++ b/crates/wasmtime/src/engine/serialization.rs @@ -365,8 +365,7 @@ impl Metadata<'_> { let Tunables { collector, static_memory_reservation, - static_memory_offset_guard_size, - dynamic_memory_offset_guard_size, + memory_guard_size, generate_native_debuginfo, parse_wasm_debuginfo, consume_fuel, @@ -397,14 +396,9 @@ impl Metadata<'_> { "static memory reservation", )?; Self::check_int( - static_memory_offset_guard_size, - other.static_memory_offset_guard_size, - "static memory guard size", - )?; - Self::check_int( - dynamic_memory_offset_guard_size, - other.dynamic_memory_offset_guard_size, - "dynamic memory guard size", + memory_guard_size, + other.memory_guard_size, + "memory guard size", )?; Self::check_bool( generate_native_debuginfo, @@ -722,11 +716,11 @@ Caused by: let engine = Engine::default(); let mut metadata = Metadata::new(&engine); - metadata.tunables.static_memory_offset_guard_size = 0; + metadata.tunables.memory_guard_size = 0; match metadata.check_compatible(&engine) { Ok(_) => unreachable!(), - Err(e) => assert_eq!(e.to_string(), "Module was compiled with a static memory guard size of '0' but '2147483648' is expected for the host"), + Err(e) => assert_eq!(e.to_string(), "Module was compiled with a memory guard size of '0' but '2147483648' is expected for the host"), } Ok(()) diff --git a/crates/wasmtime/src/runtime/memory.rs b/crates/wasmtime/src/runtime/memory.rs index 45a51132482f..8450e388443b 100644 --- a/crates/wasmtime/src/runtime/memory.rs +++ b/crates/wasmtime/src/runtime/memory.rs @@ -1048,8 +1048,7 @@ mod tests { #[test] fn respect_tunables() { let mut cfg = Config::new(); - cfg.static_memory_maximum_size(0) - .dynamic_memory_guard_size(0); + cfg.static_memory_maximum_size(0).memory_guard_size(0); let mut store = Store::new(&Engine::new(&cfg).unwrap(), ()); let ty = MemoryType::new(1, None); let mem = Memory::new(&mut store, ty).unwrap(); diff --git a/crates/wasmtime/src/runtime/vm/instance/allocator/pooling/memory_pool.rs b/crates/wasmtime/src/runtime/vm/instance/allocator/pooling/memory_pool.rs index 5535d0153fd2..dfa6c5c4deaa 100644 --- a/crates/wasmtime/src/runtime/vm/instance/allocator/pooling/memory_pool.rs +++ b/crates/wasmtime/src/runtime/vm/instance/allocator/pooling/memory_pool.rs @@ -561,7 +561,7 @@ impl SlabConstraints { let expected_slot_bytes = round_usize_up_to_host_pages(expected_slot_bytes)?; let guard_bytes: usize = tunables - .static_memory_offset_guard_size + .memory_guard_size .try_into() .context("guard region is too large")?; let guard_bytes = round_usize_up_to_host_pages(guard_bytes)?; @@ -592,7 +592,7 @@ struct SlabLayout { /// guard region after the memory to catch OOB access. On these guard /// regions, note that: /// - users can configure how aggressively (or not) to elide bounds checks - /// via `Config::static_memory_guard_size` (see also: + /// via `Config::memory_guard_size` (see also: /// `memory_and_guard_size`) /// - memory protection keys can compress the size of the guard region by /// placing slots from a different key (i.e., a stripe) in the guard @@ -770,7 +770,7 @@ mod tests { }, &Tunables { static_memory_reservation: WASM_PAGE_SIZE as u64, - static_memory_offset_guard_size: 0, + memory_guard_size: 0, ..Tunables::default_host() }, )?; diff --git a/examples/mpk.rs b/examples/mpk.rs index 232160b151dd..74a708bc120b 100644 --- a/examples/mpk.rs +++ b/examples/mpk.rs @@ -75,10 +75,10 @@ struct Args { static_memory_maximum_size: Option, /// The size in bytes of the guard region to expect between static memory - /// slots; see [`Config::static_memory_guard_size`] for more details and the + /// slots; see [`Config::memory_guard_size`] for more details and the /// default value if unset. #[arg(long, value_parser = parse_byte_size)] - static_memory_guard_size: Option, + memory_guard_size: Option, } /// Parse a human-readable byte size--e.g., "512 MiB"--into the correct number @@ -195,8 +195,8 @@ fn build_engine(args: &Args, num_memories: u32, enable_mpk: MpkEnabled) -> Resul if let Some(static_memory_maximum_size) = args.static_memory_maximum_size { config.static_memory_maximum_size(static_memory_maximum_size); } - if let Some(static_memory_guard_size) = args.static_memory_guard_size { - config.static_memory_guard_size(static_memory_guard_size); + if let Some(memory_guard_size) = args.memory_guard_size { + config.memory_guard_size(memory_guard_size); } config.allocation_strategy(InstanceAllocationStrategy::Pooling(pool)); diff --git a/tests/all/async_functions.rs b/tests/all/async_functions.rs index 790d32b699b9..ae3973b9bb6a 100644 --- a/tests/all/async_functions.rs +++ b/tests/all/async_functions.rs @@ -352,8 +352,7 @@ async fn async_with_pooling_stacks() { let mut config = Config::new(); config.async_support(true); config.allocation_strategy(InstanceAllocationStrategy::Pooling(pool)); - config.dynamic_memory_guard_size(0); - config.static_memory_guard_size(0); + config.memory_guard_size(0); config.static_memory_maximum_size(1 << 16); let engine = Engine::new(&config).unwrap(); @@ -377,8 +376,7 @@ async fn async_host_func_with_pooling_stacks() -> Result<()> { let mut config = Config::new(); config.async_support(true); config.allocation_strategy(InstanceAllocationStrategy::Pooling(pooling)); - config.dynamic_memory_guard_size(0); - config.static_memory_guard_size(0); + config.memory_guard_size(0); config.static_memory_maximum_size(1 << 16); let mut store = Store::new(&Engine::new(&config)?, ()); diff --git a/tests/all/memory.rs b/tests/all/memory.rs index 91865bfdb5b2..16dbd1d6e375 100644 --- a/tests/all/memory.rs +++ b/tests/all/memory.rs @@ -101,8 +101,7 @@ fn offsets_static_dynamic_oh_my(config: &mut Config) -> Result<()> { for &guard_size in sizes.iter() { for &guard_before_linear_memory in [true, false].iter() { config.static_memory_maximum_size(static_memory_maximum_size); - config.dynamic_memory_guard_size(guard_size); - config.static_memory_guard_size(guard_size); + config.memory_guard_size(guard_size); config.guard_before_linear_memory(guard_before_linear_memory); config.cranelift_debug_verifier(true); engines.push(Engine::new(&config)?); @@ -141,8 +140,7 @@ fn guards_present() -> Result<()> { let mut config = Config::new(); config.static_memory_maximum_size(1 << 20); - config.dynamic_memory_guard_size(GUARD_SIZE); - config.static_memory_guard_size(GUARD_SIZE); + config.memory_guard_size(GUARD_SIZE); config.guard_before_linear_memory(true); let engine = Engine::new(&config)?; let mut store = Store::new(&engine, ()); @@ -193,8 +191,7 @@ fn guards_present_pooling(config: &mut Config) -> Result<()> { .max_memory_size(10 << 16) .memory_protection_keys(MpkEnabled::Disable); config.static_memory_maximum_size(1 << 20); - config.dynamic_memory_guard_size(GUARD_SIZE); - config.static_memory_guard_size(GUARD_SIZE); + config.memory_guard_size(GUARD_SIZE); config.guard_before_linear_memory(true); config.allocation_strategy(InstanceAllocationStrategy::Pooling(pool)); let engine = Engine::new(&config)?; @@ -255,8 +252,7 @@ fn guards_present_pooling_mpk(config: &mut Config) -> Result<()> { .memory_protection_keys(MpkEnabled::Enable) .max_memory_protection_keys(2); config.static_memory_maximum_size(1 << 20); - config.dynamic_memory_guard_size(GUARD_SIZE); - config.static_memory_guard_size(GUARD_SIZE); + config.memory_guard_size(GUARD_SIZE); config.guard_before_linear_memory(true); config.allocation_strategy(InstanceAllocationStrategy::Pooling(pool)); let engine = Engine::new(&config)?; diff --git a/tests/all/memory_creator.rs b/tests/all/memory_creator.rs index 69db3417375c..5829f5b0e372 100644 --- a/tests/all/memory_creator.rs +++ b/tests/all/memory_creator.rs @@ -130,7 +130,7 @@ mod not_for_windows { config .with_host_memory(mem_creator.clone()) .static_memory_maximum_size(0) - .dynamic_memory_guard_size(0); + .memory_guard_size(0); (Store::new(&Engine::new(&config).unwrap(), ()), mem_creator) } diff --git a/tests/all/pooling_allocator.rs b/tests/all/pooling_allocator.rs index fc6e98da74d5..47fee2fec88d 100644 --- a/tests/all/pooling_allocator.rs +++ b/tests/all/pooling_allocator.rs @@ -6,8 +6,7 @@ fn successful_instantiation() -> Result<()> { let pool = crate::small_pool_config(); let mut config = Config::new(); config.allocation_strategy(InstanceAllocationStrategy::Pooling(pool)); - config.dynamic_memory_guard_size(0); - config.static_memory_guard_size(0); + config.memory_guard_size(0); config.static_memory_maximum_size(1 << 16); let engine = Engine::new(&config)?; @@ -27,8 +26,7 @@ fn memory_limit() -> Result<()> { pool.max_memory_size(3 << 16); let mut config = Config::new(); config.allocation_strategy(InstanceAllocationStrategy::Pooling(pool)); - config.dynamic_memory_guard_size(0); - config.static_memory_guard_size(1 << 16); + config.memory_guard_size(1 << 16); config.static_memory_maximum_size(3 << 16); config.wasm_multi_memory(true); @@ -201,8 +199,7 @@ fn memory_zeroed() -> Result<()> { pool.max_memory_size(1 << 16).table_elements(0); let mut config = Config::new(); config.allocation_strategy(InstanceAllocationStrategy::Pooling(pool)); - config.dynamic_memory_guard_size(0); - config.static_memory_guard_size(0); + config.memory_guard_size(0); config.static_memory_maximum_size(1 << 16); let engine = Engine::new(&config)?; @@ -239,8 +236,7 @@ fn table_limit() -> Result<()> { pool.table_elements(TABLE_ELEMENTS); let mut config = Config::new(); config.allocation_strategy(InstanceAllocationStrategy::Pooling(pool)); - config.dynamic_memory_guard_size(0); - config.static_memory_guard_size(0); + config.memory_guard_size(0); config.static_memory_maximum_size(1 << 16); let engine = Engine::new(&config)?; @@ -375,8 +371,7 @@ fn table_zeroed() -> Result<()> { let pool = crate::small_pool_config(); let mut config = Config::new(); config.allocation_strategy(InstanceAllocationStrategy::Pooling(pool)); - config.dynamic_memory_guard_size(0); - config.static_memory_guard_size(0); + config.memory_guard_size(0); config.static_memory_maximum_size(1 << 16); let engine = Engine::new(&config)?; @@ -411,8 +406,7 @@ fn total_core_instances_limit() -> Result<()> { pool.total_core_instances(INSTANCE_LIMIT); let mut config = Config::new(); config.allocation_strategy(InstanceAllocationStrategy::Pooling(pool)); - config.dynamic_memory_guard_size(0); - config.static_memory_guard_size(0); + config.memory_guard_size(0); config.static_memory_maximum_size(1 << 16); let engine = Engine::new(&config)?; @@ -702,7 +696,7 @@ fn dynamic_memory_pooling_allocator() -> Result<()> { pool.max_memory_size(max_size as usize); let mut config = Config::new(); config.static_memory_maximum_size(max_size); - config.dynamic_memory_guard_size(guard_size); + config.memory_guard_size(guard_size); config.allocation_strategy(InstanceAllocationStrategy::Pooling(pool)); let engine = Engine::new(&config)?; diff --git a/tests/pcc_memory.rs b/tests/pcc_memory.rs index dd54cf02b34a..7b6e3e58d30d 100644 --- a/tests/pcc_memory.rs +++ b/tests/pcc_memory.rs @@ -87,8 +87,7 @@ mod pcc_memory_tests { ); let mut cfg = Config::new(); cfg.static_memory_maximum_size(static_memory_maximum_size); - cfg.static_memory_guard_size(guard_size); - cfg.dynamic_memory_guard_size(guard_size); + cfg.memory_guard_size(guard_size); cfg.cranelift_pcc(true); unsafe { cfg.cranelift_flag_set( diff --git a/tests/wast.rs b/tests/wast.rs index 4bb0735d70cf..dc92dcc4df5f 100644 --- a/tests/wast.rs +++ b/tests/wast.rs @@ -367,8 +367,7 @@ fn run_wast(wast: &Path, config: WastConfig) -> anyhow::Result<()> { cfg.dynamic_memory_reserved_for_growth(0); let small_guard = 64 * 1024; - cfg.static_memory_guard_size(small_guard); - cfg.dynamic_memory_guard_size(small_guard); + cfg.memory_guard_size(small_guard); } let _pooling_lock = if config.pooling { @@ -393,8 +392,7 @@ fn run_wast(wast: &Path, config: WastConfig) -> anyhow::Result<()> { if multi_memory { cfg.static_memory_maximum_size(max_memory_size as u64); cfg.dynamic_memory_reserved_for_growth(0); - cfg.static_memory_guard_size(0); - cfg.dynamic_memory_guard_size(0); + cfg.memory_guard_size(0); } // The limits here are crafted such that the wast tests should pass.