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 Mar 7, 2020
1 parent 87d0eac commit e4a32a0
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 17 deletions.
4 changes: 4 additions & 0 deletions src/librustc/ty/query/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ pub trait QueryConfig<'tcx> {
}

pub(crate) struct QueryVtable<'tcx, K, V> {
pub anon: bool,
pub dep_kind: DepKind,
pub eval_always: bool,

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

fn reify() -> QueryVtable<'tcx, Self::Key, Self::Value> {
QueryVtable {
anon: Self::ANON,
dep_kind: Self::DEP_KIND,
eval_always: Self::EVAL_ALWAYS,
compute: Self::compute,
hash_result: Self::hash_result,
Expand Down
46 changes: 29 additions & 17 deletions src/librustc/ty/query/plumbing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -549,23 +549,7 @@ impl<'tcx> TyCtxt<'tcx> {
}

if Q::ANON {
let prof_timer = self.prof.query_provider();

let ((result, dep_node_index), diagnostics) = with_diagnostics(|diagnostics| {
self.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());

self.dep_graph.read_index(dep_node_index);

if unlikely!(!diagnostics.is_empty()) {
self.queries
.on_disk_cache
.store_diagnostics_for_anon_node(dep_node_index, diagnostics);
}
let (result, dep_node_index) = self.try_execute_anon_query(key, job.id, &Q::reify());

job.complete(&result, dep_node_index);

Expand Down Expand Up @@ -604,6 +588,34 @@ impl<'tcx> TyCtxt<'tcx> {
result
}

#[inline(always)]
fn try_execute_anon_query<K, V>(
self,
key: K,
job_id: QueryJobId,
query: &QueryVtable<'tcx, K, V>,
) -> (V, DepNodeIndex) {
assert!(query.anon);

let prof_timer = self.prof.query_provider();

let ((result, dep_node_index), diagnostics) = with_diagnostics(|diagnostics| {
self.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());

self.dep_graph.read_index(dep_node_index);

if unlikely!(!diagnostics.is_empty()) {
self.queries.on_disk_cache.store_diagnostics_for_anon_node(dep_node_index, diagnostics);
}

return (result, dep_node_index);
}

fn load_from_disk_and_cache_in_memory<K: Clone, V>(
self,
key: K,
Expand Down

0 comments on commit e4a32a0

Please sign in to comment.