[−][src]Struct lucet_runtime::MmapRegion
A Region
backed by mmap
.
MmapRegion
lays out memory for instances in a contiguous block,
with an Instance's space reserved, followed by heap, stack, globals, and sigstack.
This results in an actual layout of an instance on an MmapRegion
-produced Slot
being:
0x0000: +-----------------------+ <-- Instance
0x0000: | .magic |
0x0008: | ... |
0x000X: | ... |
0x0XXX: | .alloc -> Alloc { |
0x0XXX: | .start = 0x0000 |
0x0XXX: | .heap = 0x1000 |
0x0XXX: | .stack = 0xN000 |
0x0XXX: | .globals = 0xM000 |
0x0XXX: | .sigstack = 0xS000 |
0x0XXX: | } |
0x0XXX: | ... |
0x0XXX: ~ ~padding~ ~
0x0XXX: | ... |
0x0XXX: | .globals = 0xM000 | <-- InstanceRuntimeData
0x0XXX: | .inst_count = 0x0000 |
0x1000: +-----------------------+ <-- Heap, and `lucet_vmctx`. One page into the allocation.
0x1XXX: | |
0xXXXX: ~ .......heap....... ~ // heap size is governed by limits.heap_address_space_size
0xXXXX: | |
0xN000: +-----------------------| <-- Stack (at heap_start + limits.heap_address_space_size)
0xNXXX: --- stack guard page ----
0xNXXX: | |
0xXXXX: ~ .......stack...... ~ // stack size is governed by limits.stack_size
0xXXXX: | |
0xM000: +-----------------------| <-- Globals (at stack_start + limits.stack_size + PAGE_SIZE)
0xMXXX: | |
0xXXXX: ~ ......globals..... ~
0xXXXX: | |
0xXXXX --- global guard page ---
0xS000: +-----------------------| <-- Sigstack (at globals_start + globals_size + PAGE_SIZE)
0xSXXX: | ......sigstack.... | // sigstack is governed by limits.signal_stack_size
0xSXXX: +-----------------------|
Methods
impl MmapRegion
[src]
pub fn create(
instance_capacity: usize,
limits: &Limits
) -> Result<Arc<MmapRegion>, Error>
[src]
instance_capacity: usize,
limits: &Limits
) -> Result<Arc<MmapRegion>, Error>
Create a new MmapRegion
that can support a given number instances, each subject to the
same runtime limits.
The region is returned in an Arc
, because any instances created from it carry a reference
back to the region.
pub fn create_aligned(
instance_capacity: usize,
limits: &Limits,
heap_alignment: usize
) -> Result<Arc<MmapRegion>, Error>
[src]
instance_capacity: usize,
limits: &Limits,
heap_alignment: usize
) -> Result<Arc<MmapRegion>, Error>
Create a new MmapRegion
that can support a given number instances, each subject to the
same runtime limits. Additionally, ensure that the heap is aligned at least to the
specified amount. heap_alignment must be a power of 2.
The region is returned in an Arc
, because any instances created from it carry a reference
back to the region.
Trait Implementations
impl Drop for MmapRegion
[src]
impl Region for MmapRegion
[src]
fn free_slots(&self) -> usize
[src]
fn used_slots(&self) -> usize
[src]
fn capacity(&self) -> usize
[src]
fn new_instance(
&self,
module: Arc<dyn Module + 'static>
) -> Result<InstanceHandle, Error>
[src]
&self,
module: Arc<dyn Module + 'static>
) -> Result<InstanceHandle, Error>
fn new_instance_builder(
&'a self,
module: Arc<dyn Module + 'static>
) -> InstanceBuilder<'a>
[src]
&'a self,
module: Arc<dyn Module + 'static>
) -> InstanceBuilder<'a>
impl RegionCreate for MmapRegion
[src]
const TYPE_NAME: &'static str
[src]
fn create(
instance_capacity: usize,
limits: &Limits
) -> Result<Arc<MmapRegion>, Error>
[src]
instance_capacity: usize,
limits: &Limits
) -> Result<Arc<MmapRegion>, Error>
impl RegionInternal for MmapRegion
[src]
fn new_instance_with(
&self,
module: Arc<dyn Module + 'static>,
embed_ctx: CtxMap
) -> Result<InstanceHandle, Error>
[src]
&self,
module: Arc<dyn Module + 'static>,
embed_ctx: CtxMap
) -> Result<InstanceHandle, Error>
fn drop_alloc(&self, alloc: &mut Alloc)
[src]
fn expand_heap(&self, slot: &Slot, start: u32, len: u32) -> Result<(), Error>
[src]
fn reset_heap(
&self,
alloc: &mut Alloc,
module: &dyn Module
) -> Result<(), Error>
[src]
&self,
alloc: &mut Alloc,
module: &dyn Module
) -> Result<(), Error>
fn as_dyn_internal(&self) -> &dyn RegionInternal
[src]
Auto Trait Implementations
impl RefUnwindSafe for MmapRegion
impl Send for MmapRegion
impl Sync for MmapRegion
impl Unpin for MmapRegion
impl UnwindSafe for MmapRegion
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,