rustc_query_system::dep_graph::graph

Struct DepGraph

Source
pub struct DepGraph<D: Deps> {
    data: Option<Lrc<DepGraphData<D>>>,
    virtual_dep_node_index: Lrc<AtomicU32>,
}

Fields§

§data: Option<Lrc<DepGraphData<D>>>§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§

Source§

impl<D: Deps> DepGraph<D>

Source

pub fn new( profiler: &SelfProfilerRef, prev_graph: Arc<SerializedDepGraph>, prev_work_products: WorkProductMap, encoder: FileEncoder, record_graph: bool, record_stats: bool, ) -> DepGraph<D>

Source

pub fn new_disabled() -> DepGraph<D>

Source

pub(crate) fn data(&self) -> Option<&DepGraphData<D>>

Source

pub fn is_fully_enabled(&self) -> bool

Returns true if we are actually building the full dep-graph, and false otherwise.

Source

pub fn with_query(&self, f: impl Fn(&DepGraphQuery))

Source

pub fn assert_ignored(&self)

Source

pub fn with_ignore<OP, R>(&self, op: OP) -> R
where OP: FnOnce() -> R,

Source

pub fn with_query_deserialization<OP, R>(&self, op: OP) -> R
where OP: FnOnce() -> R,

Used to wrap the deserialization of a query result from disk, This method enforces that no new DepNodes are created during query result deserialization.

Enforcing this makes the query dep graph simpler - all nodes must be created during the query execution, and should be created from inside the ‘body’ of a query (the implementation provided by a particular compiler crate).

Consider the case of three queries A, B, and C, where A invokes B and B invokes C:

A -> B -> C

Suppose that decoding the result of query B required re-computing the query C. If we did not create a fresh TaskDeps when decoding B, we would still be using the TaskDeps for query A (if we needed to re-execute A). This would cause us to create a new edge A -> C. If this edge did not previously exist in the DepGraph, then we could end up with a different DepGraph at the end of compilation, even if there were no meaningful changes to the overall program (e.g. a newline was added). In addition, this edge might cause a subsequent compilation run to try to force C before marking other necessary nodes green. If C did not exist in the new compilation session, then we could get an ICE. Normally, we would have tried (and failed) to mark some other query green (e.g. item_children) which was used to obtain C, which would prevent us from ever trying to force a nonexistent D.

It might be possible to enforce that all DepNodes read during deserialization already exist in the previous DepGraph. In the above example, we would invoke D during the deserialization of B. Since we correctly create a new TaskDeps from the decoding of B, this would result in an edge B -> D. If that edge already existed (with the same DepPathHashes), then it should be correct to allow the invocation of the query to proceed during deserialization of a query result. We would merely assert that the dep-graph fragment that would have been added by invoking C while decoding B is equivalent to the dep-graph fragment that we already instantiated for B (at the point where we successfully marked B as green).

However, this would require additional complexity in the query infrastructure, and is not currently needed by the decoding of any query results. Should the need arise in the future, we should consider extending the query system with this functionality.

Source

