pub trait Mmapper: Sync {
    // Required methods
    fn eagerly_mmap_all_spaces(&self, space_map: &[Address]);
    fn mark_as_mapped(&self, start: Address, bytes: usize);
    fn quarantine_address_range(
        &self,
        start: Address,
        pages: usize,
        strategy: MmapStrategy,
        anno: &MmapAnnotation<'_>
    ) -> Result<()>;
    fn ensure_mapped(
        &self,
        start: Address,
        pages: usize,
        strategy: MmapStrategy,
        anno: &MmapAnnotation<'_>
    ) -> Result<()>;
    fn is_mapped_address(&self, addr: Address) -> bool;
    fn protect(&self, start: Address, pages: usize);
}
Expand description

Generic mmap and protection functionality

Required Methods§

source

fn eagerly_mmap_all_spaces(&self, space_map: &[Address])

Given an address array describing the regions of virtual memory to be used by MMTk, demand zero map all of them if they are not already mapped.

Arguments:

  • spaceMap: An address array containing a pairs of start and end addresses for each of the regions to be mapped
source

fn mark_as_mapped(&self, start: Address, bytes: usize)

Mark a number of pages as mapped, without making any request to the operating system. Used to mark pages that the VM has already mapped.

Arguments:

  • start: Address of the first page to be mapped
  • bytes: Number of bytes to ensure mapped
source

fn quarantine_address_range( &self, start: Address, pages: usize, strategy: MmapStrategy, anno: &MmapAnnotation<'_> ) -> Result<()>

Quarantine/reserve address range. We mmap from the OS with no reserve and with PROT_NONE, which should be little overhead. This ensures that we can reserve certain address range that we can use if needed. Quarantined memory needs to be mapped before it can be used.

Arguments:

  • start: Address of the first page to be quarantined
  • bytes: Number of bytes to quarantine from the start
  • strategy: The mmap strategy. The prot field is ignored because we always use PROT_NONE.
  • anno: Human-readable annotation to apply to newly mapped memory ranges.
source

fn ensure_mapped( &self, start: Address, pages: usize, strategy: MmapStrategy, anno: &MmapAnnotation<'_> ) -> Result<()>

Ensure that a range of pages is mmapped (or equivalent). If the pages are not yet mapped, demand-zero map them. Note that mapping occurs at chunk granularity, not page granularity.

Arguments:

  • start: The start of the range to be mapped.
  • pages: The size of the range to be mapped, in pages
  • strategy: The mmap strategy.
  • anno: Human-readable annotation to apply to newly mapped memory ranges.
source

fn is_mapped_address(&self, addr: Address) -> bool

Is the page pointed to by this address mapped? Returns true if the page at the given address is mapped.

Arguments:

  • addr: Address in question
source

fn protect(&self, start: Address, pages: usize)

Mark a number of pages as inaccessible.

Arguments:

  • start: Address of the first page to be protected
  • pages: Number of pages to be protected

Implementors§