Skip to main content

Relocator

Struct Relocator 

Source
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

Source

pub fn new() -> Self

Create a new relocator with an empty forwarding table.

Source

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.

Source

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.

Source

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:

  1. Allocated in target via bump allocation.
  2. Memory-copied (header + object data).
  3. Its header reset to White (ready for the next marking cycle).
  4. Recorded in the forwarding table.

Returns the number of objects moved.

Source

pub fn forwarding_table(&self) -> &ForwardingTable

Get a reference to the underlying forwarding table.

Source

pub fn forwarding_table_mut(&mut self) -> &mut ForwardingTable

Get a mutable reference to the underlying forwarding table.

Source

pub fn reset(&mut self)

Clear the forwarding table for reuse.

Trait Implementations§

Source§

impl Default for Relocator

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.