Struct mmtk::plan::mutator_context::Mutator
source · #[repr(C)]pub struct Mutator<VM: VMBinding> {
pub(crate) allocators: Allocators<VM>,
pub barrier: Box<dyn Barrier<VM>>,
pub mutator_tls: VMMutatorThread,
pub(crate) plan: &'static dyn Plan<VM = VM>,
pub(crate) config: MutatorConfig<VM>,
}
Expand description
A mutator is a per-thread data structure that manages allocations and barriers. It is usually highly coupled with the language VM. It is recommended for MMTk users 1) to have a mutator struct of the same layout in the thread local storage that can be accessed efficiently, and 2) to implement fastpath allocation and barriers for the mutator in the VM side.
Fields§
§allocators: Allocators<VM>
§barrier: Box<dyn Barrier<VM>>
Holds some thread-local states for the barrier.
mutator_tls: VMMutatorThread
The mutator thread that is bound with this Mutator struct.
plan: &'static dyn Plan<VM = VM>
§config: MutatorConfig<VM>
Implementations§
source§impl<VM: VMBinding> Mutator<VM>
impl<VM: VMBinding> Mutator<VM>
sourcefn get_all_allocator_selectors(&self) -> Vec<AllocatorSelector>
fn get_all_allocator_selectors(&self) -> Vec<AllocatorSelector>
Get all the valid allocator selector (no duplicate)
sourcepub fn on_destroy(&mut self)
pub fn on_destroy(&mut self)
Inform each allocator about destroying. Call allocator-specific on destroy methods.
sourcepub unsafe fn allocator(
&self,
selector: AllocatorSelector
) -> &dyn Allocator<VM>
pub unsafe fn allocator( &self, selector: AllocatorSelector ) -> &dyn Allocator<VM>
Get the allocator for the selector.
§Safety
The selector needs to be valid, and points to an allocator that has been initialized.
crate::memory_manager::get_allocator_mapping
can be used to get a selector.
sourcepub unsafe fn allocator_mut(
&mut self,
selector: AllocatorSelector
) -> &mut dyn Allocator<VM>
pub unsafe fn allocator_mut( &mut self, selector: AllocatorSelector ) -> &mut dyn Allocator<VM>
Get the mutable allocator for the selector.
§Safety
The selector needs to be valid, and points to an allocator that has been initialized.
crate::memory_manager::get_allocator_mapping
can be used to get a selector.
sourcepub unsafe fn allocator_impl<T: Allocator<VM>>(
&self,
selector: AllocatorSelector
) -> &T
pub unsafe fn allocator_impl<T: Allocator<VM>>( &self, selector: AllocatorSelector ) -> &T
Get the allocator of a concrete type for the selector.
§Safety
The selector needs to be valid, and points to an allocator that has been initialized.
crate::memory_manager::get_allocator_mapping
can be used to get a selector.
sourcepub unsafe fn allocator_impl_mut<T: Allocator<VM>>(
&mut self,
selector: AllocatorSelector
) -> &mut T
pub unsafe fn allocator_impl_mut<T: Allocator<VM>>( &mut self, selector: AllocatorSelector ) -> &mut T
Get the mutable allocator of a concrete type for the selector.
§Safety
The selector needs to be valid, and points to an allocator that has been initialized.
crate::memory_manager::get_allocator_mapping
can be used to get a selector.
sourcepub fn get_allocator_base_offset(selector: AllocatorSelector) -> usize
pub fn get_allocator_base_offset(selector: AllocatorSelector) -> usize
Return the base offset from a mutator pointer to the allocator specified by the selector.
Trait Implementations§
source§impl<VM: VMBinding> MutatorContext<VM> for Mutator<VM>
impl<VM: VMBinding> MutatorContext<VM> for Mutator<VM>
source§fn prepare(&mut self, tls: VMWorkerThread)
fn prepare(&mut self, tls: VMWorkerThread)
source§fn release(&mut self, tls: VMWorkerThread)
fn release(&mut self, tls: VMWorkerThread)
source§fn alloc(
&mut self,
size: usize,
align: usize,
offset: usize,
allocator: AllocationSemantics
) -> Address
fn alloc( &mut self, size: usize, align: usize, offset: usize, allocator: AllocationSemantics ) -> Address
source§fn alloc_slow(
&mut self,
size: usize,
align: usize,
offset: usize,
allocator: AllocationSemantics
) -> Address
fn alloc_slow( &mut self, size: usize, align: usize, offset: usize, allocator: AllocationSemantics ) -> Address
source§fn post_alloc(
&mut self,
refer: ObjectReference,
_bytes: usize,
allocator: AllocationSemantics
)
fn post_alloc( &mut self, refer: ObjectReference, _bytes: usize, allocator: AllocationSemantics )
source§fn get_tls(&self) -> VMMutatorThread
fn get_tls(&self) -> VMMutatorThread
crate::memory_manager::bind_mutator
when this mutator is created.source§fn flush_remembered_sets(&mut self)
fn flush_remembered_sets(&mut self)
Auto Trait Implementations§
impl<VM> !RefUnwindSafe for Mutator<VM>
impl<VM> Send for Mutator<VM>
impl<VM> !Sync for Mutator<VM>
impl<VM> Unpin for Mutator<VM>
impl<VM> !UnwindSafe for Mutator<VM>
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.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