From 9b362e3c5e355c51a0f93530a3290048648d0a50 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 4 Nov 2024 15:01:18 -0800 Subject: [PATCH] Fix how the setting is flipped --- crates/cli-flags/src/lib.rs | 5 ++++- crates/environ/src/module.rs | 4 ++-- tests/all/memory.rs | 4 ++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/crates/cli-flags/src/lib.rs b/crates/cli-flags/src/lib.rs index f45b1e59ca6..6b6ffb69258 100644 --- a/crates/cli-flags/src/lib.rs +++ b/crates/cli-flags/src/lib.rs @@ -646,7 +646,10 @@ impl CommonOptions { config.memory_reservation(max); } - if let Some(enable) = self.opts.memory_may_move.or(self.opts.static_memory_forced) { + if let Some(enable) = self.opts.static_memory_forced { + config.memory_may_move(!enable); + } + if let Some(enable) = self.opts.memory_may_move { config.memory_may_move(enable); } diff --git a/crates/environ/src/module.rs b/crates/environ/src/module.rs index 8b179b41c91..18cb2db05b4 100644 --- a/crates/environ/src/module.rs +++ b/crates/environ/src/module.rs @@ -35,7 +35,7 @@ impl MemoryStyle { && tunables.signals_based_traps && match memory.maximum_byte_size() { Ok(mut maximum) => { - if tunables.memory_may_move { + if !tunables.memory_may_move { maximum = maximum.min(tunables.memory_reservation); } @@ -51,7 +51,7 @@ impl MemoryStyle { // it's a static memory or not. It should be ok to discard the // linear memory's maximum size here as growth to the maximum // is always fallible and never guaranteed. - Err(_) => tunables.memory_may_move, + Err(_) => !tunables.memory_may_move, }; if is_static { diff --git a/tests/all/memory.rs b/tests/all/memory.rs index ece70fb170c..6c8f1c65192 100644 --- a/tests/all/memory.rs +++ b/tests/all/memory.rs @@ -421,7 +421,7 @@ fn tiny_static_heap(config: &mut Config) -> Result<()> { fn static_forced_max() -> Result<()> { let mut config = Config::new(); config.memory_reservation(5 << 16); - config.memory_may_move(true); + config.memory_may_move(false); let engine = Engine::new(&config)?; let mut store = Store::new(&engine, ()); @@ -674,7 +674,7 @@ fn init_with_negative_segment(_: &mut Config) -> Result<()> { fn non_page_aligned_static_memory() -> Result<()> { let mut config = Config::new(); config.memory_reservation(100_000); - config.memory_may_move(true); + config.memory_may_move(false); let engine = Engine::new(&config)?; let ty = MemoryType::new(1, None); Memory::new(&mut Store::new(&engine, ()), ty)?;