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

@@ -65,28 +65,68 @@ fn test_write_read_cache() {
let entry1 = ModuleCacheEntry::from_inner(ModuleCacheEntryInner::new(compiler1, &cache_config));
let entry2 = ModuleCacheEntry::from_inner(ModuleCacheEntryInner::new(compiler2, &cache_config));
entry1.get_data::<_, i32, i32>(1, |_| Ok(100)).unwrap();
entry1.get_data::<_, i32, i32>(1, |_| panic!()).unwrap();
entry1
.get_data(1, |_| -> Result<i32, ()> { Ok(100) })
.unwrap();
entry1
.get_data(1, |_| -> Result<i32, ()> { panic!() })
.unwrap();
entry1.get_data::<_, i32, i32>(2, |_| Ok(100)).unwrap();
entry1.get_data::<_, i32, i32>(1, |_| panic!()).unwrap();
entry1.get_data::<_, i32, i32>(2, |_| panic!()).unwrap();
entry1
.get_data(2, |_| -> Result<i32, ()> { Ok(100) })
.unwrap();
entry1
.get_data(1, |_| -> Result<i32, ()> { panic!() })
.unwrap();
entry1
.get_data(2, |_| -> Result<i32, ()> { panic!() })
.unwrap();
entry1.get_data::<_, i32, i32>(3, |_| Ok(100)).unwrap();
entry1.get_data::<_, i32, i32>(1, |_| panic!()).unwrap();
entry1.get_data::<_, i32, i32>(2, |_| panic!()).unwrap();
entry1.get_data::<_, i32, i32>(3, |_| panic!()).unwrap();
entry1
.get_data(3, |_| -> Result<i32, ()> { Ok(100) })
.unwrap();
entry1
.get_data(1, |_| -> Result<i32, ()> { panic!() })
.unwrap();
entry1
.get_data(2, |_| -> Result<i32, ()> { panic!() })
.unwrap();
entry1
.get_data(3, |_| -> Result<i32, ()> { panic!() })
.unwrap();
entry1.get_data::<_, i32, i32>(4, |_| Ok(100)).unwrap();
entry1.get_data::<_, i32, i32>(1, |_| panic!()).unwrap();
entry1.get_data::<_, i32, i32>(2, |_| panic!()).unwrap();
entry1.get_data::<_, i32, i32>(3, |_| panic!()).unwrap();
entry1.get_data::<_, i32, i32>(4, |_| panic!()).unwrap();
entry1
.get_data(4, |_| -> Result<i32, ()> { Ok(100) })
.unwrap();
entry1
.get_data(1, |_| -> Result<i32, ()> { panic!() })
.unwrap();
entry1
.get_data(2, |_| -> Result<i32, ()> { panic!() })
.unwrap();
entry1
.get_data(3, |_| -> Result<i32, ()> { panic!() })
.unwrap();
entry1
.get_data(4, |_| -> Result<i32, ()> { panic!() })
.unwrap();
entry2.get_data::<_, i32, i32>(1, |_| Ok(100)).unwrap();
entry1.get_data::<_, i32, i32>(1, |_| panic!()).unwrap();
entry1.get_data::<_, i32, i32>(2, |_| panic!()).unwrap();
entry1.get_data::<_, i32, i32>(3, |_| panic!()).unwrap();
entry1.get_data::<_, i32, i32>(4, |_| panic!()).unwrap();
entry2.get_data::<_, i32, i32>(1, |_| panic!()).unwrap();
entry2
.get_data(1, |_| -> Result<i32, ()> { Ok(100) })
.unwrap();
entry1
.get_data(1, |_| -> Result<i32, ()> { panic!() })
.unwrap();
entry1
.get_data(2, |_| -> Result<i32, ()> { panic!() })
.unwrap();
entry1
.get_data(3, |_| -> Result<i32, ()> { panic!() })
.unwrap();
entry1
.get_data(4, |_| -> Result<i32, ()> { panic!() })
.unwrap();
entry2
.get_data(1, |_| -> Result<i32, ()> { panic!() })
.unwrap();
}