[][src]Struct lucet_runtime::MmapRegion

pub struct MmapRegion { /* fields omitted */ }

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]

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]

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]

impl RegionCreate for MmapRegion[src]

impl RegionInternal for MmapRegion[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

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]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.