RefCountHelper

Struct RefCountHelper 

Source
#[repr(transparent)]
pub struct RefCountHelper<VM: VMBinding>(PhantomData<VM>);
Expand description

A zero-sized helper type providing methods to read and update per-object reference count metadata for LXR’s reference counting plan.

Tuple Fields§

§0: PhantomData<VM>

Implementations§

Source§

impl<VM: VMBinding> RefCountHelper<VM>

Source

pub const NEW: Self

A singleton instance of RefCountHelper (the type is zero-sized, so it can be freely copied/cloned).

Source

pub const SANITY: bool = true

Whether extra reference-counting sanity checks are enabled (debug builds or the sanity feature).

Source

pub fn inc_buffer_size(&self) -> usize

Returns the current size of the global increment buffer, i.e. the number of pending reference count increments that have been enqueued but not yet processed.

Source

pub fn increase_inc_buffer_size(&self, delta: usize)

Increases the global increment buffer size counter by delta.

Source

pub fn reset_inc_buffer_size(&self)

Resets the global increment buffer size counter to zero.

Source

pub fn fetch_update( &self, o: ObjectReference, f: impl FnMut(u8) -> Option<u8>, ) -> Result<u8, u8>

Atomically updates the reference count of object o by applying f to its current value, following the same semantics as AtomicU8::fetch_update.

Source

pub fn is_stuck(&self, o: ObjectReference) -> bool

Returns true if object o’s reference count has saturated at MAX_REF_COUNT (sticky).

Source

pub fn stick(&self, o: ObjectReference) -> Result<u8, u8>

Forces object o’s reference count to MAX_REF_COUNT, permanently marking it as sticky so it is never reclaimed by reference counting.

Source

pub fn inc(&self, o: ObjectReference) -> Result<u8, u8>

Increments object o’s reference count by one, leaving it unchanged (saturating) once it has reached MAX_REF_COUNT.

Source

pub fn dec(&self, o: ObjectReference) -> Result<u8, u8>

Decrements object o’s reference count by one, unless it is already zero or has saturated at MAX_REF_COUNT (sticky), in which case it is left unchanged.

Source

pub fn set(&self, o: ObjectReference, count: u8)

Atomically sets object o’s reference count to count.

Source

pub fn set_relaxed(&self, o: ObjectReference, count: u8)

Sets object o’s reference count to count using a non-atomic store, for use where the caller can guarantee there is no concurrent access.

Source

pub fn set_line_relaxed(&self, line: Line, count: u8)

Sets the reference count for the line containing object o to count using a non-atomic store, for use where the caller can guarantee there is no concurrent access.

Source

pub fn count(&self, o: ObjectReference) -> u8

Returns object o’s current reference count.

Source

pub fn count_by_address(&self, addr: Address) -> u8

Returns the reference count stored in the RC table at address addr. If this returns a non-zero value, it indicates that addr is the address of an object reference, or the start of a straddle line.

Source

pub fn object_or_line_is_dead(&self, o: ObjectReference) -> bool

Returns true if the RC table entry at o’s address is zero. Used for both individual objects and line-granularity entries (e.g. straddle line markers), which share the same table.

Source

pub fn rc_table_range<UInt: Sized>(&self, b: Block) -> &'static [UInt]

Returns a slice view over the raw RC table memory covering block b, reinterpreted as an array of UInt, allowing the block’s reference counts to be scanned in bulk.

Source

pub fn is_dead(&self, o: ObjectReference) -> bool

Returns true if object o’s reference count is zero.

Source

pub fn is_dead_or_stuck(&self, o: ObjectReference) -> bool

Returns true if object o’s reference count is zero (dead) or has saturated at MAX_REF_COUNT (sticky).

Source

pub fn object_is_in_straddle_line_no_rc_check(&self, o: ObjectReference) -> bool

Returns true if object o is in a straddle line. The function does not check rc table.

Source

pub fn object_is_in_straddle_line(&self, o: ObjectReference) -> bool

Returns true if address a falls within a live object whose containing line is marked as a straddle line.

Source

fn mark_straddle_object_with_size(&self, o: ObjectReference, size: usize)

Source

pub fn mark_straddle_object(&self, o: ObjectReference)

Marks every line (other than the first) spanned by object o as a straddle line, so the object can be identified from any of the lines it straddles.

Source

pub fn unmark_straddle_object(&self, o: ObjectReference)

Clears the straddle-line and reference-count markers set by mark_straddle_object for every line (other than the first) spanned by object o.

Source

pub fn assert_zero_ref_count(&self, o: ObjectReference)

Debug assertion that every MIN_OBJECT_SIZE granule within object o has a reference count of zero, used to verify that a reclaimed object has been fully cleared.

Source

pub fn promote(&self, o: ObjectReference)

Called when object o is promoted to mature space; marks it as a straddle object if it spans more than one line, deriving its size from the VM binding.

Source

pub fn promote_with_size(&self, o: ObjectReference, size: usize)

Same as promote, but with the object’s size supplied by the caller instead of being queried from the VM binding.

Trait Implementations§

Source§

impl<VM: VMBinding> Clone for RefCountHelper<VM>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<VM: Debug + VMBinding> Debug for RefCountHelper<VM>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<VM: Copy + VMBinding> Copy for RefCountHelper<VM>

Auto Trait Implementations§

§

impl<VM> Freeze for RefCountHelper<VM>

§

impl<VM> RefUnwindSafe for RefCountHelper<VM>
where VM: RefUnwindSafe,

§

impl<VM> Send for RefCountHelper<VM>

§

impl<VM> Sync for RefCountHelper<VM>

§

impl<VM> Unpin for RefCountHelper<VM>
where VM: Unpin,

§

impl<VM> UnwindSafe for RefCountHelper<VM>
where VM: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Converts &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Converts &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSend for T
where T: Any + Send,

§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Send + Sync>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.