From d56085cbc96aafe9ac2403201edc0a9728a4fea8 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Fri, 6 Mar 2020 22:56:05 +0100 Subject: [PATCH] Monomorphise try_execute_anon_query. --- src/librustc_query_system/query/config.rs | 4 ++ src/librustc_query_system/query/plumbing.rs | 45 ++++++++++++++------- 2 files changed, 34 insertions(+), 15 deletions(-) diff --git a/src/librustc_query_system/query/config.rs b/src/librustc_query_system/query/config.rs index 7a13bbf2299..baf9ca9df7f 100644 --- a/src/librustc_query_system/query/config.rs +++ b/src/librustc_query_system/query/config.rs @@ -25,6 +25,8 @@ pub trait QueryConfig { } pub(crate) struct QueryVtable { + 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 @@ impl QueryVtableExt for Q Q: QueryDescription, { const VTABLE: QueryVtable = QueryVtable { + anon: Q::ANON, + dep_kind: Q::DEP_KIND, eval_always: Q::EVAL_ALWAYS, compute: Q::compute, hash_result: Q::hash_result, diff --git a/src/librustc_query_system/query/plumbing.rs b/src/librustc_query_system/query/plumbing.rs index 4a03c172d3c..f27c508fccf 100644 --- a/src/librustc_query_system/query/plumbing.rs +++ b/src/librustc_query_system/query/plumbing.rs @@ -410,21 +410,7 @@ fn try_execute_query( } 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 @@ fn try_execute_query( result } +fn try_execute_anon_query( + tcx: CTX, + key: K, + job_id: QueryJobId, + query: &QueryVtable, +) -> (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( tcx: CTX, key: K, -- 2.44.0