pub trait RootsWorkFactory<SL: Slot>: Clone + Send + 'static {
    // Required methods
    fn create_process_roots_work(&mut self, slots: Vec<SL>);
    fn create_process_pinning_roots_work(&mut self, nodes: Vec<ObjectReference>);
    fn create_process_tpinning_roots_work(
        &mut self,
        nodes: Vec<ObjectReference>
    );
}
Expand description

Root-scanning methods use this trait to create work packets for processing roots.

Notes on the required traits:

  • Clone: The VM may divide one root-scanning call (such as scan_vm_specific_roots) into multiple work packets to scan roots in parallel. In this case, the factory shall be cloned to be given to multiple work packets.

    Cloning may be expensive if a factory contains many states. If the states are immutable, a RootsWorkFactory implementation may hold those states in an Arc field so that multiple factory instances can still share the part held in the Arc even after cloning.

  • Send + ’static: The factory will be given to root-scanning work packets. Because work packets are distributed to and executed on different GC workers, it needs Send to be sent between threads. 'static means it must not have references to variables with limited lifetime (such as local variables), because it needs to be moved between threads.

Required Methods§

source

fn create_process_roots_work(&mut self, slots: Vec<SL>)

Create work packets to handle non-pinned roots. The roots are represented as slots so that they can be updated.

The work packet may update the slots.

Arguments:

  • slots: A vector of slots.
source

fn create_process_pinning_roots_work(&mut self, nodes: Vec<ObjectReference>)

Create work packets to handle non-transitively pinning roots.

The work packet will prevent the objects in nodes from moving, i.e. they will be pinned for the duration of the GC. But it will not prevent the children of those objects from moving.

This method is useful for conservative stack scanning, or VMs that cannot update some of the root slots.

Arguments:

  • nodes: A vector of references to objects pointed by edges from roots.
source

fn create_process_tpinning_roots_work(&mut self, nodes: Vec<ObjectReference>)

Create work packets to handle transitively pinning (TP) roots.

Similar to create_process_pinning_roots_work, this work packet will not move objects in nodes. Unlike create_process_pinning_roots_work, no objects in the transitive closure of nodes will be moved, either.

Arguments:

  • nodes: A vector of references to objects pointed by edges from roots.

Object Safety§

This trait is not object safe.

Implementors§