10414: internal: Add some profiling calls to name resolution r=jonas-schievink a=jonas-schievink

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
This commit is contained in:
bors[bot] 2021-10-01 13:30:30 +00:00 committed by GitHub
commit acb565e6f9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -275,6 +275,8 @@ struct DefCollector<'a> {
impl DefCollector<'_> { impl DefCollector<'_> {
fn seed_with_top_level(&mut self) { fn seed_with_top_level(&mut self) {
let _p = profile::span("seed_with_top_level");
let file_id = self.db.crate_graph()[self.def_map.krate].root_file_id; let file_id = self.db.crate_graph()[self.def_map.krate].root_file_id;
let item_tree = self.db.file_item_tree(file_id.into()); let item_tree = self.db.file_item_tree(file_id.into());
let module_id = self.def_map.root; let module_id = self.def_map.root;
@ -346,15 +348,20 @@ impl DefCollector<'_> {
} }
} }
fn collect(&mut self) { fn resolution_loop(&mut self) {
let _p = profile::span("DefCollector::resolution_loop");
// main name resolution fixed-point loop. // main name resolution fixed-point loop.
let mut i = 0; let mut i = 0;
'outer: loop { 'outer: loop {
loop { loop {
self.db.unwind_if_cancelled(); self.db.unwind_if_cancelled();
loop { {
if self.resolve_imports() == ReachedFixedPoint::Yes { let _p = profile::span("resolve_imports loop");
break; loop {
if self.resolve_imports() == ReachedFixedPoint::Yes {
break;
}
} }
} }
if self.resolve_macros() == ReachedFixedPoint::Yes { if self.resolve_macros() == ReachedFixedPoint::Yes {
@ -372,6 +379,12 @@ impl DefCollector<'_> {
break; break;
} }
} }
}
fn collect(&mut self) {
let _p = profile::span("DefCollector::collect");
self.resolution_loop();
// Resolve all indeterminate resolved imports again // Resolve all indeterminate resolved imports again
// As some of the macros will expand newly import shadowing partial resolved imports // As some of the macros will expand newly import shadowing partial resolved imports
@ -723,6 +736,7 @@ impl DefCollector<'_> {
} }
fn resolve_import(&self, module_id: LocalModuleId, import: &Import) -> PartialResolvedImport { fn resolve_import(&self, module_id: LocalModuleId, import: &Import) -> PartialResolvedImport {
let _p = profile::span("resolve_import").detail(|| format!("{}", import.path));
tracing::debug!("resolving import: {:?} ({:?})", import, self.def_map.edition); tracing::debug!("resolving import: {:?} ({:?})", import, self.def_map.edition);
if import.is_extern_crate { if import.is_extern_crate {
let name = import let name = import
@ -790,6 +804,8 @@ impl DefCollector<'_> {
} }
fn record_resolved_import(&mut self, directive: &ImportDirective) { fn record_resolved_import(&mut self, directive: &ImportDirective) {
let _p = profile::span("record_resolved_import");
let module_id = directive.module_id; let module_id = directive.module_id;
let import = &directive.import; let import = &directive.import;
let mut def = directive.status.namespaces(); let mut def = directive.status.namespaces();
@ -1244,6 +1260,8 @@ impl DefCollector<'_> {
fn finish(mut self) -> DefMap { fn finish(mut self) -> DefMap {
// Emit diagnostics for all remaining unexpanded macros. // Emit diagnostics for all remaining unexpanded macros.
let _p = profile::span("DefCollector::finish");
for directive in &self.unresolved_macros { for directive in &self.unresolved_macros {
match &directive.kind { match &directive.kind {
MacroDirectiveKind::FnLike { ast_id, expand_to } => { MacroDirectiveKind::FnLike { ast_id, expand_to } => {