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: AtomicUsize,
}
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: AtomicUsize

This stores the size in bytes for all the live objects in last GC. This counter is only updated in the GC release phase.

Implementations§

source§

impl GlobalState

source

pub fn is_initialized(&self) -> bool

Is MMTk initialized?

source

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.

source

fn determine_collection_attempts(&self) -> usize

source

fn is_internal_triggered_collection(&self) -> bool

source

pub fn is_emergency_collection(&self) -> bool

source

pub fn is_user_triggered_collection(&self) -> bool

Return true if this collection was triggered by application code.

source

pub fn reset_collection_trigger(&self)

Reset collection state information.

source

pub fn stacks_prepared(&self) -> bool

Are the stacks scanned?

source

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.

source

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.

source

pub fn increase_allocation_bytes_by(&self, size: usize) -> usize

Increase the allocation bytes and return the current allocation bytes after increasing

source

pub fn get_malloc_bytes_in_pages(&self) -> usize

source

pub(crate) fn increase_malloc_bytes_by(&self, size: usize)

source

pub(crate) fn decrease_malloc_bytes_by(&self, size: usize)

source

pub fn get_live_bytes_in_last_gc(&self) -> usize

source

pub fn set_live_bytes_in_last_gc(&self, size: usize)

Trait Implementations§

source§

impl Default for GlobalState

source§

fn default() -> Self

Returns the “default value” for a type. Read more

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.