From 0a4f3473959411b5488b35cf4cc4379cae69a686 Mon Sep 17 00:00:00 2001 From: Michael Woerister Date: Wed, 17 Jan 2018 16:39:29 +0100 Subject: [PATCH] incr.comp.: Cache generics_of query. --- src/librustc/ty/maps/config.rs | 19 +++++++++++++++++-- src/librustc/ty/maps/on_disk_cache.rs | 1 + src/librustc/ty/maps/plumbing.rs | 1 + 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/librustc/ty/maps/config.rs b/src/librustc/ty/maps/config.rs index 1dad74fb28e..5143654e916 100644 --- a/src/librustc/ty/maps/config.rs +++ b/src/librustc/ty/maps/config.rs @@ -617,8 +617,8 @@ impl<'tcx> QueryDescription<'tcx> for queries::optimized_mir<'tcx> { } fn try_load_from_disk<'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, - id: SerializedDepNodeIndex) - -> Option { + id: SerializedDepNodeIndex) + -> Option { let mir: Option<::mir::Mir<'tcx>> = tcx.on_disk_query_result_cache .try_load_query_result(tcx, id); mir.map(|x| tcx.alloc_mir(x)) @@ -637,6 +637,21 @@ impl<'tcx> QueryDescription<'tcx> for queries::target_features_whitelist<'tcx> { } } +impl<'tcx> QueryDescription<'tcx> for queries::generics_of<'tcx> { + #[inline] + fn cache_on_disk(def_id: Self::Key) -> bool { + def_id.is_local() + } + + fn try_load_from_disk<'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>, + id: SerializedDepNodeIndex) + -> Option { + let generics: Option = tcx.on_disk_query_result_cache + .try_load_query_result(tcx, id); + generics.map(|x| tcx.alloc_generics(x)) + } +} + macro_rules! impl_disk_cacheable_query( ($query_name:ident, |$key:tt| $cond:expr) => { impl<'tcx> QueryDescription<'tcx> for queries::$query_name<'tcx> { diff --git a/src/librustc/ty/maps/on_disk_cache.rs b/src/librustc/ty/maps/on_disk_cache.rs index a489bec5b27..56ed0f9106f 100644 --- a/src/librustc/ty/maps/on_disk_cache.rs +++ b/src/librustc/ty/maps/on_disk_cache.rs @@ -205,6 +205,7 @@ impl<'sess> OnDiskCache<'sess> { let qri = &mut query_result_index; encode_query_results::(tcx, enc, qri)?; + encode_query_results::(tcx, enc, qri)?; encode_query_results::(tcx, enc, qri)?; encode_query_results::(tcx, enc, qri)?; encode_query_results::(tcx, enc, qri)?; diff --git a/src/librustc/ty/maps/plumbing.rs b/src/librustc/ty/maps/plumbing.rs index a0db3c7bca8..3e1b490957c 100644 --- a/src/librustc/ty/maps/plumbing.rs +++ b/src/librustc/ty/maps/plumbing.rs @@ -983,6 +983,7 @@ impl_load_from_cache!( ContainsExternIndicator => contains_extern_indicator, CheckMatch => check_match, TypeOfItem => type_of, + GenericsOfItem => generics_of, PredicatesOfItem => predicates_of, UsedTraitImports => used_trait_imports, );