Trait mmtk::vm::scanning::ObjectTracerContext
source · pub trait ObjectTracerContext<VM: VMBinding>: Clone + Send + 'static {
type TracerType: ObjectTracer;
// Required method
fn with_tracer<R, F>(&self, worker: &mut GCWorker<VM>, func: F) -> R
where F: FnOnce(&mut Self::TracerType) -> R;
}
Expand description
An ObjectTracerContext
gives a GC worker temporary access to an ObjectTracer
, allowing
the GC worker to trace objects. This trait is intended to abstract out the implementation
details of tracing objects, enqueuing objects, and creating work packets that expand the
transitive closure, allowing the VM binding to focus on VM-specific parts.
This trait is used during root scanning and binding-side weak reference processing.
Required Associated Types§
sourcetype TracerType: ObjectTracer
type TracerType: ObjectTracer
The concrete ObjectTracer
type.
FIXME: The current code works because of the unsafe method ProcessEdgesWork::set_worker
.
The tracer should borrow the worker passed to with_queuing_tracer
during its lifetime.
For this reason, TracerType
should have a <'w>
lifetime parameter.
Generic Associated Types (GAT) is already stablized in Rust 1.65.
We should update our toolchain version, too.
Required Methods§
sourcefn with_tracer<R, F>(&self, worker: &mut GCWorker<VM>, func: F) -> Rwhere
F: FnOnce(&mut Self::TracerType) -> R,
fn with_tracer<R, F>(&self, worker: &mut GCWorker<VM>, func: F) -> Rwhere
F: FnOnce(&mut Self::TracerType) -> R,
Create a temporary ObjectTracer
and provide access in the scope of func
.
When the ObjectTracer::trace_object
is called, if the traced object is first visited
in this transitive closure, it will be enqueued. After func
returns, the implememtation
will create work packets to continue computing the transitive closure from the newly
enqueued objects.
API functions that provide QueuingTracerFactory
should document
- on which fields the user is supposed to call
ObjectTracer::trace_object
, and - which work bucket the generated work packet will be added to. Sometimes the user needs to know when the computing of transitive closure finishes.
Arguments:
worker
: The current GC worker.func
: A caller-supplied closure in which the createdObjectTracer
can be used.
Returns: The return value of func
.