2017-09-18 09:40:13 +00:00
|
|
|
mod plumbing;
|
2020-03-19 13:13:31 +00:00
|
|
|
pub use self::plumbing::*;
|
2020-02-15 08:48:10 +00:00
|
|
|
|
2018-03-15 09:03:36 +00:00
|
|
|
mod job;
|
2019-01-28 14:51:47 +00:00
|
|
|
#[cfg(parallel_compiler)]
|
2020-03-19 13:13:31 +00:00
|
|
|
pub use self::job::deadlock;
|
2020-11-28 23:39:34 +00:00
|
|
|
pub use self::job::{print_query_stack, QueryInfo, QueryJob, QueryJobId, QueryJobInfo, QueryMap};
|
2017-09-14 03:26:39 +00:00
|
|
|
|
2020-02-08 06:38:00 +00:00
|
|
|
mod caches;
|
2020-03-27 17:46:25 +00:00
|
|
|
pub use self::caches::{
|
|
|
|
ArenaCacheSelector, CacheSelector, DefaultCacheSelector, QueryCache, QueryStorage,
|
|
|
|
};
|
2020-02-08 06:38:00 +00:00
|
|
|
|
2017-09-18 09:40:13 +00:00
|
|
|
mod config;
|
2020-03-27 06:43:11 +00:00
|
|
|
pub use self::config::{QueryAccessors, QueryConfig, QueryDescription};
|
|
|
|
|
2021-01-18 22:53:42 +00:00
|
|
|
use crate::dep_graph::{DepNode, DepNodeIndex, HasDepContext, SerializedDepNodeIndex};
|
2020-03-27 06:43:11 +00:00
|
|
|
|
2020-11-28 21:48:05 +00:00
|
|
|
use rustc_data_structures::fingerprint::Fingerprint;
|
|
|
|
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
|
2020-03-27 06:43:11 +00:00
|
|
|
use rustc_data_structures::sync::Lock;
|
|
|
|
use rustc_data_structures::thin_vec::ThinVec;
|
|
|
|
use rustc_errors::Diagnostic;
|
|
|
|
use rustc_span::def_id::DefId;
|
2020-11-28 21:48:05 +00:00
|
|
|
use rustc_span::Span;
|
2020-03-27 06:43:11 +00:00
|
|
|
|
2020-11-28 21:48:05 +00:00
|
|
|
/// Description of a frame in the query stack.
|
|
|
|
///
|
|
|
|
/// This is mostly used in case of cycles for error reporting.
|
|
|
|
#[derive(Clone, Debug)]
|
|
|
|
pub struct QueryStackFrame {
|
|
|
|
pub name: &'static str,
|
|
|
|
pub description: String,
|
|
|
|
span: Option<Span>,
|
|
|
|
/// This hash is used to deterministically pick
|
|
|
|
/// a query to remove cycles in the parallel compiler.
|
|
|
|
hash: Fingerprint,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl QueryStackFrame {
|
|
|
|
#[inline]
|
|
|
|
pub fn new(
|
|
|
|
name: &'static str,
|
|
|
|
description: String,
|
|
|
|
span: Option<Span>,
|
|
|
|
hash: Fingerprint,
|
|
|
|
) -> Self {
|
|
|
|
Self { name, hash, description, span }
|
|
|
|
}
|
|
|
|
|
|
|
|
// FIXME(eddyb) Get more valid `Span`s on queries.
|
|
|
|
#[inline]
|
|
|
|
pub fn default_span(&self, span: Span) -> Span {
|
|
|
|
if !span.is_dummy() {
|
|
|
|
return span;
|
|
|
|
}
|
|
|
|
self.span.unwrap_or(span)
|
|
|
|
}
|
|
|
|
}
|
2020-03-27 06:43:11 +00:00
|
|
|
|
2020-11-28 21:48:05 +00:00
|
|
|
impl<CTX> HashStable<CTX> for QueryStackFrame {
|
|
|
|
fn hash_stable(&self, hcx: &mut CTX, hasher: &mut StableHasher) {
|
|
|
|
self.hash.hash_stable(hcx, hasher)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub trait QueryContext: HasDepContext {
|
2020-03-27 06:43:11 +00:00
|
|
|
/// Get string representation from DefPath.
|
|
|
|
fn def_path_str(&self, def_id: DefId) -> String;
|
|
|
|
|
|
|
|
/// Get the query information from the TLS context.
|
|
|
|
fn current_query_job(&self) -> Option<QueryJobId<Self::DepKind>>;
|
|
|
|
|
2020-11-28 21:48:05 +00:00
|
|
|
fn try_collect_active_jobs(&self) -> Option<QueryMap<Self::DepKind>>;
|
2020-03-27 06:43:11 +00:00
|
|
|
|
2021-01-05 17:37:42 +00:00
|
|
|
/// Load data from the on-disk cache.
|
|
|
|
fn try_load_from_on_disk_cache(&self, dep_node: &DepNode<Self::DepKind>);
|
|
|
|
|
2021-01-18 22:53:42 +00:00
|
|
|
/// Try to force a dep node to execute and see if it's green.
|
|
|
|
fn try_force_from_dep_node(&self, dep_node: &DepNode<Self::DepKind>) -> bool;
|
|
|
|
|
|
|
|
/// Load diagnostics associated to the node in the previous session.
|
|
|
|
fn load_diagnostics(&self, prev_dep_node_index: SerializedDepNodeIndex) -> Vec<Diagnostic>;
|
|
|
|
|
|
|
|
/// Register diagnostics for the given node, for use in next session.
|
|
|
|
fn store_diagnostics(&self, dep_node_index: DepNodeIndex, diagnostics: ThinVec<Diagnostic>);
|
|
|
|
|
|
|
|
/// Register diagnostics for the given node, for use in next session.
|
|
|
|
fn store_diagnostics_for_anon_node(
|
|
|
|
&self,
|
|
|
|
dep_node_index: DepNodeIndex,
|
|
|
|
diagnostics: ThinVec<Diagnostic>,
|
|
|
|
);
|
|
|
|
|
2020-03-27 06:43:11 +00:00
|
|
|
/// Executes a job by changing the `ImplicitCtxt` to point to the
|
|
|
|
/// new query job while it executes. It returns the diagnostics
|
|
|
|
/// captured during execution and the actual result.
|
|
|
|
fn start_query<R>(
|
|
|
|
&self,
|
|
|
|
token: QueryJobId<Self::DepKind>,
|
|
|
|
diagnostics: Option<&Lock<ThinVec<Diagnostic>>>,
|
2020-10-18 19:01:36 +00:00
|
|
|
compute: impl FnOnce() -> R,
|
2020-03-27 06:43:11 +00:00
|
|
|
) -> R;
|
|
|
|
}
|