Add a configuration option to force "static" memories (#3503)

* Add a configuration option to force "static" memories

In poking around at some things earlier today I realized that one
configuration option for memories we haven't exposed from embeddings
like the CLI is to forcibly limit the size of memory growth and force
using a static memory style. This means that the CLI, for example, can't
limit memory growth by default and memories are only limited in size by
what the OS can give and the wasm's own memory type. This configuration
option means that the CLI can artificially limit the size of wasm linear
memories.

Additionally another motivation for this is for testing out various
codegen ramifications of static/dynamic memories. This is the only way
to force a static memory, by default, for wasm64 memories with no
maximum size listed for example.

* Review feedback
This commit is contained in:
Alex Crichton
2021-11-03 16:50:49 -05:00
committed by GitHub
parent 6428ac80d0
commit 6bcee7f5f7
4 changed files with 49 additions and 5 deletions

View File

@@ -244,6 +244,10 @@ struct CommonOptions {
#[structopt(long, value_name = "MAXIMUM")]
static_memory_maximum_size: Option<u64>,
/// Force using a "static" style for all wasm memories.
#[structopt(long)]
static_memory_forced: bool,
/// Byte size of the guard region after static memories are allocated.
#[structopt(long, value_name = "SIZE")]
static_memory_guard_size: Option<u64>,
@@ -319,6 +323,8 @@ impl CommonOptions {
config.static_memory_maximum_size(max);
}
config.static_memory_forced(self.static_memory_forced);
if let Some(size) = self.static_memory_guard_size {
config.static_memory_guard_size(size);
}