Skip to content

Commit 7323750

Browse files
committed
Remove ALLOC_SELF_PROFILE_QUERY_STRINGS.
And also `alloc_self_profile_query_strings` for each query. This is done by generating the top-level `alloc_self_profile_query_strings` and having it do things more directly.
1 parent 6b0beec commit 7323750

3 files changed

Lines changed: 28 additions & 39 deletions

File tree

compiler/rustc_query_impl/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ pub use crate::dep_kind_vtables::make_dep_kind_vtables;
2121
pub use crate::job::{QueryJobMap, break_query_cycles, print_query_stack};
2222
use crate::plumbing::{encode_all_query_results, try_mark_green};
2323
use crate::profiling_support::QueryKeyStringCache;
24-
pub use crate::profiling_support::alloc_self_profile_query_strings;
2524
use crate::values::Value;
2625

2726
#[macro_use]

compiler/rustc_query_impl/src/plumbing.rs

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -593,18 +593,6 @@ macro_rules! define_queries {
593593
}
594594
}
595595

596-
pub(crate) fn alloc_self_profile_query_strings<'tcx>(
597-
tcx: TyCtxt<'tcx>,
598-
string_cache: &mut QueryKeyStringCache
599-
) {
600-
$crate::profiling_support::alloc_self_profile_query_strings_for_query_cache(
601-
tcx,
602-
stringify!($name),
603-
&tcx.query_system.query_vtables.$name.cache,
604-
string_cache,
605-
)
606-
}
607-
608596
item_if_cache_on_disk! { [$($modifiers)*]
609597
pub(crate) fn encode_query_results<'tcx>(
610598
tcx: TyCtxt<'tcx>,
@@ -663,9 +651,33 @@ macro_rules! define_queries {
663651
if complete { Ok(job_map_out) } else { Err(job_map_out) }
664652
}
665653

666-
const ALLOC_SELF_PROFILE_QUERY_STRINGS: &[
667-
for<'tcx> fn(TyCtxt<'tcx>, &mut QueryKeyStringCache)
668-
] = &[$(query_impl::$name::alloc_self_profile_query_strings),*];
654+
/// All self-profiling events generated by the query engine use
655+
/// virtual `StringId`s for their `event_id`. This method makes all
656+
/// those virtual `StringId`s point to actual strings.
657+
///
658+
/// If we are recording only summary data, the ids will point to
659+
/// just the query names. If we are recording query keys too, we
660+
/// allocate the corresponding strings here.
661+
pub fn alloc_self_profile_query_strings(tcx: TyCtxt<'_>) {
662+
if !tcx.prof.enabled() {
663+
return;
664+
}
665+
666+
let _prof_timer = tcx.sess.prof.generic_activity("self_profile_alloc_query_strings");
667+
668+
let mut string_cache = QueryKeyStringCache::new();
669+
670+
$(
671+
$crate::profiling_support::alloc_self_profile_query_strings_for_query_cache(
672+
tcx,
673+
stringify!($name),
674+
&tcx.query_system.query_vtables.$name.cache,
675+
&mut string_cache,
676+
);
677+
)*
678+
679+
tcx.sess.prof.store_query_cache_hits();
680+
}
669681

670682
const ENCODE_QUERY_RESULTS: &[
671683
Option<for<'tcx> fn(

compiler/rustc_query_impl/src/profiling_support.rs

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub(crate) struct QueryKeyStringCache {
1414
}
1515

1616
impl QueryKeyStringCache {
17-
fn new() -> QueryKeyStringCache {
17+
pub(crate) fn new() -> QueryKeyStringCache {
1818
QueryKeyStringCache { def_id_cache: Default::default() }
1919
}
2020
}
@@ -239,25 +239,3 @@ pub(crate) fn alloc_self_profile_query_strings_for_query_cache<'tcx, C>(
239239
}
240240
});
241241
}
242-
243-
/// All self-profiling events generated by the query engine use
244-
/// virtual `StringId`s for their `event_id`. This method makes all
245-
/// those virtual `StringId`s point to actual strings.
246-
///
247-
/// If we are recording only summary data, the ids will point to
248-
/// just the query names. If we are recording query keys too, we
249-
/// allocate the corresponding strings here.
250-
pub fn alloc_self_profile_query_strings(tcx: TyCtxt<'_>) {
251-
if !tcx.prof.enabled() {
252-
return;
253-
}
254-
255-
let _prof_timer = tcx.sess.prof.generic_activity("self_profile_alloc_query_strings");
256-
257-
let mut string_cache = QueryKeyStringCache::new();
258-
259-
for alloc in super::ALLOC_SELF_PROFILE_QUERY_STRINGS.iter() {
260-
alloc(tcx, &mut string_cache)
261-
}
262-
tcx.sess.prof.store_query_cache_hits();
263-
}

0 commit comments

Comments
 (0)