pub fn with_task<Ctxt: HasDepContext<Deps = D>, A: Debug, R>( &self, key: DepNode, cx: Ctxt, arg: A, task: fn(_: Ctxt, _: A) -> R, hash_result: Option<fn(_: &mut StableHashingContext<'_>, _: &R) -> Fingerprint>, ) -> (R, DepNodeIndex)

Source

pub fn with_anon_task<Tcx: DepContext<Deps = D>, OP, R>( &self, cx: Tcx, dep_kind: DepKind, op: OP, ) -> (R, DepNodeIndex)
where OP: FnOnce() -> R,

Source§

impl<D: Deps> DepGraph<D>

Source

pub fn read_index(&self, dep_node_index: DepNodeIndex)

Source

pub fn with_feed_task<Ctxt: DepContext<Deps = D>, A: Debug, R: Debug>( &self, node: DepNode, cx: Ctxt, key: A, result: &R, hash_result: Option<fn(_: &mut StableHashingContext<'_>, _: &R) -> Fingerprint>, ) -> DepNodeIndex

Create a node when we force-feed a value into the query cache. This is used to remove cycles during type-checking const generic parameters.

As usual in the query system, we consider the current state of the calling query only depends on the list of dependencies up to now. As a consequence, the value that this query gives us can only depend on those dependencies too. Therefore, it is sound to use the current dependency set for the created node.

During replay, the order of the nodes is relevant in the dependency graph. So the unchanged replay will mark the caller query before trying to mark this one. If there is a change to report, the caller query will be re-executed before this one.

FIXME: If the code is changed enough for this node to be marked before requiring the caller’s node, we suppose that those changes will be enough to mark this node red and force a recomputation using the “normal” way.

Source§

impl<D: Deps> DepGraph<D>

Source

pub fn dep_node_exists(&self, dep_node: &DepNode) -> bool

Source

pub fn previous_work_product(&self, v: &WorkProductId) -> Option<WorkProduct>

Checks whether a previous work product exists for v and, if so, return the path that leads to it. Used to skip doing work.

Source

pub fn previous_work_products(&self) -> &WorkProductMap

Access the map of work-products created during the cached run. Only used during saving of the dep-graph.

Source

pub fn debug_was_loaded_from_disk(&self, dep_node: DepNode) -> bool

Source

pub(crate) fn register_dep_node_debug_str<F>( &self, dep_node: DepNode, debug_str_gen: F, )
where F: FnOnce() -> String,

Source

pub fn dep_node_debug_str(&self, dep_node: DepNode) -> Option<String>

Source

fn node_color(&self, dep_node: &DepNode) -> Option<DepNodeColor>

Source

pub fn try_mark_green<Qcx: QueryContext<Deps = D>>( &self, qcx: Qcx, dep_node: &DepNode, ) -> Option<(SerializedDepNodeIndex, DepNodeIndex)>

Source§

impl<D: Deps> DepGraph<D>

Source

pub fn is_red(&self, dep_node: &DepNode) -> bool

Returns true if the given node has been marked as red during the current compilation session. Used in various assertions

Source

pub fn is_green(&self, dep_node: &DepNode) -> bool

Returns true if the given node has been marked as green during the current compilation session. Used in various assertions

Source

pub fn exec_cache_promotions<Tcx: DepContext>(&self, tcx: Tcx)

This method loads all on-disk cacheable query results into memory, so they can be written out to the new cache file again. Most query results will already be in memory but in the case where we marked something as green but then did not need the value, that value will never have been loaded from disk.

This method will only load queries that will end up in the disk cache. Other queries will not be executed.

Source

pub fn print_incremental_info(&self)

Source

pub fn finish_encoding(&self) -> FileEncodeResult

Source

pub(crate) fn next_virtual_depnode_index(&self) -> DepNodeIndex

Trait Implementations§

Source§

impl<D: Clone + Deps> Clone for DepGraph<D>

Source§

fn clone(&self) -> DepGraph<D>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<D> DynSend for DepGraph<D>
where D: DynSend,

§

impl<D> DynSync for DepGraph<D>
where D: DynSend,

§

impl<D> Freeze for DepGraph<D>

§

impl<D> !RefUnwindSafe for DepGraph<D>

§

impl<D> !Send for DepGraph<D>

§

impl<D> !Sync for DepGraph<D>

§

impl<D> Unpin for DepGraph<D>

§

impl<D> !UnwindSafe for DepGraph<D>

Blanket Implementations§

Source§

impl<T> Aligned for T

Source§

const ALIGN: Alignment = _

Alignment of Self.
Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T, R> CollectAndApply<T, R> for T

Source§

fn collect_and_apply<I, F>(iter: I, f: F) -> R
where I: Iterator<Item = T>, F: FnOnce(&[T]) -> R,

Equivalent to f(&iter.collect::<Vec<_>>()).

Source§

type Output = R

Source§

impl<T> Filterable for T

Source§

fn filterable( self, filter_name: &'static str, ) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>

Creates a filterable data provider with the given name for debugging. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize = _

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<I, T, U> Upcast<I, U> for T
where U: UpcastFrom<I, T>,

Source§

fn upcast(self, interner: I) -> U

Source§

impl<I, T> UpcastFrom<I, T> for T

Source§

fn upcast_from(from: T, _tcx: I) -> T

Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<Tcx, T> Value<Tcx> for T
where Tcx: DepContext,

Source§

default fn from_cycle_error( tcx: Tcx, cycle_error: &CycleError, _guar: ErrorGuaranteed, ) -> T

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<'a, T> Captures<'a> for T
where T: ?Sized,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

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