Trait mmtk::vm::Finalizable

source ·
pub trait Finalizable: Debug + Send {
    // Required methods
    fn get_reference(&self) -> ObjectReference;
    fn set_reference(&mut self, object: ObjectReference);
    fn keep_alive<E: ProcessEdgesWork>(&mut self, trace: &mut E);
}
Expand description

A finalizable object for MMTk. MMTk needs to know the actual object reference in the type, while a binding can use this type to store some runtime information about finalizable objects. For example, for bindings that allows multiple finalizer methods with one object, they can define the type as a tuple of (object, finalize method), and register different finalizer methods to MMTk for the same object. The implementation should mark theird method implementations as inline for performance.

Required Methods§

source

fn get_reference(&self) -> ObjectReference

Load the object reference.

source

fn set_reference(&mut self, object: ObjectReference)

Store the object reference.

source

fn keep_alive<E: ProcessEdgesWork>(&mut self, trace: &mut E)

Keep the heap references in the finalizable object alive. For example, the reference itself needs to be traced. However, if the finalizable object includes other heap references, the implementation should trace them as well. Note that trace_object() may move objects so we need to write the new reference in case that it is moved.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl Finalizable for ObjectReference

This provides an implementation of Finalizable for ObjectReference. Most bindings should be able to use ObjectReference as ReferenceGlue::FinalizableType.