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

@@ -101,6 +101,7 @@ impl CompilationArtifacts {
pub fn build(
compiler: &Compiler,
data: &[u8],
validate: impl Fn(&ModuleTranslation) -> Result<(), String> + Sync,
) -> Result<(usize, Vec<CompilationArtifacts>, TypeTables), SetupError> {
let (main_module, translations, types) = ModuleEnvironment::new(
compiler.frontend_config(),
@@ -112,6 +113,8 @@ impl CompilationArtifacts {
let list = maybe_parallel!(translations.(into_iter | into_par_iter))
.map(|mut translation| {
validate(&translation).map_err(|e| SetupError::Validate(e))?;
let Compilation {
obj,
unwind_info,