}
}
- /// All self-profiling events generated by the query engine use a
- /// virtual `StringId`s for their `event_id`. This method makes all
- /// those virtual `StringId`s point to actual strings.
- ///
- /// If we are recording only summary data, the ids will point to
- /// just the query names. If we are recording query keys too, we
- /// allocate the corresponding strings here. (The latter is not yet
- /// implemented.)
- pub fn allocate_self_profile_query_strings(
- &self,
- profiler: &rustc_data_structures::profiling::SelfProfiler
- ) {
- // Walk the entire query cache and allocate the appropriate
- // string representation. Each cache entry is uniquely
- // identified by its dep_node_index.
- $({
- let query_name_string_id =
- profiler.get_or_alloc_cached_string(stringify!($name));
-
- let result_cache = self.$name.lock_shards();
-
- for shard in result_cache.iter() {
- let query_invocation_ids = shard
- .results
- .values()
- .map(|v| v.index)
- .map(|dep_node_index| dep_node_index.into());
-
- profiler.bulk_map_query_invocation_id_to_single_string(
- query_invocation_ids,
- query_name_string_id
- );
- }
- })*
- }
-
#[cfg(parallel_compiler)]
pub fn collect_active_jobs(&self) -> Vec<Lrc<QueryJob<$tcx>>> {
let mut jobs = Vec::new();
pub fn $name(self, key: $K) -> $V {
self.at(DUMMY_SP).$name(key)
})*
+
+ /// All self-profiling events generated by the query engine use
+ /// virtual `StringId`s for their `event_id`. This method makes all
+ /// those virtual `StringId`s point to actual strings.
+ ///
+ /// If we are recording only summary data, the ids will point to
+ /// just the query names. If we are recording query keys too, we
+ /// allocate the corresponding strings here.
+ pub fn alloc_self_profile_query_strings(self) {
+ use crate::ty::query::profiling_support::{
+ alloc_self_profile_query_strings_for_query_cache,
+ QueryKeyStringCache,
+ };
+
+ if !self.prof.enabled() {
+ return;
+ }
+
+ let mut string_cache = QueryKeyStringCache::new();
+
+ $({
+ alloc_self_profile_query_strings_for_query_cache(
+ self,
+ stringify!($name),
+ &self.queries.$name,
+ &mut string_cache,
+ );
+ })*
+ }
}
impl TyCtxtAt<$tcx> {