-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Remove ensure_done execution path
#153472
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -58,20 +58,10 @@ pub struct Cycle<'tcx> { | |
|
|
||
| #[derive(Debug)] | ||
| pub enum QueryMode { | ||
| /// This is a normal query call to `tcx.$query(..)` or `tcx.at(span).$query(..)`. | ||
| /// This is a query call to `tcx.$query(..)`, `tcx.at(span).$query(..)` or `tcx.ensure_done().$query(..)`. | ||
| Get, | ||
| /// This is a call to `tcx.ensure_ok().$query(..)` or `tcx.ensure_done().$query(..)`. | ||
| Ensure { ensure_mode: EnsureMode }, | ||
| } | ||
|
|
||
| /// Distinguishes between `tcx.ensure_ok()` and `tcx.ensure_done()` in shared | ||
| /// code paths that handle both modes. | ||
| #[derive(Debug)] | ||
| pub enum EnsureMode { | ||
| /// Corresponds to [`TyCtxt::ensure_ok`]. | ||
| Ok, | ||
| /// Corresponds to [`TyCtxt::ensure_done`]. | ||
| Done, | ||
| /// This is a call to `tcx.ensure_ok().$query(..)`. | ||
| Ensure, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The variants should be named
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think It's not a get-or-ensure-done mode; it's a get mode that ensure-done delegates to because it currently doesn't have a specialized path of its own. |
||
| } | ||
|
|
||
| /// Stores data and metadata (e.g. function pointers) for a particular query. | ||
|
|
@@ -245,20 +235,13 @@ impl<'tcx> TyCtxt<'tcx> { | |
| TyCtxtEnsureResult { tcx: self } | ||
| } | ||
|
|
||
| /// Wrapper that calls queries in a special "ensure done" mode, for callers | ||
| /// that don't need the return value and just want to guarantee that the | ||
| /// query won't be executed in the future, by executing it now if necessary. | ||
| /// Wrapper that calls queries where callers don't need the return value and | ||
| /// just want to guarantee that the query won't be executed in the future. | ||
| /// | ||
| /// This is useful for queries that read from a [`Steal`] value, to ensure | ||
| /// that they are executed before the query that will steal the value. | ||
| /// | ||
| /// Unlike [`Self::ensure_ok`], a query with all-green inputs will only be | ||
| /// skipped if its return value is stored in the disk-cache. This is still | ||
| /// more efficient than a regular query, because in that situation the | ||
| /// return value doesn't necessarily need to be decoded. | ||
| /// | ||
| /// (As with all query calls, execution is also skipped if the query result | ||
| /// is already cached in memory.) | ||
| /// Currently this causes the query to be executed normally, but this behavior may change. | ||
| /// | ||
| /// [`Steal`]: rustc_data_structures::steal::Steal | ||
| #[inline(always)] | ||
|
|
@@ -583,11 +566,10 @@ macro_rules! define_callbacks { | |
| $(#[$attr])* | ||
| #[inline(always)] | ||
| pub fn $name(self, key: maybe_into_query_key!($($K)*)) { | ||
| $crate::query::inner::query_ensure_ok_or_done( | ||
| $crate::query::inner::query_ensure_ok( | ||
| self.tcx, | ||
| &self.tcx.query_system.query_vtables.$name, | ||
| $crate::query::IntoQueryKey::into_query_key(key), | ||
| $crate::query::EnsureMode::Ok, | ||
| ) | ||
| } | ||
| )* | ||
|
|
@@ -617,12 +599,9 @@ macro_rules! define_callbacks { | |
| $(#[$attr])* | ||
| #[inline(always)] | ||
| pub fn $name(self, key: maybe_into_query_key!($($K)*)) { | ||
| $crate::query::inner::query_ensure_ok_or_done( | ||
| self.tcx, | ||
| &self.tcx.query_system.query_vtables.$name, | ||
| $crate::query::IntoQueryKey::into_query_key(key), | ||
| $crate::query::EnsureMode::Done, | ||
| ); | ||
| // This has the same implementation as `tcx.$query(..)` as it isn't currently | ||
| // beneficial to have an optimized variant due to how promotion works. | ||
| let _ = self.tcx.$name(key); | ||
| } | ||
| )* | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be renamed
query_get_or_ensure_done. (I think theatcan be dropped because it's low-value andQueryModedoesn't have it.)