pub struct ArenaMemoryProvider { /* private fields */ }
Expand description
ArenaMemoryProvider
allocates segments from a contiguous memory region
that is reserved up-front.
The arena’s memory is initially allocated with PROT_NONE and gradually updated as the JIT requires more space. This approach allows for stable addresses throughout the lifetime of the JIT.
Depending on the underlying platform, requesting large parts of the address space to be allocated might fail. This implementation currently doesn’t do overcommit on Windows.
Note: Memory will be leaked by default unless
JITMemoryProvider::free_memory
is called to ensure function pointers
remain valid for the remainder of the program’s life.
Implementations§
Source§impl ArenaMemoryProvider
impl ArenaMemoryProvider
Sourcepub fn new_with_size(reserve_size: usize) -> Result<Self, Error>
pub fn new_with_size(reserve_size: usize) -> Result<Self, Error>
Create a new memory region with the given size.
Trait Implementations§
Source§impl Drop for ArenaMemoryProvider
impl Drop for ArenaMemoryProvider
Source§impl JITMemoryProvider for ArenaMemoryProvider
impl JITMemoryProvider for ArenaMemoryProvider
Source§fn allocate_readexec(&mut self, size: usize, align: u64) -> Result<*mut u8>
fn allocate_readexec(&mut self, size: usize, align: u64) -> Result<*mut u8>
Allocate memory that will be executable once finalized.
Source§fn allocate_readwrite(&mut self, size: usize, align: u64) -> Result<*mut u8>
fn allocate_readwrite(&mut self, size: usize, align: u64) -> Result<*mut u8>
Allocate writable memory.
Source§fn allocate_readonly(&mut self, size: usize, align: u64) -> Result<*mut u8>
fn allocate_readonly(&mut self, size: usize, align: u64) -> Result<*mut u8>
Allocate memory that will be read-only once finalized.
Source§unsafe fn free_memory(&mut self)
unsafe fn free_memory(&mut self)
Free the memory region.
Source§fn finalize(&mut self, branch_protection: BranchProtection) -> ModuleResult<()>
fn finalize(&mut self, branch_protection: BranchProtection) -> ModuleResult<()>
Finalize the memory region and apply memory protections.
impl Send for ArenaMemoryProvider
Auto Trait Implementations§
impl Freeze for ArenaMemoryProvider
impl RefUnwindSafe for ArenaMemoryProvider
impl !Sync for ArenaMemoryProvider
impl Unpin for ArenaMemoryProvider
impl UnwindSafe for ArenaMemoryProvider
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more