]> git.lizzy.rs Git - rust.git/commitdiff
Monomorphise try_execute_anon_query.
authorCamille GILLOT <gillot.camille@gmail.com>
Fri, 6 Mar 2020 21:56:05 +0000 (22:56 +0100)
committerCamille GILLOT <gillot.camille@gmail.com>
Fri, 1 May 2020 12:32:11 +0000 (14:32 +0200)
src/librustc_query_system/query/config.rs
src/librustc_query_system/query/plumbing.rs

index 7a13bbf22999d0fd78fc8135636c5f462e4c546c..baf9ca9df7fb8d97cc6705ac448ea906a73c19b6 100644 (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 @@ impl<CTX, Q> QueryVtableExt<CTX, Q::Key, Q::Value> for Q
     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,
index 4a03c172d3cdad808e7ecb73d5140c55bca5bd48..f27c508fccfee377538e7949575190026bf1fb33 100644 (file)
@@ -410,21 +410,7 @@ fn try_execute_query<Q, CTX>(
     }
 
     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<Q, CTX>(
     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,