Skip to content

Commit

Permalink
Use LocalDenseDefIdCache on more queries
Browse files Browse the repository at this point in the history
  • Loading branch information
Zoxc committed Feb 15, 2020
1 parent 0b31698 commit 9247e87
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/librustc/query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ rustc_queries! {
/// Maps from the `DefId` of an item (trait/struct/enum/fn) to its
/// associated generics.
query generics_of(key: DefId) -> &'tcx ty::Generics {
storage(caches::LocalDenseDefIdCacheSelector<&'tcx ty::Generics>)
cache_on_disk_if { key.is_local() }
load_cached(tcx, id) {
let generics: Option<ty::Generics> = tcx.queries.on_disk_cache
Expand All @@ -88,6 +89,7 @@ rustc_queries! {
/// to operate over only the actual where-clauses written by the
/// user.)
query predicates_of(key: DefId) -> ty::GenericPredicates<'tcx> {
storage(caches::LocalDenseDefIdCacheSelector<ty::GenericPredicates<'tcx>>)
cache_on_disk_if { key.is_local() }
}

Expand Down Expand Up @@ -586,23 +588,29 @@ rustc_queries! {
cache_on_disk_if { true }
}

query def_kind(_: DefId) -> Option<DefKind> {}
query def_kind(_: DefId) -> Option<DefKind> {
storage(caches::LocalDenseDefIdCacheSelector<Option<DefKind>>)
}
query def_span(_: DefId) -> Span {
storage(caches::LocalDenseDefIdCacheSelector<Span>)
// FIXME(mw): DefSpans are not really inputs since they are derived from
// HIR. But at the moment HIR hashing still contains some hacks that allow
// to make type debuginfo to be source location independent. Declaring
// DefSpan an input makes sure that changes to these are always detected
// regardless of HIR hashing.
eval_always
}
query lookup_stability(_: DefId) -> Option<&'tcx attr::Stability> {}
query lookup_stability(_: DefId) -> Option<&'tcx attr::Stability> {
storage(caches::LocalDenseDefIdCacheSelector<Option<&'tcx attr::Stability>>)
}
query lookup_const_stability(_: DefId) -> Option<&'tcx attr::ConstStability> {}
query lookup_deprecation_entry(_: DefId) -> Option<DeprecationEntry> {}
query item_attrs(_: DefId) -> Lrc<[ast::Attribute]> {}
}

Codegen {
query codegen_fn_attrs(_: DefId) -> CodegenFnAttrs {
storage(caches::LocalDenseDefIdCacheSelector<CodegenFnAttrs>)
cache_on_disk_if { true }
}
}
Expand Down Expand Up @@ -664,7 +672,9 @@ rustc_queries! {
/// associated types. This is almost always what you want,
/// unless you are doing MIR optimizations, in which case you
/// might want to use `reveal_all()` method to change modes.
query param_env(_: DefId) -> ty::ParamEnv<'tcx> {}
query param_env(_: DefId) -> ty::ParamEnv<'tcx> {
storage(caches::LocalDenseDefIdCacheSelector<ty::ParamEnv<'tcx>>)
}

/// Trait selection queries. These are best used by invoking `ty.is_copy_modulo_regions()`,
/// `ty.is_copy()`, etc, since that will prune the environment where possible.
Expand Down

0 comments on commit 9247e87

Please sign in to comment.