Utilities for tracing JS-managed values.
The lifetime of DOM objects is managed by the SpiderMonkey Garbage
Collector. A rooted DOM object implementing the interface
Foo is traced
- The GC calls
FooBindingduring the marking phase. (This happens through
JSClass.tracefor non-proxy bindings, and through
Foo::trace()(an implementation of
JSTraceable). This is typically derived via a
#[derive(JSTraceable)]) annotation. Non-JS-managed types have an empty inline
trace()method, achieved via
- For all fields,
trace()on the field. For example, for fields of type
Dom::TraceEdge()with a pointer to the
JSObjectfor the reflector. This notifies the GC, which will add the object to the graph, and will trace that object as well.
- When the GC finishes tracing, it
finalizesany reflectors that were not reachable.
unsafe_no_jsmanaged_fields!() macro adds an empty implementation of
JSTraceable to a datatype.
A vector of items to be rooted with
RootedVec. Guaranteed to be empty when not rooted. Usage:
rooted_vec!(let mut v);or if you have an iterator of
rooted_vec!(let v <- iterator);.
Roots any JSTraceable thing
Holds a set of JSTraceables that need to be rooted
A vector of items that are rooted for the lifetime ’a.
TLV Holds a set of JSTraceables that need to be rooted
A trait to allow tracing (only) DOM objects.
SM Callback that traces the rooted traceables