Trait mmtk::plan::MutatorContext
source · pub trait MutatorContext<VM: VMBinding>: Send + 'static {
// Required methods
fn prepare(&mut self, tls: VMWorkerThread);
fn release(&mut self, tls: VMWorkerThread);
fn alloc(
&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;
fn post_alloc(
&mut self,
refer: ObjectReference,
bytes: usize,
allocator: AllocationSemantics
);
fn get_tls(&self) -> VMMutatorThread;
fn barrier(&mut self) -> &mut dyn Barrier<VM>;
// Provided methods
fn flush_remembered_sets(&mut self) { ... }
fn flush(&mut self) { ... }
}
Expand description
Each GC plan should provide their implementation of a MutatorContext. Note that this trait is no longer needed as we removed per-plan mutator implementation and we will remove this trait as well in the future.
Required Methods§
sourcefn prepare(&mut self, tls: VMWorkerThread)
fn prepare(&mut self, tls: VMWorkerThread)
Do the prepare work for this mutator.
sourcefn release(&mut self, tls: VMWorkerThread)
fn release(&mut self, tls: VMWorkerThread)
Do the release work for this mutator.
sourcefn 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
Allocate memory for an object.
Arguments:
size
: the number of bytes required for the object.align
: required alignment for the object.offset
: offset associated with the alignment. The result plus the offset will be aligned to the given alignment.allocator
: the allocation semantic used for this object.
sourcefn 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
The slow path allocation. This is only useful when the binding implements the fast path allocation, and would like to explicitly call the slow path after the fast path allocation fails.
sourcefn post_alloc(
&mut self,
refer: ObjectReference,
bytes: usize,
allocator: AllocationSemantics
)
fn post_alloc( &mut self, refer: ObjectReference, bytes: usize, allocator: AllocationSemantics )
Perform post-allocation actions. For many allocators none are required.
Arguments:
refer
: the newly allocated object.bytes
: the size of the space allocated (in bytes).allocator
: the allocation semantic used.
sourcefn get_tls(&self) -> VMMutatorThread
fn get_tls(&self) -> VMMutatorThread
Get the mutator thread for this mutator context. This is the same value as the argument supplied in
crate::memory_manager::bind_mutator
when this mutator is created.
Provided Methods§
sourcefn flush_remembered_sets(&mut self)
fn flush_remembered_sets(&mut self)
Flush per-mutator remembered sets and create GC work for the remembered sets.