pub struct MarkState {
    state: u8,
}
Expand description

This provides an abstraction of the mark bit. It abstracts over the difference between side mark bits and in-header mark bits, and provides efficient implementation for each case.

The key difference between side and in-header mark bit is what the mark state represents.

  • Side mark bit We always use 1 for the marked state. So we do not need to set mark bit for new objects (mark bit 0). In each GC, we do bulk zeroing to reset the mark bit to 0 before tracing or after tracing. During tracing, we mark objects with the state 1 as usual.
  • In-header mark bit We flip the mark state in every GC. For example, if 1 means marked in the current GC, 1 will mean unmarked in the next GC. With this approach, we do not need to reset mark bit for each object, as the value represents unmarked in the next GC. However, with in-header mark bit, we have to set mark bit for newly allocated objects.

A policy could use this struct instead of the raw mark bit. It has to call all the methods prefixed with on_ such as on_object_metadata_initialization(), on_global_prepare(), on_block_prepare(), and on_global_release().

Fields§

§state: u8

This value represents the marked state. If the mark bit is this value, the object is considered as marked. If the mark bit is on side, we always use 1 as the marked state. We do bulk zeroing to reset mark bits before GCs If the mark bit is in header, we flip the marked state in every GC, so we do not need to reset the mark bit for live objects.

Implementations§

source§

impl MarkState

source

pub fn new() -> Self

source

fn unmarked_state(&self) -> u8

source

pub fn is_marked<VM: VMBinding>(&self, object: ObjectReference) -> bool

Check if the object is marked

source

pub fn test_and_mark<VM: VMBinding>(&self, object: ObjectReference) -> bool

Attempt to mark an object. If the object is marked by this invocation, return true. Otherwise return false – the object was marked by others.

source

pub fn on_object_metadata_initialization<VM: VMBinding>( &self, object: ObjectReference )

This has to be called during object initialization.

source

pub fn on_global_prepare<VM: VMBinding>(&mut self)

This has to be called in the global preparation of a space

source

pub fn on_block_reset<VM: VMBinding>(&self, start: Address, size: usize)

This has to be called when a space resets its memory regions. This can be either called before the GC tracing, or after a GC tracing (eagerly). This method will reset the mark bit. The policy should not use the mark bit before doing another tracing.

source

pub fn on_global_release<VM: VMBinding>(&mut self)

This has to be called in the global release of a space

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
§

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

§

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

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

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

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

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

Convert &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)

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

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

§

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

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further 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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.