Struct mmtk::global_state::GlobalState
source · pub struct GlobalState {Show 15 fields
pub(crate) initialized: AtomicBool,
pub(crate) gc_status: Mutex<GcStatus>,
pub(crate) gc_start_time: AtomicRefCell<Option<Instant>>,
pub(crate) emergency_collection: AtomicBool,
pub(crate) user_triggered_collection: AtomicBool,
pub(crate) internal_triggered_collection: AtomicBool,
pub(crate) last_internal_triggered_collection: AtomicBool,
pub(crate) allocation_success: AtomicBool,
pub(crate) max_collection_attempts: AtomicUsize,
pub(crate) cur_collection_attempts: AtomicUsize,
pub(crate) scanned_stacks: AtomicUsize,
pub(crate) stacks_prepared: AtomicBool,
pub(crate) allocation_bytes: AtomicUsize,
pub(crate) malloc_bytes: AtomicUsize,
pub(crate) live_bytes_in_last_gc: AtomicRefCell<HashMap<&'static str, LiveBytesStats>>,
}
Expand description
This stores some global states for an MMTK instance. Some MMTK components like plans and allocators may keep an reference to the struct, and can access it.
Fields§
§initialized: AtomicBool
Whether MMTk is now ready for collection. This is set to true when initialize_collection() is called.
gc_status: Mutex<GcStatus>
The current GC status.
gc_start_time: AtomicRefCell<Option<Instant>>
When did the last GC start? Only accessed by the last parked worker.
emergency_collection: AtomicBool
Is the current GC an emergency collection? Emergency means we may run out of memory soon, and we should attempt to collect as much as we can.
user_triggered_collection: AtomicBool
Is the current GC triggered by the user?
internal_triggered_collection: AtomicBool
Is the current GC triggered internally by MMTK? This is unused for now. We may have internally triggered GC for a concurrent plan.
last_internal_triggered_collection: AtomicBool
Is the last GC internally triggered?
allocation_success: AtomicBool
§max_collection_attempts: AtomicUsize
§cur_collection_attempts: AtomicUsize
§scanned_stacks: AtomicUsize
A counter for per-mutator stack scanning
stacks_prepared: AtomicBool
Have we scanned all the stacks?
allocation_bytes: AtomicUsize
A counter that keeps tracks of the number of bytes allocated since last stress test
malloc_bytes: AtomicUsize
A counteer that keeps tracks of the number of bytes allocated by malloc
live_bytes_in_last_gc: AtomicRefCell<HashMap<&'static str, LiveBytesStats>>
This stores the live bytes and the used bytes (by pages) for each space in last GC. This counter is only updated in the GC release phase.
Implementations§
source§impl GlobalState
impl GlobalState
sourcepub fn is_initialized(&self) -> bool
pub fn is_initialized(&self) -> bool
Is MMTk initialized?
sourcepub fn set_collection_kind(
&self,
last_collection_was_exhaustive: bool,
heap_can_grow: bool
) -> bool
pub fn set_collection_kind( &self, last_collection_was_exhaustive: bool, heap_can_grow: bool ) -> bool
Set the collection kind for the current GC. This is called before scheduling collection to determin what kind of collection it will be.
fn determine_collection_attempts(&self) -> usize
fn is_internal_triggered_collection(&self) -> bool
pub fn is_emergency_collection(&self) -> bool
sourcepub fn is_user_triggered_collection(&self) -> bool
pub fn is_user_triggered_collection(&self) -> bool
Return true if this collection was triggered by application code.
sourcepub fn reset_collection_trigger(&self)
pub fn reset_collection_trigger(&self)
Reset collection state information.
sourcepub fn stacks_prepared(&self) -> bool
pub fn stacks_prepared(&self) -> bool
Are the stacks scanned?
sourcepub fn prepare_for_stack_scanning(&self)
pub fn prepare_for_stack_scanning(&self)
Prepare for stack scanning. This is usually used with inform_stack_scanned()
.
This should be called before doing stack scanning.
sourcepub fn inform_stack_scanned(&self, n_mutators: usize) -> bool
pub fn inform_stack_scanned(&self, n_mutators: usize) -> bool
Inform that 1 stack has been scanned. The argument n_mutators
indicates the
total stacks we should scan. This method returns true if the number of scanned
stacks equals the total mutator count. Otherwise it returns false. This method
is thread safe and we guarantee only one thread will return true.
sourcepub fn increase_allocation_bytes_by(&self, size: usize) -> usize
pub fn increase_allocation_bytes_by(&self, size: usize) -> usize
Increase the allocation bytes and return the current allocation bytes after increasing
pub fn get_malloc_bytes_in_pages(&self) -> usize
pub(crate) fn increase_malloc_bytes_by(&self, size: usize)
pub(crate) fn decrease_malloc_bytes_by(&self, size: usize)
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for GlobalState
impl Send for GlobalState
impl Sync for GlobalState
impl Unpin for GlobalState
impl UnwindSafe for GlobalState
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