Allow instance allocators control over module compilation.

This commit introduces two new methods on `InstanceAllocator`:

* `validate_module` - this method is used to validate a module after
  translation but before compilation. It will be used for the upcoming pooling
  allocator to ensure a module being compiled adheres to the limits of the
  allocator.

* `adjust_tunables` - this method is used to adjust the `Tunables` given the
  JIT compiler.  The pooling allocator will use this to force all memories to
  be static during compilation.
This commit is contained in:
Peter Huene
2020-12-07 22:12:33 -08:00
parent b58afbf849
commit c8871ee1e6
9 changed files with 112 additions and 45 deletions

View File

@@ -42,8 +42,16 @@ impl MemoryStyle {
// A heap with a maximum that doesn't exceed the static memory bound specified by the
// tunables make it static.
//
// If the module doesn't declare an explicit maximum treat it as 4GiB.
let maximum = memory.maximum.unwrap_or(WASM_MAX_PAGES);
// If the module doesn't declare an explicit maximum treat it as 4GiB when not
// requested to use the static memory bound itself as the maximum.
let maximum = memory
.maximum
.unwrap_or(if tunables.static_memory_bound_is_maximum {
tunables.static_memory_bound
} else {
WASM_MAX_PAGES
});
if maximum <= tunables.static_memory_bound {
assert_ge!(tunables.static_memory_bound, memory.minimum);
return (