Trait mmtk::plan::barriers::Barrier

source ·
pub trait Barrier<VM: VMBinding>: 'static + Send + Downcast {
    // Provided methods
    fn flush(&mut self) { ... }
    fn object_reference_write(
        &mut self,
        src: ObjectReference,
        slot: VM::VMEdge,
        target: ObjectReference
    ) { ... }
    fn object_reference_write_pre(
        &mut self,
        _src: ObjectReference,
        _slot: VM::VMEdge,
        _target: Option<ObjectReference>
    ) { ... }
    fn object_reference_write_post(
        &mut self,
        _src: ObjectReference,
        _slot: VM::VMEdge,
        _target: Option<ObjectReference>
    ) { ... }
    fn object_reference_write_slow(
        &mut self,
        _src: ObjectReference,
        _slot: VM::VMEdge,
        _target: Option<ObjectReference>
    ) { ... }
    fn memory_region_copy(
        &mut self,
        src: VM::VMMemorySlice,
        dst: VM::VMMemorySlice
    ) { ... }
    fn memory_region_copy_pre(
        &mut self,
        _src: VM::VMMemorySlice,
        _dst: VM::VMMemorySlice
    ) { ... }
    fn memory_region_copy_post(
        &mut self,
        _src: VM::VMMemorySlice,
        _dst: VM::VMMemorySlice
    ) { ... }
    fn object_probable_write(&mut self, _obj: ObjectReference) { ... }
}
Expand description

A barrier is a combination of fast-path behaviour + slow-path semantics. This trait exposes generic barrier interfaces. The implementations will define their own fast-path code and slow-path semantics.

Normally, a binding will call these generic barrier interfaces (object_reference_write and memory_region_copy) for subsuming barrier calls.

If a subsuming barrier cannot be easily deployed due to platform limitations, the binding may chosse to call both object_reference_write_pre and object_reference_write_post barrier before and after the store operation.

As a performance optimization, the binding may also choose to port the fast-path to the VM side, and call the slow-path (object_reference_write_slow) only if necessary.

Provided Methods§

source

fn flush(&mut self)

source

fn object_reference_write( &mut self, src: ObjectReference, slot: VM::VMEdge, target: ObjectReference )

Subsuming barrier for object reference write

source

fn object_reference_write_pre( &mut self, _src: ObjectReference, _slot: VM::VMEdge, _target: Option<ObjectReference> )

Full pre-barrier for object reference write

source

fn object_reference_write_post( &mut self, _src: ObjectReference, _slot: VM::VMEdge, _target: Option<ObjectReference> )

Full post-barrier for object reference write

source

fn object_reference_write_slow( &mut self, _src: ObjectReference, _slot: VM::VMEdge, _target: Option<ObjectReference> )

Object reference write slow-path call. This can be called either before or after the store, depend on the concrete barrier implementation.

source

fn memory_region_copy(&mut self, src: VM::VMMemorySlice, dst: VM::VMMemorySlice)

Subsuming barrier for array copy

source

fn memory_region_copy_pre( &mut self, _src: VM::VMMemorySlice, _dst: VM::VMMemorySlice )

Full pre-barrier for array copy

source

fn memory_region_copy_post( &mut self, _src: VM::VMMemorySlice, _dst: VM::VMMemorySlice )

Full post-barrier for array copy

source

fn object_probable_write(&mut self, _obj: ObjectReference)

A pre-barrier indicating that some fields of the object will probably be modified soon. Specifically, the caller should ensure that: * The barrier must called before any field modification. * Some fields (unknown at the time of calling this barrier) might be modified soon, without a write barrier. * There are no safepoints between the barrier call and the field writes.

Example use case for mmtk-openjdk:

The OpenJDK C2 slowpath allocation code can do deoptimization after the allocation and before returning to C2 compiled code. The deoptimization itself contains a safepoint. For generational plans, if a GC happens at this safepoint, the allocated object will be promoted, and all the subsequent field initialization should be recorded.

Implementations§

source§

impl<VM> dyn Barrier<VM>
where VM: Any + 'static + VMBinding,

source

pub fn is<__T: Barrier<VM>>(&self) -> bool

Returns true if the trait object wraps an object of type __T.

source

pub fn downcast<__T: Barrier<VM>>( self: Box<Self> ) -> Result<Box<__T>, Box<Self>>

Returns a boxed object from a boxed trait object if the underlying object is of type __T. Returns the original boxed trait if it isn’t.

source

pub fn downcast_rc<__T: Barrier<VM>>( self: Rc<Self> ) -> Result<Rc<__T>, Rc<Self>>

Returns an Rc-ed object from an Rc-ed trait object if the underlying object is of type __T. Returns the original Rc-ed trait if it isn’t.

source

pub fn downcast_ref<__T: Barrier<VM>>(&self) -> Option<&__T>

Returns a reference to the object within the trait object if it is of type __T, or None if it isn’t.

source

pub fn downcast_mut<__T: Barrier<VM>>(&mut self) -> Option<&mut __T>

Returns a mutable reference to the object within the trait object if it is of type __T, or None if it isn’t.

Implementors§