#[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>
impl<VM: VMBinding> RefCountHelper<VM>
Sourcepub const NEW: Self
pub const NEW: Self
A singleton instance of RefCountHelper (the type is zero-sized, so it can be freely copied/cloned).
Sourcepub const SANITY: bool = true
pub const SANITY: bool = true
Whether extra reference-counting sanity checks are enabled (debug builds or the sanity feature).
Sourcepub fn inc_buffer_size(&self) -> usize
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.
Sourcepub fn increase_inc_buffer_size(&self, delta: usize)
pub fn increase_inc_buffer_size(&self, delta: usize)
Increases the global increment buffer size counter by delta.
Sourcepub fn reset_inc_buffer_size(&self)
pub fn reset_inc_buffer_size(&self)
Resets the global increment buffer size counter to zero.
Sourcepub fn fetch_update(
&self,
o: ObjectReference,
f: impl FnMut(u8) -> Option<u8>,
) -> Result<u8, u8>
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.
Sourcepub fn is_stuck(&self, o: ObjectReference) -> bool
pub fn is_stuck(&self, o: ObjectReference) -> bool
Returns true if object o’s reference count has saturated at MAX_REF_COUNT (sticky).
Sourcepub fn stick(&self, o: ObjectReference) -> Result<u8, u8>
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.
Sourcepub fn inc(&self, o: ObjectReference) -> Result<u8, u8>
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.
Sourcepub fn dec(&self, o: ObjectReference) -> Result<u8, u8>
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.
Sourcepub fn set(&self, o: ObjectReference, count: u8)
pub fn set(&self, o: ObjectReference, count: u8)
Atomically sets object o’s reference count to count.
Sourcepub fn set_relaxed(&self, o: ObjectReference, count: u8)
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.
Sourcepub fn set_line_relaxed(&self, line: Line, count: u8)
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.
Sourcepub fn count(&self, o: ObjectReference) -> u8
pub fn count(&self, o: ObjectReference) -> u8
Returns object o’s current reference count.
Sourcepub fn count_by_address(&self, addr: Address) -> u8
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.
Sourcepub fn object_or_line_is_dead(&self, o: ObjectReference) -> bool
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.
Sourcepub fn rc_table_range<UInt: Sized>(&self, b: Block) -> &'static [UInt]
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.
Sourcepub fn is_dead(&self, o: ObjectReference) -> bool
pub fn is_dead(&self, o: ObjectReference) -> bool
Returns true if object o’s reference count is zero.
Sourcepub fn is_dead_or_stuck(&self, o: ObjectReference) -> bool
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).
Sourcepub fn object_is_in_straddle_line_no_rc_check(&self, o: ObjectReference) -> bool
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.
Sourcepub fn object_is_in_straddle_line(&self, o: ObjectReference) -> bool
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.
fn mark_straddle_object_with_size(&self, o: ObjectReference, size: usize)
Sourcepub fn mark_straddle_object(&self, o: ObjectReference)
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.
Sourcepub fn unmark_straddle_object(&self, o: ObjectReference)
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.
Sourcepub fn assert_zero_ref_count(&self, o: ObjectReference)
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.
Sourcepub fn promote(&self, o: ObjectReference)
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.
Sourcepub fn promote_with_size(&self, o: ObjectReference, size: usize)
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>
impl<VM: VMBinding> Clone for RefCountHelper<VM>
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> 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&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
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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