Move dep_graph checking into try_load_from_disk_and_cache_in_memory.
This commit is contained in:
parent
2451f42c1d
commit
5e35fadddb
1 changed files with 12 additions and 23 deletions
|
@ -2,8 +2,7 @@
|
||||||
//! generate the actual methods on tcx which find and execute the provider,
|
//! generate the actual methods on tcx which find and execute the provider,
|
||||||
//! manage the caches, and so forth.
|
//! manage the caches, and so forth.
|
||||||
|
|
||||||
use crate::dep_graph::{DepContext, DepKind, DepNode, DepNodeParams};
|
use crate::dep_graph::{DepContext, DepKind, DepNode, DepNodeIndex, DepNodeParams};
|
||||||
use crate::dep_graph::{DepNodeIndex, SerializedDepNodeIndex};
|
|
||||||
use crate::query::caches::QueryCache;
|
use crate::query::caches::QueryCache;
|
||||||
use crate::query::config::{QueryDescription, QueryVtable, QueryVtableExt};
|
use crate::query::config::{QueryDescription, QueryVtable, QueryVtableExt};
|
||||||
use crate::query::job::{
|
use crate::query::job::{
|
||||||
|
@ -496,21 +495,7 @@ where
|
||||||
// promoted to the current session during
|
// promoted to the current session during
|
||||||
// `try_mark_green()`, so we can ignore them here.
|
// `try_mark_green()`, so we can ignore them here.
|
||||||
let loaded = tcx.start_query(job.id, None, || {
|
let loaded = tcx.start_query(job.id, None, || {
|
||||||
let marked = dep_graph.try_mark_green_and_read(tcx, &dep_node);
|
try_load_from_disk_and_cache_in_memory(tcx, key.clone(), &dep_node, query, compute)
|
||||||
marked.map(|(prev_dep_node_index, dep_node_index)| {
|
|
||||||
(
|
|
||||||
load_from_disk_and_cache_in_memory(
|
|
||||||
tcx,
|
|
||||||
key.clone(),
|
|
||||||
prev_dep_node_index,
|
|
||||||
dep_node_index,
|
|
||||||
&dep_node,
|
|
||||||
query,
|
|
||||||
compute,
|
|
||||||
),
|
|
||||||
dep_node_index,
|
|
||||||
)
|
|
||||||
})
|
|
||||||
});
|
});
|
||||||
if let Some((result, dep_node_index)) = loaded {
|
if let Some((result, dep_node_index)) = loaded {
|
||||||
return job.complete(result, dep_node_index);
|
return job.complete(result, dep_node_index);
|
||||||
|
@ -522,21 +507,23 @@ where
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
fn load_from_disk_and_cache_in_memory<CTX, K, V: Debug>(
|
fn try_load_from_disk_and_cache_in_memory<CTX, K, V>(
|
||||||
tcx: CTX,
|
tcx: CTX,
|
||||||
key: K,
|
key: K,
|
||||||
prev_dep_node_index: SerializedDepNodeIndex,
|
|
||||||
dep_node_index: DepNodeIndex,
|
|
||||||
dep_node: &DepNode<CTX::DepKind>,
|
dep_node: &DepNode<CTX::DepKind>,
|
||||||
query: &QueryVtable<CTX, K, V>,
|
query: &QueryVtable<CTX, K, V>,
|
||||||
compute: fn(CTX::DepContext, K) -> V,
|
compute: fn(CTX::DepContext, K) -> V,
|
||||||
) -> V
|
) -> Option<(V, DepNodeIndex)>
|
||||||
where
|
where
|
||||||
CTX: QueryContext,
|
CTX: QueryContext,
|
||||||
|
V: Debug,
|
||||||
{
|
{
|
||||||
// Note this function can be called concurrently from the same query
|
// Note this function can be called concurrently from the same query
|
||||||
// We must ensure that this is handled correctly.
|
// We must ensure that this is handled correctly.
|
||||||
|
|
||||||
|
let (prev_dep_node_index, dep_node_index) =
|
||||||
|
tcx.dep_context().dep_graph().try_mark_green_and_read(tcx, &dep_node)?;
|
||||||
|
|
||||||
debug_assert!(tcx.dep_context().dep_graph().is_green(dep_node));
|
debug_assert!(tcx.dep_context().dep_graph().is_green(dep_node));
|
||||||
|
|
||||||
// First we try to load the result from the on-disk cache.
|
// First we try to load the result from the on-disk cache.
|
||||||
|
@ -558,7 +545,7 @@ where
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(result) = result {
|
let result = if let Some(result) = result {
|
||||||
// If `-Zincremental-verify-ich` is specified, re-hash results from
|
// If `-Zincremental-verify-ich` is specified, re-hash results from
|
||||||
// the cache and make sure that they have the expected fingerprint.
|
// the cache and make sure that they have the expected fingerprint.
|
||||||
if unlikely!(tcx.dep_context().sess().opts.debugging_opts.incremental_verify_ich) {
|
if unlikely!(tcx.dep_context().sess().opts.debugging_opts.incremental_verify_ich) {
|
||||||
|
@ -588,7 +575,9 @@ where
|
||||||
incremental_verify_ich(*tcx.dep_context(), &result, dep_node, query);
|
incremental_verify_ich(*tcx.dep_context(), &result, dep_node, query);
|
||||||
|
|
||||||
result
|
result
|
||||||
}
|
};
|
||||||
|
|
||||||
|
Some((result, dep_node_index))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn incremental_verify_ich<CTX, K, V: Debug>(
|
fn incremental_verify_ich<CTX, K, V: Debug>(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue