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
impl MarkState
pub fn new() -> Self
fn unmarked_state(&self) -> u8
sourcepub fn is_marked<VM: VMBinding>(&self, object: ObjectReference) -> bool
pub fn is_marked<VM: VMBinding>(&self, object: ObjectReference) -> bool
Check if the object is marked
sourcepub fn test_and_mark<VM: VMBinding>(&self, object: ObjectReference) -> bool
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.
sourcepub fn on_object_metadata_initialization<VM: VMBinding>(
&self,
object: ObjectReference
)
pub fn on_object_metadata_initialization<VM: VMBinding>( &self, object: ObjectReference )
This has to be called during object initialization.
sourcepub fn on_global_prepare<VM: VMBinding>(&mut self)
pub fn on_global_prepare<VM: VMBinding>(&mut self)
This has to be called in the global preparation of a space
sourcepub fn on_block_reset<VM: VMBinding>(&self, start: Address, size: usize)
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.
sourcepub fn on_global_release<VM: VMBinding>(&mut self)
pub fn on_global_release<VM: VMBinding>(&mut self)
This has to be called in the global release of a space
Auto Trait Implementations§
impl RefUnwindSafe for MarkState
impl Send for MarkState
impl Sync for MarkState
impl Unpin for MarkState
impl UnwindSafe for MarkState
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
§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>
. 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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
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> 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