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:
@@ -362,3 +362,17 @@ fn tiny_static_heap() -> Result<()> {
|
||||
f.call(&mut store, ())?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn static_forced_max() -> Result<()> {
|
||||
let mut config = Config::new();
|
||||
config.static_memory_maximum_size(5 * 65536);
|
||||
config.static_memory_forced(true);
|
||||
let engine = Engine::new(&config)?;
|
||||
let mut store = Store::new(&engine, ());
|
||||
|
||||
let mem = Memory::new(&mut store, MemoryType::new(0, None))?;
|
||||
mem.grow(&mut store, 5).unwrap();
|
||||
assert!(mem.grow(&mut store, 1).is_err());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user