Skip to content

Commit e4a32a0

Browse files
committed
Monomorphise try_execute_anon_query.
1 parent 87d0eac commit e4a32a0

File tree

2 files changed

+33
-17
lines changed

2 files changed

+33
-17
lines changed

src/librustc/ty/query/config.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ pub trait QueryConfig<'tcx> {
2727
}
2828

2929
pub(crate) struct QueryVtable<'tcx, K, V> {
30+
pub anon: bool,
31+
pub dep_kind: DepKind,
3032
pub eval_always: bool,
3133

3234
// Don't use this method to compute query results, instead use the methods on TyCtxt
@@ -98,6 +100,8 @@ pub(crate) trait QueryDescription<'tcx>: QueryAccessors<'tcx> {
98100

99101
fn reify() -> QueryVtable<'tcx, Self::Key, Self::Value> {
100102
QueryVtable {
103+
anon: Self::ANON,
104+
dep_kind: Self::DEP_KIND,
101105
eval_always: Self::EVAL_ALWAYS,
102106
compute: Self::compute,
103107
hash_result: Self::hash_result,

src/librustc/ty/query/plumbing.rs

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -549,23 +549,7 @@ impl<'tcx> TyCtxt<'tcx> {
549549
}
550550

551551
if Q::ANON {
552-
let prof_timer = self.prof.query_provider();
553-
554-
let ((result, dep_node_index), diagnostics) = with_diagnostics(|diagnostics| {
555-
self.start_query(job.id, diagnostics, |tcx| {
556-
tcx.dep_graph.with_anon_task(Q::DEP_KIND, || Q::compute(tcx, key))
557-
})
558-
});
559-
560-
prof_timer.finish_with_query_invocation_id(dep_node_index.into());
561-
562-
self.dep_graph.read_index(dep_node_index);
563-
564-
if unlikely!(!diagnostics.is_empty()) {
565-
self.queries
566-
.on_disk_cache
567-
.store_diagnostics_for_anon_node(dep_node_index, diagnostics);
568-
}
552+
let (result, dep_node_index) = self.try_execute_anon_query(key, job.id, &Q::reify());
569553

570554
job.complete(&result, dep_node_index);
571555

@@ -604,6 +588,34 @@ impl<'tcx> TyCtxt<'tcx> {
604588
result
605589
}
606590

591+
#[inline(always)]
592+
fn try_execute_anon_query<K, V>(
593+
self,
594+
key: K,
595+
job_id: QueryJobId,
596+
query: &QueryVtable<'tcx, K, V>,
597+
) -> (V, DepNodeIndex) {
598+
assert!(query.anon);
599+
600+
let prof_timer = self.prof.query_provider();
601+
602+
let ((result, dep_node_index), diagnostics) = with_diagnostics(|diagnostics| {
603+
self.start_query(job_id, diagnostics, |tcx| {
604+
tcx.dep_graph.with_anon_task(query.dep_kind, || query.compute(tcx, key))
605+
})
606+
});
607+
608+
prof_timer.finish_with_query_invocation_id(dep_node_index.into());
609+
610+
self.dep_graph.read_index(dep_node_index);
611+
612+
if unlikely!(!diagnostics.is_empty()) {
613+
self.queries.on_disk_cache.store_diagnostics_for_anon_node(dep_node_index, diagnostics);
614+
}
615+
616+
return (result, dep_node_index);
617+
}
618+
607619
fn load_from_disk_and_cache_in_memory<K: Clone, V>(
608620
self,
609621
key: K,

0 commit comments

Comments
 (0)