Skip to content

Commit

Permalink
Fix how the setting is flipped
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcrichton committed Nov 4, 2024
1 parent 6b21001 commit 9b362e3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
5 changes: 4 additions & 1 deletion crates/cli-flags/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
4 changes: 2 additions & 2 deletions crates/environ/src/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions tests/all/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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, ());

Expand Down Expand Up @@ -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)?;
Expand Down

0 comments on commit 9b362e3

Please sign in to comment.