pub struct Relocator { /* private fields */ }Expand description
The Relocator orchestrates compaction by owning a ForwardingTable and
providing methods to copy live objects between regions, install forwarding
entries, and resolve stale pointers.
Implementations§
Source§impl Relocator
impl Relocator
Sourcepub fn install_forwarding(&mut self, old_addr: *mut u8, new_addr: *mut u8)
pub fn install_forwarding(&mut self, old_addr: *mut u8, new_addr: *mut u8)
Install a forwarding entry: old_addr now lives at new_addr.
Sourcepub fn resolve(&self, ptr: *mut u8) -> *mut u8
pub fn resolve(&self, ptr: *mut u8) -> *mut u8
Resolve a (possibly stale) pointer through the forwarding table.
If ptr has a forwarding entry, returns the new address. Otherwise
returns ptr unchanged.
Sourcepub fn compact_region(&mut self, source: &Region, target: &mut Region) -> usize
pub fn compact_region(&mut self, source: &Region, target: &mut Region) -> usize
Compact a source region by copying all live (Black) objects into target.
Each copied object is:
- Allocated in
targetvia bump allocation. - Memory-copied (header + object data).
- Its header reset to White (ready for the next marking cycle).
- Recorded in the forwarding table.
Returns the number of objects moved.
Sourcepub fn forwarding_table(&self) -> &ForwardingTable
pub fn forwarding_table(&self) -> &ForwardingTable
Get a reference to the underlying forwarding table.
Sourcepub fn forwarding_table_mut(&mut self) -> &mut ForwardingTable
pub fn forwarding_table_mut(&mut self) -> &mut ForwardingTable
Get a mutable reference to the underlying forwarding table.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Relocator
impl RefUnwindSafe for Relocator
impl Send for Relocator
impl Sync for Relocator
impl Unpin for Relocator
impl UnsafeUnpin for Relocator
impl UnwindSafe for Relocator
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