diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2021-01-18 23:53:42 +0100 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2021-02-19 17:51:56 +0100 |
| commit | b27266fdb20dd6f6d58428bcf15771dbaeb18d01 (patch) | |
| tree | ffcf08b18f51c71271e486e0a06cdf14f7314ea6 /compiler/rustc_query_system/src/query | |
| parent | 3bd14c7bbee10aaff2466014ae1c2455010dfafe (diff) | |
| download | rust-b27266fdb20dd6f6d58428bcf15771dbaeb18d01.tar.gz rust-b27266fdb20dd6f6d58428bcf15771dbaeb18d01.zip | |
Use a QueryContext for try_mark_green.
Diffstat (limited to 'compiler/rustc_query_system/src/query')
| -rw-r--r-- | compiler/rustc_query_system/src/query/mod.rs | 24 | ||||
| -rw-r--r-- | compiler/rustc_query_system/src/query/plumbing.rs | 19 |
2 files changed, 31 insertions, 12 deletions
diff --git a/compiler/rustc_query_system/src/query/mod.rs b/compiler/rustc_query_system/src/query/mod.rs index 8d5c9d7bea7..c935e1b9c5c 100644 --- a/compiler/rustc_query_system/src/query/mod.rs +++ b/compiler/rustc_query_system/src/query/mod.rs @@ -14,7 +14,7 @@ pub use self::caches::{ mod config; pub use self::config::{QueryAccessors, QueryConfig, QueryDescription}; -use crate::dep_graph::{DepNode, HasDepContext}; +use crate::dep_graph::{DepNode, DepNodeIndex, HasDepContext, SerializedDepNodeIndex}; use crate::query::job::QueryMap; use rustc_data_structures::stable_hasher::HashStable; @@ -40,6 +40,28 @@ pub trait QueryContext: HasDepContext { /// Load data from the on-disk cache. fn try_load_from_on_disk_cache(&self, dep_node: &DepNode<Self::DepKind>); + /// 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; + + /// Return whether the current session is tainted by errors. + fn has_errors_or_delayed_span_bugs(&self) -> bool; + + /// Return the diagnostic handler. + fn diagnostic(&self) -> &rustc_errors::Handler; + + /// 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>, + ); + /// 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. diff --git a/compiler/rustc_query_system/src/query/plumbing.rs b/compiler/rustc_query_system/src/query/plumbing.rs index 89f1e6511e3..bd22ee2c18b 100644 --- a/compiler/rustc_query_system/src/query/plumbing.rs +++ b/compiler/rustc_query_system/src/query/plumbing.rs @@ -460,7 +460,7 @@ where tcx.dep_context().dep_graph().read_index(dep_node_index); if unlikely!(!diagnostics.is_empty()) { - tcx.dep_context().store_diagnostics_for_anon_node(dep_node_index, diagnostics); + tcx.store_diagnostics_for_anon_node(dep_node_index, diagnostics); } return job.complete(result, dep_node_index); @@ -473,10 +473,7 @@ where // promoted to the current session during // `try_mark_green()`, so we can ignore them here. let loaded = tcx.start_query(job.id, None, || { - let marked = tcx - .dep_context() - .dep_graph() - .try_mark_green_and_read(*tcx.dep_context(), &dep_node); + let marked = tcx.dep_context().dep_graph().try_mark_green_and_read(tcx, &dep_node); marked.map(|(prev_dep_node_index, dep_node_index)| { ( load_from_disk_and_cache_in_memory( @@ -641,7 +638,7 @@ where prof_timer.finish_with_query_invocation_id(dep_node_index.into()); if unlikely!(!diagnostics.is_empty()) && dep_node.kind != DepKind::NULL { - tcx.dep_context().store_diagnostics(dep_node_index, diagnostics); + tcx.store_diagnostics(dep_node_index, diagnostics); } let result = job.complete(result, dep_node_index); @@ -676,7 +673,7 @@ where /// /// Note: The optimization is only available during incr. comp. #[inline(never)] -fn ensure_must_run<CTX, K, V>(tcx: CTX::DepContext, key: &K, query: &QueryVtable<CTX, K, V>) -> bool +fn ensure_must_run<CTX, K, V>(tcx: CTX, key: &K, query: &QueryVtable<CTX, K, V>) -> bool where K: crate::dep_graph::DepNodeParams<CTX::DepContext>, CTX: QueryContext, @@ -688,9 +685,9 @@ where // Ensuring an anonymous query makes no sense assert!(!query.anon); - let dep_node = query.to_dep_node(tcx, key); + let dep_node = query.to_dep_node(*tcx.dep_context(), key); - match tcx.dep_graph().try_mark_green_and_read(tcx, &dep_node) { + match tcx.dep_context().dep_graph().try_mark_green_and_read(tcx, &dep_node) { None => { // A None return from `try_mark_green_and_read` means that this is either // a new dep node or that the dep node has already been marked red. @@ -701,7 +698,7 @@ where true } Some((_, dep_node_index)) => { - tcx.profiler().query_cache_hit(dep_node_index.into()); + tcx.dep_context().profiler().query_cache_hit(dep_node_index.into()); false } } @@ -768,7 +765,7 @@ where { let query = &Q::VTABLE; if let QueryMode::Ensure = mode { - if !ensure_must_run(*tcx.dep_context(), &key, query) { + if !ensure_must_run(tcx, &key, query) { return None; } } |
