Struct rustc_query_system::dep_graph::DepGraph [−][src]
pub struct DepGraph<K: DepKind> {
data: Option<Lrc<DepGraphData<K>>>,
virtual_dep_node_index: Lrc<AtomicU32>,
}
Fields
data: Option<Lrc<DepGraphData<K>>>
virtual_dep_node_index: Lrc<AtomicU32>
This field is used for assigning DepNodeIndices when running in
non-incremental mode. Even in non-incremental mode we make sure that
each task has a DepNodeIndex
that uniquely identifies it. This unique
ID is used for self-profiling.
Implementations
pub fn new(
profiler: &SelfProfilerRef,
prev_graph: SerializedDepGraph<K>,
prev_work_products: FxHashMap<WorkProductId, WorkProduct>,
encoder: FileEncoder,
record_graph: bool,
record_stats: bool
) -> DepGraph<K>
Returns true
if we are actually building the full dep-graph, and false
otherwise.
pub fn with_task<Ctxt: HasDepContext<DepKind = K>, A: Debug, R>(
&self,
key: DepNode<K>,
cx: Ctxt,
arg: A,
task: fn(_: Ctxt, _: A) -> R,
hash_result: Option<fn(_: &mut StableHashingContext<'_>, _: &R) -> Fingerprint>
) -> (R, DepNodeIndex)
pub fn with_task<Ctxt: HasDepContext<DepKind = K>, A: Debug, R>(
&self,
key: DepNode<K>,
cx: Ctxt,
arg: A,
task: fn(_: Ctxt, _: A) -> R,
hash_result: Option<fn(_: &mut StableHashingContext<'_>, _: &R) -> Fingerprint>
) -> (R, DepNodeIndex)
Starts a new dep-graph task. Dep-graph tasks are specified
using a free function (task
) and not a closure – this
is intentional because we want to exercise tight control over
what state they have access to. In particular, we want to
prevent implicit ‘leaks’ of tracked state into the task (which
could then be read without generating correct edges in the
dep-graph – see the rustc dev guide for more details on
the dep-graph). To this end, the task function gets exactly two
pieces of state: the context cx
and an argument arg
. Both
of these bits of state must be of some type that implements
DepGraphSafe
and hence does not leak.
The choice of two arguments is not fundamental. One argument
would work just as well, since multiple values can be
collected using tuples. However, using two arguments works out
to be quite convenient, since it is common to need a context
(cx
) and some argument (e.g., a DefId
identifying what
item to process).
For cases where you need some other number of arguments:
- If you only need one argument, just use
()
for thearg
parameter. - If you need 3+ arguments, use a tuple for the
arg
parameter.
fn with_task_impl<Ctxt: HasDepContext<DepKind = K>, A: Debug, R>(
&self,
key: DepNode<K>,
cx: Ctxt,
arg: A,
task: fn(_: Ctxt, _: A) -> R,
hash_result: Option<fn(_: &mut StableHashingContext<'_>, _: &R) -> Fingerprint>
) -> (R, DepNodeIndex)
pub fn with_anon_task<Ctxt: DepContext<DepKind = K>, OP, R>(
&self,
cx: Ctxt,
dep_kind: K,
op: OP
) -> (R, DepNodeIndex) where
OP: FnOnce() -> R,
pub fn with_anon_task<Ctxt: DepContext<DepKind = K>, OP, R>(
&self,
cx: Ctxt,
dep_kind: K,
op: OP
) -> (R, DepNodeIndex) where
OP: FnOnce() -> R,
Executes something within an “anonymous” task, that is, a task the
DepNode
of which is determined by the list of inputs it read from.
Checks whether a previous work product exists for v
and, if
so, return the path that leads to it. Used to skip doing work.
Access the map of work-products created during the cached run. Only used during saving of the dep-graph.
pub fn register_dep_node_debug_str<F>(
&self,
dep_node: DepNode<K>,
debug_str_gen: F
) where
F: FnOnce() -> String,
pub fn try_mark_green<Ctxt: QueryContext<DepKind = K>>(
&self,
tcx: Ctxt,
dep_node: &DepNode<K>
) -> Option<(SerializedDepNodeIndex, DepNodeIndex)>
pub fn try_mark_green<Ctxt: QueryContext<DepKind = K>>(
&self,
tcx: Ctxt,
dep_node: &DepNode<K>
) -> Option<(SerializedDepNodeIndex, DepNodeIndex)>
Try to mark a node index for the node dep_node.
A node will have an index, when it’s already been marked green, or when we can mark it green. This function will mark the current task as a reader of the specified node, when a node index can be found for that node.
fn try_mark_parent_green<Ctxt: QueryContext<DepKind = K>>(
&self,
tcx: Ctxt,
data: &DepGraphData<K>,
parent_dep_node_index: SerializedDepNodeIndex,
dep_node: &DepNode<K>
) -> Option<()>
fn try_mark_previous_green<Ctxt: QueryContext<DepKind = K>>(
&self,
tcx: Ctxt,
data: &DepGraphData<K>,
prev_dep_node_index: SerializedDepNodeIndex,
dep_node: &DepNode<K>
) -> Option<DepNodeIndex>
fn try_mark_previous_green<Ctxt: QueryContext<DepKind = K>>(
&self,
tcx: Ctxt,
data: &DepGraphData<K>,
prev_dep_node_index: SerializedDepNodeIndex,
dep_node: &DepNode<K>
) -> Option<DepNodeIndex>
Try to mark a dep-node which existed in the previous compilation session as green.
fn emit_side_effects<Ctxt: QueryContext<DepKind = K>>(
&self,
tcx: Ctxt,
data: &DepGraphData<K>,
dep_node_index: DepNodeIndex,
side_effects: QuerySideEffects
)
fn emit_side_effects<Ctxt: QueryContext<DepKind = K>>(
&self,
tcx: Ctxt,
data: &DepGraphData<K>,
dep_node_index: DepNodeIndex,
side_effects: QuerySideEffects
)
Atomically emits some loaded diagnostics. This may be called concurrently on multiple threads for the same dep node.
Trait Implementations
Auto Trait Implementations
impl<K> !RefUnwindSafe for DepGraph<K>
impl<K> !UnwindSafe for DepGraph<K>
Blanket Implementations
Mutably borrows from an owned value. Read more
Layout
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference’s “Type Layout” chapter for details on type layout guarantees.
Size: 16 bytes