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:
@@ -1119,6 +1119,22 @@ impl Config {
|
||||
self
|
||||
}
|
||||
|
||||
/// Indicates that the "static" style of memory should always be used.
|
||||
///
|
||||
/// This configuration option enables selecting the "static" option for all
|
||||
/// linear memories created within this `Config`. This means that all
|
||||
/// memories will be allocated up-front and will never move. Additionally
|
||||
/// this means that all memories are synthetically limited by the
|
||||
/// [`Config::static_memory_maximum_size`] option, irregardless of what the
|
||||
/// actual maximum size is on the memory's original type.
|
||||
///
|
||||
/// For the difference between static and dynamic memories, see the
|
||||
/// [`Config::static_memory_maximum_size`].
|
||||
pub fn static_memory_forced(&mut self, force: bool) -> &mut Self {
|
||||
self.tunables.static_memory_bound_is_maximum = force;
|
||||
self
|
||||
}
|
||||
|
||||
/// Configures the size, in bytes, of the guard region used at the end of a
|
||||
/// static memory's address space reservation.
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user