Monomorphise try_execute_anon_query.

This commit is contained in:
Camille GILLOT 2020-03-06 22:56:05 +01:00
parent 85704a41db
commit d56085cbc9
2 changed files with 34 additions and 15 deletions

View File

@ -25,6 +25,8 @@ pub trait QueryConfig<CTX> {
}
pub(crate) struct QueryVtable<CTX: QueryContext, K, V> {
pub anon: bool,
pub dep_kind: CTX::DepKind,
pub eval_always: bool,
// Don't use this method to compute query results, instead use the methods on TyCtxt
@ -103,6 +105,8 @@ where
Q: QueryDescription<CTX>,
{
const VTABLE: QueryVtable<CTX, Q::Key, Q::Value> = QueryVtable {
anon: Q::ANON,
dep_kind: Q::DEP_KIND,
eval_always: Q::EVAL_ALWAYS,
compute: Q::compute,
hash_result: Q::hash_result,

View File

@ -410,21 +410,7 @@ where
}
if Q::ANON {
let prof_timer = tcx.profiler().query_provider();
let ((result, dep_node_index), diagnostics) = with_diagnostics(|diagnostics| {
tcx.start_query(job.id, diagnostics, |tcx| {
tcx.dep_graph().with_anon_task(Q::DEP_KIND, || Q::compute(tcx, key))
})
});
prof_timer.finish_with_query_invocation_id(dep_node_index.into());
tcx.dep_graph().read_index(dep_node_index);
if unlikely!(!diagnostics.is_empty()) {
tcx.store_diagnostics_for_anon_node(dep_node_index, diagnostics);
}
let (result, dep_node_index) = try_execute_anon_query(tcx, key, job.id, &Q::VTABLE);
return job.complete(tcx, result, dep_node_index);
}
@ -461,6 +447,35 @@ where
result
}
fn try_execute_anon_query<CTX, K, V>(
tcx: CTX,
key: K,
job_id: QueryJobId<CTX::DepKind>,
query: &QueryVtable<CTX, K, V>,
) -> (V, DepNodeIndex)
where
CTX: QueryContext,
{
debug_assert!(query.anon);
let prof_timer = tcx.profiler().query_provider();
let ((result, dep_node_index), diagnostics) = with_diagnostics(|diagnostics| {
tcx.start_query(job_id, diagnostics, |tcx| {
tcx.dep_graph().with_anon_task(query.dep_kind, || query.compute(tcx, key))
})
});
prof_timer.finish_with_query_invocation_id(dep_node_index.into());
tcx.dep_graph().read_index(dep_node_index);
if unlikely!(!diagnostics.is_empty()) {
tcx.store_diagnostics_for_anon_node(dep_node_index, diagnostics);
}
(result, dep_node_index)
}
fn load_from_disk_and_cache_in_memory<CTX, K, V>(
tcx: CTX,
key: K,