Implement the pooling instance allocator.

This commit implements the pooling instance allocator.

The allocation strategy can be set with `Config::with_allocation_strategy`.

The pooling strategy uses the pooling instance allocator to preallocate a
contiguous region of memory for instantiating modules that adhere to various
limits.

The intention of the pooling instance allocator is to reserve as much of the
host address space needed for instantiating modules ahead of time and to reuse
committed memory pages wherever possible.
This commit is contained in:
Peter Huene
2020-12-08 16:00:48 -08:00
parent 16ca5e16d9
commit e71ccbf9bc
16 changed files with 2374 additions and 20 deletions

View File

@@ -234,7 +234,7 @@ impl Mmap {
}
/// Return the allocated memory as a mutable pointer to u8.
pub fn as_mut_ptr(&mut self) -> *mut u8 {
pub fn as_mut_ptr(&self) -> *mut u8 {
self.ptr as *mut u8
}
@@ -247,6 +247,11 @@ impl Mmap {
pub fn is_empty(&self) -> bool {
self.len() == 0
}
#[allow(dead_code)]
pub(crate) unsafe fn from_raw(ptr: usize, len: usize) -> Self {
Self { ptr, len }
}
}
impl Drop for Mmap {