Some minor perf improvements
This commit is contained in:
parent
51ac6de6f3
commit
06aaf20f10
@ -44,6 +44,7 @@ pub trait Upcast<T: ?Sized> {
|
||||
}
|
||||
|
||||
pub const DEFAULT_PARSE_LRU_CAP: usize = 128;
|
||||
pub const DEFAULT_BORROWCK_LRU_CAP: usize = 256;
|
||||
|
||||
pub trait FileLoader {
|
||||
/// Text of the file.
|
||||
|
@ -107,11 +107,11 @@ impl TypeOrConstParamData {
|
||||
impl_from!(TypeParamData, ConstParamData for TypeOrConstParamData);
|
||||
|
||||
/// Data about the generic parameters of a function, struct, impl, etc.
|
||||
#[derive(Clone, PartialEq, Eq, Debug, Default, Hash)]
|
||||
#[derive(Clone, PartialEq, Eq, Debug, Hash)]
|
||||
pub struct GenericParams {
|
||||
pub type_or_consts: Arena<TypeOrConstParamData>,
|
||||
pub lifetimes: Arena<LifetimeParamData>,
|
||||
pub where_predicates: Vec<WherePredicate>,
|
||||
pub where_predicates: Box<[WherePredicate]>,
|
||||
}
|
||||
|
||||
/// A single predicate from a where clause, i.e. `where Type: Trait`. Combined
|
||||
@ -142,109 +142,14 @@ pub enum WherePredicateTypeTarget {
|
||||
TypeOrConstParam(LocalTypeOrConstParamId),
|
||||
}
|
||||
|
||||
impl GenericParams {
|
||||
/// Iterator of type_or_consts field
|
||||
pub fn iter(
|
||||
&self,
|
||||
) -> impl DoubleEndedIterator<Item = (Idx<TypeOrConstParamData>, &TypeOrConstParamData)> {
|
||||
self.type_or_consts.iter()
|
||||
}
|
||||
|
||||
pub(crate) fn generic_params_query(
|
||||
db: &dyn DefDatabase,
|
||||
def: GenericDefId,
|
||||
) -> Interned<GenericParams> {
|
||||
let _p = profile::span("generic_params_query");
|
||||
|
||||
let krate = def.module(db).krate;
|
||||
let cfg_options = db.crate_graph();
|
||||
let cfg_options = &cfg_options[krate].cfg_options;
|
||||
|
||||
// Returns the generic parameters that are enabled under the current `#[cfg]` options
|
||||
let enabled_params = |params: &Interned<GenericParams>, item_tree: &ItemTree| {
|
||||
let enabled = |param| item_tree.attrs(db, krate, param).is_cfg_enabled(cfg_options);
|
||||
|
||||
// In the common case, no parameters will by disabled by `#[cfg]` attributes.
|
||||
// Therefore, make a first pass to check if all parameters are enabled and, if so,
|
||||
// clone the `Interned<GenericParams>` instead of recreating an identical copy.
|
||||
let all_type_or_consts_enabled =
|
||||
params.type_or_consts.iter().all(|(idx, _)| enabled(idx.into()));
|
||||
let all_lifetimes_enabled = params.lifetimes.iter().all(|(idx, _)| enabled(idx.into()));
|
||||
|
||||
if all_type_or_consts_enabled && all_lifetimes_enabled {
|
||||
params.clone()
|
||||
} else {
|
||||
Interned::new(GenericParams {
|
||||
type_or_consts: all_type_or_consts_enabled
|
||||
.then(|| params.type_or_consts.clone())
|
||||
.unwrap_or_else(|| {
|
||||
params
|
||||
.type_or_consts
|
||||
.iter()
|
||||
.filter_map(|(idx, param)| {
|
||||
enabled(idx.into()).then(|| param.clone())
|
||||
})
|
||||
.collect()
|
||||
}),
|
||||
lifetimes: all_lifetimes_enabled
|
||||
.then(|| params.lifetimes.clone())
|
||||
.unwrap_or_else(|| {
|
||||
params
|
||||
.lifetimes
|
||||
.iter()
|
||||
.filter_map(|(idx, param)| {
|
||||
enabled(idx.into()).then(|| param.clone())
|
||||
})
|
||||
.collect()
|
||||
}),
|
||||
where_predicates: params.where_predicates.clone(),
|
||||
})
|
||||
}
|
||||
};
|
||||
macro_rules! id_to_generics {
|
||||
($id:ident) => {{
|
||||
let id = $id.lookup(db).id;
|
||||
let tree = id.item_tree(db);
|
||||
let item = &tree[id.value];
|
||||
enabled_params(&item.generic_params, &tree)
|
||||
}};
|
||||
}
|
||||
|
||||
match def {
|
||||
GenericDefId::FunctionId(id) => {
|
||||
let loc = id.lookup(db);
|
||||
let tree = loc.id.item_tree(db);
|
||||
let item = &tree[loc.id.value];
|
||||
|
||||
let enabled_params = enabled_params(&item.explicit_generic_params, &tree);
|
||||
let mut generic_params = GenericParams::clone(&enabled_params);
|
||||
|
||||
let module = loc.container.module(db);
|
||||
let func_data = db.function_data(id);
|
||||
|
||||
// Don't create an `Expander` if not needed since this
|
||||
// could cause a reparse after the `ItemTree` has been created due to the spanmap.
|
||||
let mut expander =
|
||||
Lazy::new(|| (module.def_map(db), Expander::new(db, loc.id.file_id(), module)));
|
||||
for param in func_data.params.iter() {
|
||||
generic_params.fill_implicit_impl_trait_args(db, &mut expander, param);
|
||||
}
|
||||
|
||||
Interned::new(generic_params)
|
||||
}
|
||||
GenericDefId::AdtId(AdtId::StructId(id)) => id_to_generics!(id),
|
||||
GenericDefId::AdtId(AdtId::EnumId(id)) => id_to_generics!(id),
|
||||
GenericDefId::AdtId(AdtId::UnionId(id)) => id_to_generics!(id),
|
||||
GenericDefId::TraitId(id) => id_to_generics!(id),
|
||||
GenericDefId::TraitAliasId(id) => id_to_generics!(id),
|
||||
GenericDefId::TypeAliasId(id) => id_to_generics!(id),
|
||||
GenericDefId::ImplId(id) => id_to_generics!(id),
|
||||
GenericDefId::EnumVariantId(_) | GenericDefId::ConstId(_) => {
|
||||
Interned::new(GenericParams::default())
|
||||
}
|
||||
}
|
||||
}
|
||||
#[derive(Clone, Default)]
|
||||
pub(crate) struct GenericParamsCollector {
|
||||
pub type_or_consts: Arena<TypeOrConstParamData>,
|
||||
pub lifetimes: Arena<LifetimeParamData>,
|
||||
pub where_predicates: Vec<WherePredicate>,
|
||||
}
|
||||
|
||||
impl GenericParamsCollector {
|
||||
pub(crate) fn fill(
|
||||
&mut self,
|
||||
lower_ctx: &LowerCtx<'_>,
|
||||
@ -444,11 +349,131 @@ impl GenericParams {
|
||||
});
|
||||
}
|
||||
|
||||
pub(crate) fn shrink_to_fit(&mut self) {
|
||||
let Self { lifetimes, type_or_consts: types, where_predicates } = self;
|
||||
pub(crate) fn finish(self) -> GenericParams {
|
||||
let Self { mut lifetimes, mut type_or_consts, where_predicates } = self;
|
||||
lifetimes.shrink_to_fit();
|
||||
types.shrink_to_fit();
|
||||
where_predicates.shrink_to_fit();
|
||||
type_or_consts.shrink_to_fit();
|
||||
GenericParams {
|
||||
type_or_consts,
|
||||
lifetimes,
|
||||
where_predicates: where_predicates.into_boxed_slice(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl GenericParams {
|
||||
/// Iterator of type_or_consts field
|
||||
pub fn iter(
|
||||
&self,
|
||||
) -> impl DoubleEndedIterator<Item = (Idx<TypeOrConstParamData>, &TypeOrConstParamData)> {
|
||||
self.type_or_consts.iter()
|
||||
}
|
||||
|
||||
pub(crate) fn generic_params_query(
|
||||
db: &dyn DefDatabase,
|
||||
def: GenericDefId,
|
||||
) -> Interned<GenericParams> {
|
||||
let _p = profile::span("generic_params_query");
|
||||
|
||||
let krate = def.module(db).krate;
|
||||
let cfg_options = db.crate_graph();
|
||||
let cfg_options = &cfg_options[krate].cfg_options;
|
||||
|
||||
// Returns the generic parameters that are enabled under the current `#[cfg]` options
|
||||
let enabled_params = |params: &Interned<GenericParams>, item_tree: &ItemTree| {
|
||||
let enabled = |param| item_tree.attrs(db, krate, param).is_cfg_enabled(cfg_options);
|
||||
|
||||
// In the common case, no parameters will by disabled by `#[cfg]` attributes.
|
||||
// Therefore, make a first pass to check if all parameters are enabled and, if so,
|
||||
// clone the `Interned<GenericParams>` instead of recreating an identical copy.
|
||||
let all_type_or_consts_enabled =
|
||||
params.type_or_consts.iter().all(|(idx, _)| enabled(idx.into()));
|
||||
let all_lifetimes_enabled = params.lifetimes.iter().all(|(idx, _)| enabled(idx.into()));
|
||||
|
||||
if all_type_or_consts_enabled && all_lifetimes_enabled {
|
||||
params.clone()
|
||||
} else {
|
||||
Interned::new(GenericParams {
|
||||
type_or_consts: all_type_or_consts_enabled
|
||||
.then(|| params.type_or_consts.clone())
|
||||
.unwrap_or_else(|| {
|
||||
params
|
||||
.type_or_consts
|
||||
.iter()
|
||||
.filter_map(|(idx, param)| {
|
||||
enabled(idx.into()).then(|| param.clone())
|
||||
})
|
||||
.collect()
|
||||
}),
|
||||
lifetimes: all_lifetimes_enabled
|
||||
.then(|| params.lifetimes.clone())
|
||||
.unwrap_or_else(|| {
|
||||
params
|
||||
.lifetimes
|
||||
.iter()
|
||||
.filter_map(|(idx, param)| {
|
||||
enabled(idx.into()).then(|| param.clone())
|
||||
})
|
||||
.collect()
|
||||
}),
|
||||
where_predicates: params.where_predicates.clone(),
|
||||
})
|
||||
}
|
||||
};
|
||||
macro_rules! id_to_generics {
|
||||
($id:ident) => {{
|
||||
let id = $id.lookup(db).id;
|
||||
let tree = id.item_tree(db);
|
||||
let item = &tree[id.value];
|
||||
enabled_params(&item.generic_params, &tree)
|
||||
}};
|
||||
}
|
||||
|
||||
match def {
|
||||
GenericDefId::FunctionId(id) => {
|
||||
let loc = id.lookup(db);
|
||||
let tree = loc.id.item_tree(db);
|
||||
let item = &tree[loc.id.value];
|
||||
|
||||
let enabled_params = enabled_params(&item.explicit_generic_params, &tree);
|
||||
|
||||
let module = loc.container.module(db);
|
||||
let func_data = db.function_data(id);
|
||||
if func_data.params.is_empty() {
|
||||
enabled_params
|
||||
} else {
|
||||
let mut generic_params = GenericParamsCollector {
|
||||
type_or_consts: enabled_params.type_or_consts.clone(),
|
||||
lifetimes: enabled_params.lifetimes.clone(),
|
||||
where_predicates: enabled_params.where_predicates.clone().into(),
|
||||
};
|
||||
|
||||
// Don't create an `Expander` if not needed since this
|
||||
// could cause a reparse after the `ItemTree` has been created due to the spanmap.
|
||||
let mut expander = Lazy::new(|| {
|
||||
(module.def_map(db), Expander::new(db, loc.id.file_id(), module))
|
||||
});
|
||||
for param in func_data.params.iter() {
|
||||
generic_params.fill_implicit_impl_trait_args(db, &mut expander, param);
|
||||
}
|
||||
Interned::new(generic_params.finish())
|
||||
}
|
||||
}
|
||||
GenericDefId::AdtId(AdtId::StructId(id)) => id_to_generics!(id),
|
||||
GenericDefId::AdtId(AdtId::EnumId(id)) => id_to_generics!(id),
|
||||
GenericDefId::AdtId(AdtId::UnionId(id)) => id_to_generics!(id),
|
||||
GenericDefId::TraitId(id) => id_to_generics!(id),
|
||||
GenericDefId::TraitAliasId(id) => id_to_generics!(id),
|
||||
GenericDefId::TypeAliasId(id) => id_to_generics!(id),
|
||||
GenericDefId::ImplId(id) => id_to_generics!(id),
|
||||
GenericDefId::EnumVariantId(_) | GenericDefId::ConstId(_) => {
|
||||
Interned::new(GenericParams {
|
||||
type_or_consts: Default::default(),
|
||||
lifetimes: Default::default(),
|
||||
where_predicates: Default::default(),
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn find_type_by_name(&self, name: &Name, parent: GenericDefId) -> Option<TypeParamId> {
|
||||
|
@ -116,8 +116,7 @@ pub enum TypeRef {
|
||||
Path(Path),
|
||||
RawPtr(Box<TypeRef>, Mutability),
|
||||
Reference(Box<TypeRef>, Option<LifetimeRef>, Mutability),
|
||||
// FIXME: for full const generics, the latter element (length) here is going to have to be an
|
||||
// expression that is further lowered later in hir_ty.
|
||||
// FIXME: This should be Array(Box<TypeRef>, Ast<ConstArg>),
|
||||
Array(Box<TypeRef>, ConstRef),
|
||||
Slice(Box<TypeRef>),
|
||||
/// A fn pointer. Last element of the vector is the return type.
|
||||
|
@ -6,7 +6,7 @@ use hir_expand::{ast_id_map::AstIdMap, span_map::SpanMapRef, HirFileId};
|
||||
use syntax::ast::{self, HasModuleItem, HasTypeBounds};
|
||||
|
||||
use crate::{
|
||||
generics::{GenericParams, TypeParamData, TypeParamProvenance},
|
||||
generics::{GenericParams, GenericParamsCollector, TypeParamData, TypeParamProvenance},
|
||||
type_ref::{LifetimeRef, TraitBoundModifier, TraitRef},
|
||||
LocalLifetimeParamId, LocalTypeOrConstParamId,
|
||||
};
|
||||
@ -386,17 +386,16 @@ impl<'a> Ctx<'a> {
|
||||
flags |= FnFlags::HAS_UNSAFE_KW;
|
||||
}
|
||||
|
||||
let mut res = Function {
|
||||
let res = Function {
|
||||
name,
|
||||
visibility,
|
||||
explicit_generic_params: Interned::new(GenericParams::default()),
|
||||
explicit_generic_params: self.lower_generic_params(HasImplicitSelf::No, func),
|
||||
abi,
|
||||
params,
|
||||
ret_type: Interned::new(ret_type),
|
||||
ast_id,
|
||||
flags,
|
||||
};
|
||||
res.explicit_generic_params = self.lower_generic_params(HasImplicitSelf::No, func);
|
||||
|
||||
Some(id(self.data().functions.alloc(res)))
|
||||
}
|
||||
@ -604,7 +603,7 @@ impl<'a> Ctx<'a> {
|
||||
has_implicit_self: HasImplicitSelf,
|
||||
node: &dyn ast::HasGenericParams,
|
||||
) -> Interned<GenericParams> {
|
||||
let mut generics = GenericParams::default();
|
||||
let mut generics = GenericParamsCollector::default();
|
||||
|
||||
if let HasImplicitSelf::Yes(bounds) = has_implicit_self {
|
||||
// Traits and trait aliases get the Self type as an implicit first type parameter.
|
||||
@ -642,8 +641,7 @@ impl<'a> Ctx<'a> {
|
||||
};
|
||||
generics.fill(&self.body_ctx, node, add_param_attrs);
|
||||
|
||||
generics.shrink_to_fit();
|
||||
Interned::new(generics)
|
||||
Interned::new(generics.finish())
|
||||
}
|
||||
|
||||
fn lower_type_bounds(&mut self, node: &dyn ast::HasTypeBounds) -> Box<[Interned<TypeBound>]> {
|
||||
|
@ -1601,7 +1601,7 @@ fn implicitly_sized_clauses<'a>(
|
||||
pub(crate) fn generic_defaults_query(
|
||||
db: &dyn HirDatabase,
|
||||
def: GenericDefId,
|
||||
) -> Arc<[Binders<chalk_ir::GenericArg<Interner>>]> {
|
||||
) -> Arc<[Binders<crate::GenericArg>]> {
|
||||
let resolver = def.resolver(db.upcast());
|
||||
let ctx = TyLoweringContext::new(db, &resolver, def.into())
|
||||
.with_type_param_mode(ParamLoweringMode::Variable);
|
||||
|
@ -132,34 +132,33 @@ pub(crate) const ALL_FLOAT_FPS: [TyFingerprint; 2] = [
|
||||
TyFingerprint::Scalar(Scalar::Float(FloatTy::F64)),
|
||||
];
|
||||
|
||||
type TraitFpMap = FxHashMap<TraitId, FxHashMap<Option<TyFingerprint>, Box<[ImplId]>>>;
|
||||
type TraitFpMapCollector = FxHashMap<TraitId, FxHashMap<Option<TyFingerprint>, Vec<ImplId>>>;
|
||||
|
||||
/// Trait impls defined or available in some crate.
|
||||
#[derive(Debug, Eq, PartialEq)]
|
||||
pub struct TraitImpls {
|
||||
// If the `Option<TyFingerprint>` is `None`, the impl may apply to any self type.
|
||||
map: FxHashMap<TraitId, FxHashMap<Option<TyFingerprint>, Vec<ImplId>>>,
|
||||
map: TraitFpMap,
|
||||
}
|
||||
|
||||
impl TraitImpls {
|
||||
pub(crate) fn trait_impls_in_crate_query(db: &dyn HirDatabase, krate: CrateId) -> Arc<Self> {
|
||||
let _p = profile::span("trait_impls_in_crate_query").detail(|| format!("{krate:?}"));
|
||||
let mut impls = Self { map: FxHashMap::default() };
|
||||
let mut impls = FxHashMap::default();
|
||||
|
||||
let crate_def_map = db.crate_def_map(krate);
|
||||
impls.collect_def_map(db, &crate_def_map);
|
||||
impls.shrink_to_fit();
|
||||
Self::collect_def_map(db, &mut impls, &db.crate_def_map(krate));
|
||||
|
||||
Arc::new(impls)
|
||||
Arc::new(Self::finish(impls))
|
||||
}
|
||||
|
||||
pub(crate) fn trait_impls_in_block_query(db: &dyn HirDatabase, block: BlockId) -> Arc<Self> {
|
||||
let _p = profile::span("trait_impls_in_block_query");
|
||||
let mut impls = Self { map: FxHashMap::default() };
|
||||
let mut impls = FxHashMap::default();
|
||||
|
||||
let block_def_map = db.block_def_map(block);
|
||||
impls.collect_def_map(db, &block_def_map);
|
||||
impls.shrink_to_fit();
|
||||
Self::collect_def_map(db, &mut impls, &db.block_def_map(block));
|
||||
|
||||
Arc::new(impls)
|
||||
Arc::new(Self::finish(impls))
|
||||
}
|
||||
|
||||
pub(crate) fn trait_impls_in_deps_query(
|
||||
@ -174,15 +173,16 @@ impl TraitImpls {
|
||||
)
|
||||
}
|
||||
|
||||
fn shrink_to_fit(&mut self) {
|
||||
self.map.shrink_to_fit();
|
||||
self.map.values_mut().for_each(|map| {
|
||||
map.shrink_to_fit();
|
||||
map.values_mut().for_each(Vec::shrink_to_fit);
|
||||
});
|
||||
fn finish(map: TraitFpMapCollector) -> TraitImpls {
|
||||
TraitImpls {
|
||||
map: map
|
||||
.into_iter()
|
||||
.map(|(k, v)| (k, v.into_iter().map(|(k, v)| (k, v.into_boxed_slice())).collect()))
|
||||
.collect(),
|
||||
}
|
||||
}
|
||||
|
||||
fn collect_def_map(&mut self, db: &dyn HirDatabase, def_map: &DefMap) {
|
||||
fn collect_def_map(db: &dyn HirDatabase, map: &mut TraitFpMapCollector, def_map: &DefMap) {
|
||||
for (_module_id, module_data) in def_map.modules() {
|
||||
for impl_id in module_data.scope.impls() {
|
||||
// Reservation impls should be ignored during trait resolution, so we never need
|
||||
@ -200,12 +200,7 @@ impl TraitImpls {
|
||||
};
|
||||
let self_ty = db.impl_self_ty(impl_id);
|
||||
let self_ty_fp = TyFingerprint::for_trait_impl(self_ty.skip_binders());
|
||||
self.map
|
||||
.entry(target_trait)
|
||||
.or_default()
|
||||
.entry(self_ty_fp)
|
||||
.or_default()
|
||||
.push(impl_id);
|
||||
map.entry(target_trait).or_default().entry(self_ty_fp).or_default().push(impl_id);
|
||||
}
|
||||
|
||||
// To better support custom derives, collect impls in all unnamed const items.
|
||||
@ -213,7 +208,7 @@ impl TraitImpls {
|
||||
for konst in collect_unnamed_consts(db, &module_data.scope) {
|
||||
let body = db.body(konst.into());
|
||||
for (_, block_def_map) in body.blocks(db.upcast()) {
|
||||
self.collect_def_map(db, &block_def_map);
|
||||
Self::collect_def_map(db, map, &block_def_map);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -84,26 +84,53 @@ impl RootDatabase {
|
||||
)*}
|
||||
}
|
||||
purge_each_query![
|
||||
// SourceDatabase
|
||||
base_db::ParseQuery
|
||||
base_db::CrateGraphQuery
|
||||
|
||||
// SourceDatabaseExt
|
||||
base_db::FileTextQuery
|
||||
base_db::FileSourceRootQuery
|
||||
base_db::SourceRootQuery
|
||||
base_db::SourceRootCratesQuery
|
||||
|
||||
// ExpandDatabase
|
||||
hir::db::AstIdMapQuery
|
||||
hir::db::DeclMacroExpanderQuery
|
||||
hir::db::ExpandProcMacroQuery
|
||||
hir::db::InternMacroCallQuery
|
||||
hir::db::InternSyntaxContextQuery
|
||||
hir::db::MacroArgQuery
|
||||
hir::db::ParseMacroExpansionQuery
|
||||
hir::db::RealSpanMapQuery
|
||||
hir::db::ProcMacrosQuery
|
||||
// SymbolsDatabase
|
||||
crate::symbol_index::ModuleSymbolsQuery
|
||||
crate::symbol_index::LibrarySymbolsQuery
|
||||
crate::symbol_index::LocalRootsQuery
|
||||
crate::symbol_index::LibraryRootsQuery
|
||||
// HirDatabase
|
||||
hir::db::InferQueryQuery
|
||||
hir::db::MirBodyQuery
|
||||
hir::db::BorrowckQuery
|
||||
hir::db::TyQuery
|
||||
hir::db::ValueTyQuery
|
||||
hir::db::ImplSelfTyQuery
|
||||
hir::db::ConstParamTyQuery
|
||||
hir::db::ConstEvalQuery
|
||||
hir::db::ConstEvalDiscriminantQuery
|
||||
hir::db::ImplTraitQuery
|
||||
hir::db::FieldTypesQuery
|
||||
hir::db::LayoutOfAdtQuery
|
||||
hir::db::TargetDataLayoutQuery
|
||||
hir::db::CallableItemSignatureQuery
|
||||
hir::db::ReturnTypeImplTraitsQuery
|
||||
hir::db::GenericPredicatesForParamQuery
|
||||
hir::db::GenericPredicatesQuery
|
||||
hir::db::TraitEnvironmentQuery
|
||||
hir::db::GenericDefaultsQuery
|
||||
hir::db::InherentImplsInCrateQuery
|
||||
hir::db::InherentImplsInBlockQuery
|
||||
hir::db::IncoherentInherentImplCratesQuery
|
||||
hir::db::TraitImplsInCrateQuery
|
||||
hir::db::TraitImplsInBlockQuery
|
||||
hir::db::TraitImplsInDepsQuery
|
||||
hir::db::InternCallableDefQuery
|
||||
hir::db::InternLifetimeParamIdQuery
|
||||
hir::db::InternImplTraitIdQuery
|
||||
hir::db::InternTypeOrConstParamIdQuery
|
||||
hir::db::InternClosureQuery
|
||||
hir::db::InternGeneratorQuery
|
||||
hir::db::AssociatedTyDataQuery
|
||||
hir::db::TraitDatumQuery
|
||||
hir::db::StructDatumQuery
|
||||
hir::db::ImplDatumQuery
|
||||
hir::db::FnDefDatumQuery
|
||||
hir::db::FnDefVarianceQuery
|
||||
hir::db::AdtVarianceQuery
|
||||
hir::db::AssociatedTyValueQuery
|
||||
hir::db::TraitSolveQueryQuery
|
||||
hir::db::ProgramClausesForChalkEnvQuery
|
||||
|
||||
// DefDatabase
|
||||
hir::db::FileItemTreeQuery
|
||||
@ -151,58 +178,6 @@ impl RootDatabase {
|
||||
hir::db::InternInTypeConstQuery
|
||||
hir::db::InternUseQuery
|
||||
|
||||
// HirDatabase
|
||||
hir::db::InferQueryQuery
|
||||
hir::db::MirBodyQuery
|
||||
hir::db::BorrowckQuery
|
||||
hir::db::TyQuery
|
||||
hir::db::ValueTyQuery
|
||||
hir::db::ImplSelfTyQuery
|
||||
hir::db::ConstParamTyQuery
|
||||
hir::db::ConstEvalQuery
|
||||
hir::db::ConstEvalDiscriminantQuery
|
||||
hir::db::ImplTraitQuery
|
||||
hir::db::FieldTypesQuery
|
||||
hir::db::LayoutOfAdtQuery
|
||||
hir::db::TargetDataLayoutQuery
|
||||
hir::db::CallableItemSignatureQuery
|
||||
hir::db::ReturnTypeImplTraitsQuery
|
||||
hir::db::GenericPredicatesForParamQuery
|
||||
hir::db::GenericPredicatesQuery
|
||||
hir::db::TraitEnvironmentQuery
|
||||
hir::db::GenericDefaultsQuery
|
||||
hir::db::InherentImplsInCrateQuery
|
||||
hir::db::InherentImplsInBlockQuery
|
||||
hir::db::IncoherentInherentImplCratesQuery
|
||||
hir::db::TraitImplsInCrateQuery
|
||||
hir::db::TraitImplsInBlockQuery
|
||||
hir::db::TraitImplsInDepsQuery
|
||||
hir::db::InternCallableDefQuery
|
||||
hir::db::InternLifetimeParamIdQuery
|
||||
hir::db::InternImplTraitIdQuery
|
||||
hir::db::InternTypeOrConstParamIdQuery
|
||||
hir::db::InternClosureQuery
|
||||
hir::db::InternGeneratorQuery
|
||||
hir::db::AssociatedTyDataQuery
|
||||
hir::db::TraitDatumQuery
|
||||
hir::db::StructDatumQuery
|
||||
hir::db::ImplDatumQuery
|
||||
hir::db::FnDefDatumQuery
|
||||
hir::db::FnDefVarianceQuery
|
||||
hir::db::AdtVarianceQuery
|
||||
hir::db::AssociatedTyValueQuery
|
||||
hir::db::TraitSolveQueryQuery
|
||||
hir::db::ProgramClausesForChalkEnvQuery
|
||||
|
||||
// SymbolsDatabase
|
||||
crate::symbol_index::ModuleSymbolsQuery
|
||||
crate::symbol_index::LibrarySymbolsQuery
|
||||
crate::symbol_index::LocalRootsQuery
|
||||
crate::symbol_index::LibraryRootsQuery
|
||||
|
||||
// LineIndexDatabase
|
||||
crate::LineIndexQuery
|
||||
|
||||
// InternDatabase
|
||||
hir::db::InternFunctionQuery
|
||||
hir::db::InternStructQuery
|
||||
@ -219,6 +194,30 @@ impl RootDatabase {
|
||||
hir::db::InternMacro2Query
|
||||
hir::db::InternProcMacroQuery
|
||||
hir::db::InternMacroRulesQuery
|
||||
|
||||
// ExpandDatabase
|
||||
hir::db::AstIdMapQuery
|
||||
hir::db::DeclMacroExpanderQuery
|
||||
hir::db::ExpandProcMacroQuery
|
||||
hir::db::InternMacroCallQuery
|
||||
hir::db::InternSyntaxContextQuery
|
||||
hir::db::MacroArgQuery
|
||||
hir::db::ParseMacroExpansionQuery
|
||||
hir::db::RealSpanMapQuery
|
||||
hir::db::ProcMacrosQuery
|
||||
|
||||
// LineIndexDatabase
|
||||
crate::LineIndexQuery
|
||||
|
||||
// SourceDatabase
|
||||
base_db::ParseQuery
|
||||
base_db::CrateGraphQuery
|
||||
|
||||
// SourceDatabaseExt
|
||||
base_db::FileTextQuery
|
||||
base_db::FileSourceRootQuery
|
||||
base_db::SourceRootQuery
|
||||
base_db::SourceRootCratesQuery
|
||||
];
|
||||
|
||||
acc.sort_by_key(|it| std::cmp::Reverse(it.1));
|
||||
|
@ -145,7 +145,7 @@ impl RootDatabase {
|
||||
db.set_local_roots_with_durability(Default::default(), Durability::HIGH);
|
||||
db.set_library_roots_with_durability(Default::default(), Durability::HIGH);
|
||||
db.set_expand_proc_attr_macros_with_durability(false, Durability::HIGH);
|
||||
db.update_parse_query_lru_capacity(lru_capacity);
|
||||
db.update_base_query_lru_capacities(lru_capacity);
|
||||
db.setup_syntax_context_root();
|
||||
db
|
||||
}
|
||||
@ -154,11 +154,12 @@ impl RootDatabase {
|
||||
self.set_expand_proc_attr_macros_with_durability(true, Durability::HIGH);
|
||||
}
|
||||
|
||||
pub fn update_parse_query_lru_capacity(&mut self, lru_capacity: Option<usize>) {
|
||||
pub fn update_base_query_lru_capacities(&mut self, lru_capacity: Option<usize>) {
|
||||
let lru_capacity = lru_capacity.unwrap_or(base_db::DEFAULT_PARSE_LRU_CAP);
|
||||
base_db::ParseQuery.in_db_mut(self).set_lru_capacity(lru_capacity);
|
||||
// macro expansions are usually rather small, so we can afford to keep more of them alive
|
||||
hir::db::ParseMacroExpansionQuery.in_db_mut(self).set_lru_capacity(4 * lru_capacity);
|
||||
hir::db::BorrowckQuery.in_db_mut(self).set_lru_capacity(base_db::DEFAULT_BORROWCK_LRU_CAP);
|
||||
}
|
||||
|
||||
pub fn update_lru_capacities(&mut self, lru_capacities: &FxHashMap<Box<str>, usize>) {
|
||||
@ -176,6 +177,12 @@ impl RootDatabase {
|
||||
.copied()
|
||||
.unwrap_or(4 * base_db::DEFAULT_PARSE_LRU_CAP),
|
||||
);
|
||||
hir_db::BorrowckQuery.in_db_mut(self).set_lru_capacity(
|
||||
lru_capacities
|
||||
.get(stringify!(BorrowckQuery))
|
||||
.copied()
|
||||
.unwrap_or(base_db::DEFAULT_BORROWCK_LRU_CAP),
|
||||
);
|
||||
|
||||
macro_rules! update_lru_capacity_per_query {
|
||||
($( $module:ident :: $query:ident )*) => {$(
|
||||
|
@ -171,7 +171,7 @@ impl AnalysisHost {
|
||||
}
|
||||
|
||||
pub fn update_lru_capacity(&mut self, lru_capacity: Option<usize>) {
|
||||
self.db.update_parse_query_lru_capacity(lru_capacity);
|
||||
self.db.update_base_query_lru_capacities(lru_capacity);
|
||||
}
|
||||
|
||||
pub fn update_lru_capacities(&mut self, lru_capacities: &FxHashMap<Box<str>, usize>) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user