OSMemory

Trait OSMemory 

Source
pub trait OSMemory {
    // Required methods
    fn dzmmap(
        start: Address,
        size: usize,
        strategy: MmapStrategy,
        annotation: &MmapAnnotation<'_>,
    ) -> MmapResult<Address>;
    fn is_mmap_oom(os_errno: i32) -> bool;
    fn munmap(start: Address, size: usize) -> Result<()>;
    fn set_memory_access(
        start: Address,
        size: usize,
        prot: MmapProtection,
    ) -> Result<()>;
    fn panic_if_unmapped(start: Address, size: usize);

    // Provided methods
    fn handle_mmap_error<VM: VMBinding>(mmap_error: MmapError, tls: VMThread) { ... }
    fn get_system_total_memory() -> Result<u64> { ... }
}
Expand description

Abstraction for OS memory operations.

Required Methods§

Source

fn dzmmap( start: Address, size: usize, strategy: MmapStrategy, annotation: &MmapAnnotation<'_>, ) -> MmapResult<Address>

Perform a demand-zero mmap.

Fallback: annotation is only used for debugging. For platforms that do not support mmap annotations, this parameter can be ignored. Fallback: see crate::util::os::MmapStrategy for fallbacks for strategy.

Source

fn is_mmap_oom(os_errno: i32) -> bool

Check whether the given OS error number indicates an out-of-memory condition.

Source

fn munmap(start: Address, size: usize) -> Result<()>

Unmap a memory region.

Source

fn set_memory_access( start: Address, size: usize, prot: MmapProtection, ) -> Result<()>

Change the protection of a memory region to the specified protection.

Source

fn panic_if_unmapped(start: Address, size: usize)

Checks if the memory has already been mapped. If not, we panic.

Note that the checking may have a side effect that it will map the memory if it was unmapped. So we panic if it was unmapped. Be very careful about using this function.

Fallback: As the function is only used for assertions, it can be a no-op, and MMTk will still run and never panics in this function.

Provided Methods§

Source

fn handle_mmap_error<VM: VMBinding>(mmap_error: MmapError, tls: VMThread)

Handle mmap errors, possibly by signaling the VM about an out-of-memory condition.

Source

fn get_system_total_memory() -> Result<u64>

Get the total memory of the system in bytes.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§