Skip to content

Commit

Permalink
Monomorphise try_execute_anon_query.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjgillot committed May 1, 2020
1 parent 85704a4 commit d56085c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 15 deletions.
4 changes: 4 additions & 0 deletions src/librustc_query_system/query/config.rs
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down
45 changes: 30 additions & 15 deletions src/librustc_query_system/query/plumbing.rs
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit d56085c

Please sign in to comment.