summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_query_impl
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:43 +0000
commit3e3e70d529d8c7d7c4d7bc4fefc9f109393b9245 (patch)
treedaf049b282ab10e8c3d03e409b3cd84ff3f7690c /compiler/rustc_query_impl
parentAdding debian version 1.68.2+dfsg1-1. (diff)
downloadrustc-3e3e70d529d8c7d7c4d7bc4fefc9f109393b9245.tar.xz
rustc-3e3e70d529d8c7d7c4d7bc4fefc9f109393b9245.zip
Merging upstream version 1.69.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'compiler/rustc_query_impl')
-rw-r--r--compiler/rustc_query_impl/Cargo.toml3
-rw-r--r--compiler/rustc_query_impl/src/lib.rs4
-rw-r--r--compiler/rustc_query_impl/src/on_disk_cache.rs2
-rw-r--r--compiler/rustc_query_impl/src/plumbing.rs91
4 files changed, 58 insertions, 42 deletions
diff --git a/compiler/rustc_query_impl/Cargo.toml b/compiler/rustc_query_impl/Cargo.toml
index 46e776264..3e8a88c7e 100644
--- a/compiler/rustc_query_impl/Cargo.toml
+++ b/compiler/rustc_query_impl/Cargo.toml
@@ -20,8 +20,7 @@ rustc-rayon-core = { version = "0.4.0", optional = true }
rustc_serialize = { path = "../rustc_serialize" }
rustc_session = { path = "../rustc_session" }
rustc_span = { path = "../rustc_span" }
-rustc_target = { path = "../rustc_target" }
-thin-vec = "0.2.9"
+thin-vec = "0.2.12"
tracing = "0.1"
[features]
diff --git a/compiler/rustc_query_impl/src/lib.rs b/compiler/rustc_query_impl/src/lib.rs
index 2d243e13c..d7708a3bc 100644
--- a/compiler/rustc_query_impl/src/lib.rs
+++ b/compiler/rustc_query_impl/src/lib.rs
@@ -21,7 +21,9 @@ use rustc_data_structures::sync::AtomicU64;
use rustc_middle::arena::Arena;
use rustc_middle::dep_graph::{self, DepKindStruct};
use rustc_middle::query::Key;
-use rustc_middle::ty::query::{query_keys, query_storage, query_stored, query_values};
+use rustc_middle::ty::query::{
+ query_keys, query_provided, query_provided_to_value, query_storage, query_values,
+};
use rustc_middle::ty::query::{ExternProviders, Providers, QueryEngine};
use rustc_middle::ty::TyCtxt;
use rustc_span::Span;
diff --git a/compiler/rustc_query_impl/src/on_disk_cache.rs b/compiler/rustc_query_impl/src/on_disk_cache.rs
index 70c481fb0..46e34462c 100644
--- a/compiler/rustc_query_impl/src/on_disk_cache.rs
+++ b/compiler/rustc_query_impl/src/on_disk_cache.rs
@@ -333,7 +333,7 @@ impl<'sess> rustc_middle::ty::OnDiskCache<'sess> for OnDiskCache<'sess> {
},
);
- // `Encode the file footer.
+ // Encode the file footer.
let footer_pos = encoder.position() as u64;
encoder.encode_tagged(
TAG_FILE_FOOTER,
diff --git a/compiler/rustc_query_impl/src/plumbing.rs b/compiler/rustc_query_impl/src/plumbing.rs
index 6125ad4ef..a8592bd70 100644
--- a/compiler/rustc_query_impl/src/plumbing.rs
+++ b/compiler/rustc_query_impl/src/plumbing.rs
@@ -53,7 +53,7 @@ impl<'tcx> HasDepContext for QueryCtxt<'tcx> {
}
impl QueryContext for QueryCtxt<'_> {
- fn next_job_id(&self) -> QueryJobId {
+ fn next_job_id(self) -> QueryJobId {
QueryJobId(
NonZeroU64::new(
self.queries.jobs.fetch_add(1, rustc_data_structures::sync::Ordering::Relaxed),
@@ -62,31 +62,31 @@ impl QueryContext for QueryCtxt<'_> {
)
}
- fn current_query_job(&self) -> Option<QueryJobId> {
- tls::with_related_context(**self, |icx| icx.query)
+ fn current_query_job(self) -> Option<QueryJobId> {
+ tls::with_related_context(*self, |icx| icx.query)
}
- fn try_collect_active_jobs(&self) -> Option<QueryMap<DepKind>> {
- self.queries.try_collect_active_jobs(**self)
+ fn try_collect_active_jobs(self) -> Option<QueryMap<DepKind>> {
+ self.queries.try_collect_active_jobs(*self)
}
// Interactions with on_disk_cache
- fn load_side_effects(&self, prev_dep_node_index: SerializedDepNodeIndex) -> QuerySideEffects {
+ fn load_side_effects(self, prev_dep_node_index: SerializedDepNodeIndex) -> QuerySideEffects {
self.queries
.on_disk_cache
.as_ref()
- .map(|c| c.load_side_effects(**self, prev_dep_node_index))
+ .map(|c| c.load_side_effects(*self, prev_dep_node_index))
.unwrap_or_default()
}
- fn store_side_effects(&self, dep_node_index: DepNodeIndex, side_effects: QuerySideEffects) {
+ fn store_side_effects(self, dep_node_index: DepNodeIndex, side_effects: QuerySideEffects) {
if let Some(c) = self.queries.on_disk_cache.as_ref() {
c.store_side_effects(dep_node_index, side_effects)
}
}
fn store_side_effects_for_anon_node(
- &self,
+ self,
dep_node_index: DepNodeIndex,
side_effects: QuerySideEffects,
) {
@@ -100,7 +100,7 @@ impl QueryContext for QueryCtxt<'_> {
/// captured during execution and the actual result.
#[inline(always)]
fn start_query<R>(
- &self,
+ self,
token: QueryJobId,
depth_limit: bool,
diagnostics: Option<&Lock<ThinVec<Diagnostic>>>,
@@ -109,14 +109,14 @@ impl QueryContext for QueryCtxt<'_> {
// The `TyCtxt` stored in TLS has the same global interner lifetime
// as `self`, so we use `with_related_context` to relate the 'tcx lifetimes
// when accessing the `ImplicitCtxt`.
- tls::with_related_context(**self, move |current_icx| {
+ tls::with_related_context(*self, move |current_icx| {
if depth_limit && !self.recursion_limit().value_within_limit(current_icx.query_depth) {
self.depth_limit_error(token);
}
// Update the `ImplicitCtxt` to point to our new query job.
let new_icx = ImplicitCtxt {
- tcx: **self,
+ tcx: *self,
query: Some(token),
diagnostics,
query_depth: current_icx.query_depth + depth_limit as usize,
@@ -124,13 +124,11 @@ impl QueryContext for QueryCtxt<'_> {
};
// Use the `ImplicitCtxt` while we execute the query.
- tls::enter_context(&new_icx, |_| {
- rustc_data_structures::stack::ensure_sufficient_stack(compute)
- })
+ tls::enter_context(&new_icx, compute)
})
}
- fn depth_limit_error(&self, job: QueryJobId) {
+ fn depth_limit_error(self, job: QueryJobId) {
let mut span = None;
let mut layout_of_depth = None;
if let Some(map) = self.try_collect_active_jobs() {
@@ -293,14 +291,14 @@ macro_rules! get_provider {
}
macro_rules! should_ever_cache_on_disk {
- ([]) => {{
- None
+ ([]$yes:tt $no:tt) => {{
+ $no
}};
- ([(cache) $($rest:tt)*]) => {{
- Some($crate::plumbing::try_load_from_disk::<Self::Value>)
+ ([(cache) $($rest:tt)*]$yes:tt $no:tt) => {{
+ $yes
}};
- ([$other:tt $($modifiers:tt)*]) => {
- should_ever_cache_on_disk!([$($modifiers)*])
+ ([$other:tt $($modifiers:tt)*]$yes:tt $no:tt) => {
+ should_ever_cache_on_disk!([$($modifiers)*]$yes $no)
};
}
@@ -314,11 +312,14 @@ pub(crate) fn create_query_frame<
kind: DepKind,
name: &'static str,
) -> QueryStackFrame<DepKind> {
- // Disable visible paths printing for performance reasons.
- // Showing visible path instead of any path is not that important in production.
- let description = ty::print::with_no_visible_paths!(
- // Force filename-line mode to avoid invoking `type_of` query.
- ty::print::with_forced_impl_filename_line!(do_describe(tcx.tcx, key))
+ // Avoid calling queries while formatting the description
+ let description = ty::print::with_no_queries!(
+ // Disable visible paths printing for performance reasons.
+ // Showing visible path instead of any path is not that important in production.
+ ty::print::with_no_visible_paths!(
+ // Force filename-line mode to avoid invoking `type_of` query.
+ ty::print::with_forced_impl_filename_line!(do_describe(tcx.tcx, key))
+ )
);
let description =
if tcx.sess.verbose() { format!("{description} [{name:?}]") } else { description };
@@ -469,7 +470,6 @@ macro_rules! define_queries {
$(impl<'tcx> QueryConfig<QueryCtxt<'tcx>> for queries::$name<'tcx> {
type Key = query_keys::$name<'tcx>;
type Value = query_values::$name<'tcx>;
- type Stored = query_stored::$name<'tcx>;
const NAME: &'static str = stringify!($name);
#[inline]
@@ -490,24 +490,39 @@ macro_rules! define_queries {
fn query_cache<'a>(tcx: QueryCtxt<'tcx>) -> &'a Self::Cache
where 'tcx:'a
{
- &tcx.query_caches.$name
+ &tcx.query_system.caches.$name
}
- fn execute_query(tcx: TyCtxt<'tcx>, key: Self::Key) -> Self::Stored {
+ fn execute_query(tcx: TyCtxt<'tcx>, key: Self::Key) -> Self::Value {
tcx.$name(key)
}
#[inline]
- // key is only sometimes used
#[allow(unused_variables)]
- fn compute(qcx: QueryCtxt<'tcx>, key: &Self::Key) -> fn(TyCtxt<'tcx>, Self::Key) -> Self::Value {
- get_provider!([$($modifiers)*][qcx, $name, key])
+ fn compute(qcx: QueryCtxt<'tcx>, key: Self::Key) -> Self::Value {
+ query_provided_to_value::$name(
+ qcx.tcx,
+ get_provider!([$($modifiers)*][qcx, $name, key])(qcx.tcx, key)
+ )
}
#[inline]
- fn try_load_from_disk(qcx: QueryCtxt<'tcx>, key: &Self::Key) -> rustc_query_system::query::TryLoadFromDisk<QueryCtxt<'tcx>, Self> {
- let cache_on_disk = Self::cache_on_disk(qcx.tcx, key);
- if cache_on_disk { should_ever_cache_on_disk!([$($modifiers)*]) } else { None }
+ fn try_load_from_disk(_qcx: QueryCtxt<'tcx>, _key: &Self::Key) -> rustc_query_system::query::TryLoadFromDisk<QueryCtxt<'tcx>, Self> {
+ should_ever_cache_on_disk!([$($modifiers)*] {
+ if Self::cache_on_disk(_qcx.tcx, _key) {
+ Some(|qcx: QueryCtxt<'tcx>, dep_node| {
+ let value = $crate::plumbing::try_load_from_disk::<query_provided::$name<'tcx>>(
+ qcx,
+ dep_node
+ );
+ value.map(|value| query_provided_to_value::$name(qcx.tcx, value))
+ })
+ } else {
+ None
+ }
+ } {
+ None
+ })
}
const ANON: bool = is_anon!([$($modifiers)*]);
@@ -630,7 +645,7 @@ macro_rules! define_queries {
$crate::profiling_support::alloc_self_profile_query_strings_for_query_cache(
tcx,
stringify!($name),
- &tcx.query_caches.$name,
+ &tcx.query_system.caches.$name,
string_cache,
)
},
@@ -722,7 +737,7 @@ macro_rules! define_queries_struct {
span: Span,
key: <queries::$name<'tcx> as QueryConfig<QueryCtxt<'tcx>>>::Key,
mode: QueryMode,
- ) -> Option<query_stored::$name<'tcx>> {
+ ) -> Option<query_values::$name<'tcx>> {
let qcx = QueryCtxt { tcx, queries: self };
get_query::<queries::$name<'tcx>, _, rustc_middle::dep_graph::DepKind>(qcx, span, key, mode)
})*