Skip to content

Commit d56085c

Browse files
committed
Monomorphise try_execute_anon_query.
1 parent 85704a4 commit d56085c

File tree

2 files changed

+34
-15
lines changed

2 files changed

+34
-15
lines changed

src/librustc_query_system/query/config.rs

+4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ pub trait QueryConfig<CTX> {
2525
}
2626

2727
pub(crate) struct QueryVtable<CTX: QueryContext, K, V> {
28+
pub anon: bool,
29+
pub dep_kind: CTX::DepKind,
2830
pub eval_always: bool,
2931

3032
// Don't use this method to compute query results, instead use the methods on TyCtxt
@@ -103,6 +105,8 @@ where
103105
Q: QueryDescription<CTX>,
104106
{
105107
const VTABLE: QueryVtable<CTX, Q::Key, Q::Value> = QueryVtable {
108+
anon: Q::ANON,
109+
dep_kind: Q::DEP_KIND,
106110
eval_always: Q::EVAL_ALWAYS,
107111
compute: Q::compute,
108112
hash_result: Q::hash_result,

src/librustc_query_system/query/plumbing.rs

+30-15
Original file line numberDiff line numberDiff line change
@@ -410,21 +410,7 @@ where
410410
}
411411

412412
if Q::ANON {
413-
let prof_timer = tcx.profiler().query_provider();
414-
415-
let ((result, dep_node_index), diagnostics) = with_diagnostics(|diagnostics| {
416-
tcx.start_query(job.id, diagnostics, |tcx| {
417-
tcx.dep_graph().with_anon_task(Q::DEP_KIND, || Q::compute(tcx, key))
418-
})
419-
});
420-
421-
prof_timer.finish_with_query_invocation_id(dep_node_index.into());
422-
423-
tcx.dep_graph().read_index(dep_node_index);
424-
425-
if unlikely!(!diagnostics.is_empty()) {
426-
tcx.store_diagnostics_for_anon_node(dep_node_index, diagnostics);
427-
}
413+
let (result, dep_node_index) = try_execute_anon_query(tcx, key, job.id, &Q::VTABLE);
428414

429415
return job.complete(tcx, result, dep_node_index);
430416
}
@@ -461,6 +447,35 @@ where
461447
result
462448
}
463449

450+
fn try_execute_anon_query<CTX, K, V>(
451+
tcx: CTX,
452+
key: K,
453+
job_id: QueryJobId<CTX::DepKind>,
454+
query: &QueryVtable<CTX, K, V>,
455+
) -> (V, DepNodeIndex)
456+
where
457+
CTX: QueryContext,
458+
{
459+
debug_assert!(query.anon);
460+
let prof_timer = tcx.profiler().query_provider();
461+
462+
let ((result, dep_node_index), diagnostics) = with_diagnostics(|diagnostics| {
463+
tcx.start_query(job_id, diagnostics, |tcx| {
464+
tcx.dep_graph().with_anon_task(query.dep_kind, || query.compute(tcx, key))
465+
})
466+
});
467+
468+
prof_timer.finish_with_query_invocation_id(dep_node_index.into());
469+
470+
tcx.dep_graph().read_index(dep_node_index);
471+
472+
if unlikely!(!diagnostics.is_empty()) {
473+
tcx.store_diagnostics_for_anon_node(dep_node_index, diagnostics);
474+
}
475+
476+
(result, dep_node_index)
477+
}
478+
464479
fn load_from_disk_and_cache_in_memory<CTX, K, V>(
465480
tcx: CTX,
466481
key: K,

0 commit comments

Comments
 (0)