Skip to content

Commit 5e35fad

Browse files
committed
Move dep_graph checking into try_load_from_disk_and_cache_in_memory.
1 parent 2451f42 commit 5e35fad

File tree

1 file changed

+12
-23
lines changed

1 file changed

+12
-23
lines changed

compiler/rustc_query_system/src/query/plumbing.rs

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
//! generate the actual methods on tcx which find and execute the provider,
33
//! manage the caches, and so forth.
44
5-
use crate::dep_graph::{DepContext, DepKind, DepNode, DepNodeParams};
6-
use crate::dep_graph::{DepNodeIndex, SerializedDepNodeIndex};
5+
use crate::dep_graph::{DepContext, DepKind, DepNode, DepNodeIndex, DepNodeParams};
76
use crate::query::caches::QueryCache;
87
use crate::query::config::{QueryDescription, QueryVtable, QueryVtableExt};
98
use crate::query::job::{
@@ -496,21 +495,7 @@ where
496495
// promoted to the current session during
497496
// `try_mark_green()`, so we can ignore them here.
498497
let loaded = tcx.start_query(job.id, None, || {
499-
let marked = dep_graph.try_mark_green_and_read(tcx, &dep_node);
500-
marked.map(|(prev_dep_node_index, dep_node_index)| {
501-
(
502-
load_from_disk_and_cache_in_memory(
503-
tcx,
504-
key.clone(),
505-
prev_dep_node_index,
506-
dep_node_index,
507-
&dep_node,
508-
query,
509-
compute,
510-
),
511-
dep_node_index,
512-
)
513-
})
498+
try_load_from_disk_and_cache_in_memory(tcx, key.clone(), &dep_node, query, compute)
514499
});
515500
if let Some((result, dep_node_index)) = loaded {
516501
return job.complete(result, dep_node_index);
@@ -522,21 +507,23 @@ where
522507
result
523508
}
524509

525-
fn load_from_disk_and_cache_in_memory<CTX, K, V: Debug>(
510+
fn try_load_from_disk_and_cache_in_memory<CTX, K, V>(
526511
tcx: CTX,
527512
key: K,
528-
prev_dep_node_index: SerializedDepNodeIndex,
529-
dep_node_index: DepNodeIndex,
530513
dep_node: &DepNode<CTX::DepKind>,
531514
query: &QueryVtable<CTX, K, V>,
532515
compute: fn(CTX::DepContext, K) -> V,
533-
) -> V
516+
) -> Option<(V, DepNodeIndex)>
534517
where
535518
CTX: QueryContext,
519+
V: Debug,
536520
{
537521
// Note this function can be called concurrently from the same query
538522
// We must ensure that this is handled correctly.
539523

524+
let (prev_dep_node_index, dep_node_index) =
525+
tcx.dep_context().dep_graph().try_mark_green_and_read(tcx, &dep_node)?;
526+
540527
debug_assert!(tcx.dep_context().dep_graph().is_green(dep_node));
541528

542529
// First we try to load the result from the on-disk cache.
@@ -558,7 +545,7 @@ where
558545
None
559546
};
560547

561-
if let Some(result) = result {
548+
let result = if let Some(result) = result {
562549
// If `-Zincremental-verify-ich` is specified, re-hash results from
563550
// the cache and make sure that they have the expected fingerprint.
564551
if unlikely!(tcx.dep_context().sess().opts.debugging_opts.incremental_verify_ich) {
@@ -588,7 +575,9 @@ where
588575
incremental_verify_ich(*tcx.dep_context(), &result, dep_node, query);
589576

590577
result
591-
}
578+
};
579+
580+
Some((result, dep_node_index))
592581
}
593582

594583
fn incremental_verify_ich<CTX, K, V: Debug>(

0 commit comments

Comments
 (0)