Merge QueryDescription
into QueryConfig
`QueryDescription` has gone through a lot of refactoring and doesn't make sense anymore.
This commit is contained in:
parent
452cf4f710
commit
36be251a35
6 changed files with 42 additions and 45 deletions
|
@ -36,7 +36,7 @@ mod keys;
|
||||||
use keys::Key;
|
use keys::Key;
|
||||||
|
|
||||||
pub use rustc_query_system::query::QueryConfig;
|
pub use rustc_query_system::query::QueryConfig;
|
||||||
pub(crate) use rustc_query_system::query::{QueryDescription, QueryVTable};
|
pub(crate) use rustc_query_system::query::QueryVTable;
|
||||||
|
|
||||||
mod on_disk_cache;
|
mod on_disk_cache;
|
||||||
pub use on_disk_cache::OnDiskCache;
|
pub use on_disk_cache::OnDiskCache;
|
||||||
|
|
|
@ -1063,7 +1063,7 @@ pub fn encode_query_results<'a, 'tcx, CTX, Q>(
|
||||||
query_result_index: &mut EncodedDepNodeIndex,
|
query_result_index: &mut EncodedDepNodeIndex,
|
||||||
) where
|
) where
|
||||||
CTX: QueryContext + 'tcx,
|
CTX: QueryContext + 'tcx,
|
||||||
Q: super::QueryDescription<CTX>,
|
Q: super::QueryConfig<CTX>,
|
||||||
Q::Value: Encodable<CacheEncoder<'a, 'tcx>>,
|
Q::Value: Encodable<CacheEncoder<'a, 'tcx>>,
|
||||||
{
|
{
|
||||||
let _timer = tcx
|
let _timer = tcx
|
||||||
|
|
|
@ -17,8 +17,7 @@ use rustc_middle::ty::{self, TyCtxt};
|
||||||
use rustc_query_system::dep_graph::{DepNodeParams, HasDepContext};
|
use rustc_query_system::dep_graph::{DepNodeParams, HasDepContext};
|
||||||
use rustc_query_system::ich::StableHashingContext;
|
use rustc_query_system::ich::StableHashingContext;
|
||||||
use rustc_query_system::query::{
|
use rustc_query_system::query::{
|
||||||
force_query, QueryConfig, QueryContext, QueryDescription, QueryJobId, QueryMap,
|
force_query, QueryConfig, QueryContext, QueryJobId, QueryMap, QuerySideEffects, QueryStackFrame,
|
||||||
QuerySideEffects, QueryStackFrame,
|
|
||||||
};
|
};
|
||||||
use rustc_query_system::{LayoutOfDepth, QueryOverflow, Value};
|
use rustc_query_system::{LayoutOfDepth, QueryOverflow, Value};
|
||||||
use rustc_serialize::Decodable;
|
use rustc_serialize::Decodable;
|
||||||
|
@ -340,7 +339,7 @@ pub(crate) fn create_query_frame<
|
||||||
|
|
||||||
fn try_load_from_on_disk_cache<'tcx, Q>(tcx: TyCtxt<'tcx>, dep_node: DepNode)
|
fn try_load_from_on_disk_cache<'tcx, Q>(tcx: TyCtxt<'tcx>, dep_node: DepNode)
|
||||||
where
|
where
|
||||||
Q: QueryDescription<QueryCtxt<'tcx>>,
|
Q: QueryConfig<QueryCtxt<'tcx>>,
|
||||||
Q::Key: DepNodeParams<TyCtxt<'tcx>>,
|
Q::Key: DepNodeParams<TyCtxt<'tcx>>,
|
||||||
{
|
{
|
||||||
debug_assert!(tcx.dep_graph.is_green(&dep_node));
|
debug_assert!(tcx.dep_graph.is_green(&dep_node));
|
||||||
|
@ -365,7 +364,7 @@ where
|
||||||
|
|
||||||
fn force_from_dep_node<'tcx, Q>(tcx: TyCtxt<'tcx>, dep_node: DepNode) -> bool
|
fn force_from_dep_node<'tcx, Q>(tcx: TyCtxt<'tcx>, dep_node: DepNode) -> bool
|
||||||
where
|
where
|
||||||
Q: QueryDescription<QueryCtxt<'tcx>>,
|
Q: QueryConfig<QueryCtxt<'tcx>>,
|
||||||
Q::Key: DepNodeParams<TyCtxt<'tcx>>,
|
Q::Key: DepNodeParams<TyCtxt<'tcx>>,
|
||||||
Q::Value: Value<TyCtxt<'tcx>>,
|
Q::Value: Value<TyCtxt<'tcx>>,
|
||||||
{
|
{
|
||||||
|
@ -398,12 +397,9 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn query_callback<'tcx, Q: QueryConfig>(
|
pub(crate) fn query_callback<'tcx, Q>(is_anon: bool, is_eval_always: bool) -> DepKindStruct<'tcx>
|
||||||
is_anon: bool,
|
|
||||||
is_eval_always: bool,
|
|
||||||
) -> DepKindStruct<'tcx>
|
|
||||||
where
|
where
|
||||||
Q: QueryDescription<QueryCtxt<'tcx>>,
|
Q: QueryConfig<QueryCtxt<'tcx>>,
|
||||||
Q::Key: DepNodeParams<TyCtxt<'tcx>>,
|
Q::Key: DepNodeParams<TyCtxt<'tcx>>,
|
||||||
{
|
{
|
||||||
let fingerprint_style = Q::Key::fingerprint_style();
|
let fingerprint_style = Q::Key::fingerprint_style();
|
||||||
|
@ -458,14 +454,12 @@ macro_rules! define_queries {
|
||||||
})*
|
})*
|
||||||
}
|
}
|
||||||
|
|
||||||
$(impl<'tcx> QueryConfig for queries::$name<'tcx> {
|
$(impl<'tcx> QueryConfig<QueryCtxt<'tcx>> for queries::$name<'tcx> {
|
||||||
type Key = query_keys::$name<'tcx>;
|
type Key = query_keys::$name<'tcx>;
|
||||||
type Value = query_values::$name<'tcx>;
|
type Value = query_values::$name<'tcx>;
|
||||||
type Stored = query_stored::$name<'tcx>;
|
type Stored = query_stored::$name<'tcx>;
|
||||||
const NAME: &'static str = stringify!($name);
|
const NAME: &'static str = stringify!($name);
|
||||||
}
|
|
||||||
|
|
||||||
impl<'tcx> QueryDescription<QueryCtxt<'tcx>> for queries::$name<'tcx> {
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn cache_on_disk(tcx: TyCtxt<'tcx>, key: &Self::Key) -> bool {
|
fn cache_on_disk(tcx: TyCtxt<'tcx>, key: &Self::Key) -> bool {
|
||||||
::rustc_middle::query::cached::$name(tcx, key)
|
::rustc_middle::query::cached::$name(tcx, key)
|
||||||
|
@ -662,12 +656,15 @@ macro_rules! define_queries_struct {
|
||||||
local_providers: Box<Providers>,
|
local_providers: Box<Providers>,
|
||||||
extern_providers: Box<ExternProviders>,
|
extern_providers: Box<ExternProviders>,
|
||||||
query_structs: Vec<$crate::plumbing::QueryStruct<'tcx>>,
|
query_structs: Vec<$crate::plumbing::QueryStruct<'tcx>>,
|
||||||
|
|
||||||
pub on_disk_cache: Option<OnDiskCache<'tcx>>,
|
pub on_disk_cache: Option<OnDiskCache<'tcx>>,
|
||||||
|
|
||||||
jobs: AtomicU64,
|
jobs: AtomicU64,
|
||||||
|
|
||||||
$($(#[$attr])* $name: QueryState<<queries::$name<'tcx> as QueryConfig>::Key>,)*
|
$(
|
||||||
|
$(#[$attr])*
|
||||||
|
$name: QueryState<
|
||||||
|
<queries::$name<'tcx> as QueryConfig<QueryCtxt<'tcx>>>::Key
|
||||||
|
>,
|
||||||
|
)*
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> Queries<'tcx> {
|
impl<'tcx> Queries<'tcx> {
|
||||||
|
@ -704,7 +701,7 @@ macro_rules! define_queries_struct {
|
||||||
&'tcx self,
|
&'tcx self,
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
span: Span,
|
span: Span,
|
||||||
key: <queries::$name<'tcx> as QueryConfig>::Key,
|
key: <queries::$name<'tcx> as QueryConfig<QueryCtxt<'tcx>>>::Key,
|
||||||
mode: QueryMode,
|
mode: QueryMode,
|
||||||
) -> Option<query_stored::$name<'tcx>> {
|
) -> Option<query_stored::$name<'tcx>> {
|
||||||
let qcx = QueryCtxt { tcx, queries: self };
|
let qcx = QueryCtxt { tcx, queries: self };
|
||||||
|
|
|
@ -11,12 +11,32 @@ use rustc_data_structures::fingerprint::Fingerprint;
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
use std::hash::Hash;
|
use std::hash::Hash;
|
||||||
|
|
||||||
pub trait QueryConfig {
|
pub trait QueryConfig<CTX: QueryContext> {
|
||||||
const NAME: &'static str;
|
const NAME: &'static str;
|
||||||
|
|
||||||
type Key: Eq + Hash + Clone + Debug;
|
type Key: Eq + Hash + Clone + Debug;
|
||||||
type Value;
|
type Value;
|
||||||
type Stored: Clone;
|
type Stored: Clone;
|
||||||
|
|
||||||
|
type Cache: QueryCache<Key = Self::Key, Stored = Self::Stored, Value = Self::Value>;
|
||||||
|
|
||||||
|
// Don't use this method to access query results, instead use the methods on TyCtxt
|
||||||
|
fn query_state<'a>(tcx: CTX) -> &'a QueryState<Self::Key>
|
||||||
|
where
|
||||||
|
CTX: 'a;
|
||||||
|
|
||||||
|
// Don't use this method to access query results, instead use the methods on TyCtxt
|
||||||
|
fn query_cache<'a>(tcx: CTX) -> &'a Self::Cache
|
||||||
|
where
|
||||||
|
CTX: 'a;
|
||||||
|
|
||||||
|
// Don't use this method to compute query results, instead use the methods on TyCtxt
|
||||||
|
fn make_vtable(tcx: CTX, key: &Self::Key) -> QueryVTable<CTX, Self::Key, Self::Value>;
|
||||||
|
|
||||||
|
fn cache_on_disk(tcx: CTX::DepContext, key: &Self::Key) -> bool;
|
||||||
|
|
||||||
|
// Don't use this method to compute query results, instead use the methods on TyCtxt
|
||||||
|
fn execute_query(tcx: CTX::DepContext, k: Self::Key) -> Self::Stored;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
|
@ -45,25 +65,3 @@ impl<CTX: QueryContext, K, V> QueryVTable<CTX, K, V> {
|
||||||
(self.compute)(tcx, key)
|
(self.compute)(tcx, key)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait QueryDescription<CTX: QueryContext>: QueryConfig {
|
|
||||||
type Cache: QueryCache<Key = Self::Key, Stored = Self::Stored, Value = Self::Value>;
|
|
||||||
|
|
||||||
// Don't use this method to access query results, instead use the methods on TyCtxt
|
|
||||||
fn query_state<'a>(tcx: CTX) -> &'a QueryState<Self::Key>
|
|
||||||
where
|
|
||||||
CTX: 'a;
|
|
||||||
|
|
||||||
// Don't use this method to access query results, instead use the methods on TyCtxt
|
|
||||||
fn query_cache<'a>(tcx: CTX) -> &'a Self::Cache
|
|
||||||
where
|
|
||||||
CTX: 'a;
|
|
||||||
|
|
||||||
// Don't use this method to compute query results, instead use the methods on TyCtxt
|
|
||||||
fn make_vtable(tcx: CTX, key: &Self::Key) -> QueryVTable<CTX, Self::Key, Self::Value>;
|
|
||||||
|
|
||||||
fn cache_on_disk(tcx: CTX::DepContext, key: &Self::Key) -> bool;
|
|
||||||
|
|
||||||
// Don't use this method to compute query results, instead use the methods on TyCtxt
|
|
||||||
fn execute_query(tcx: CTX::DepContext, k: Self::Key) -> Self::Stored;
|
|
||||||
}
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ pub use self::caches::{
|
||||||
};
|
};
|
||||||
|
|
||||||
mod config;
|
mod config;
|
||||||
pub use self::config::{QueryConfig, QueryDescription, QueryVTable};
|
pub use self::config::{QueryConfig, QueryVTable};
|
||||||
|
|
||||||
use crate::dep_graph::{DepNodeIndex, HasDepContext, SerializedDepNodeIndex};
|
use crate::dep_graph::{DepNodeIndex, HasDepContext, SerializedDepNodeIndex};
|
||||||
use rustc_data_structures::sync::Lock;
|
use rustc_data_structures::sync::Lock;
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
use crate::dep_graph::{DepContext, DepNode, DepNodeIndex, DepNodeParams};
|
use crate::dep_graph::{DepContext, DepNode, DepNodeIndex, DepNodeParams};
|
||||||
use crate::query::caches::QueryCache;
|
use crate::query::caches::QueryCache;
|
||||||
use crate::query::config::{QueryDescription, QueryVTable};
|
use crate::query::config::QueryVTable;
|
||||||
use crate::query::job::{report_cycle, QueryInfo, QueryJob, QueryJobId, QueryJobInfo};
|
use crate::query::job::{report_cycle, QueryInfo, QueryJob, QueryJobId, QueryJobInfo};
|
||||||
use crate::query::{QueryContext, QueryMap, QuerySideEffects, QueryStackFrame};
|
use crate::query::{QueryContext, QueryMap, QuerySideEffects, QueryStackFrame};
|
||||||
use crate::values::Value;
|
use crate::values::Value;
|
||||||
|
@ -27,6 +27,8 @@ use std::mem;
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
use thin_vec::ThinVec;
|
use thin_vec::ThinVec;
|
||||||
|
|
||||||
|
use super::QueryConfig;
|
||||||
|
|
||||||
pub struct QueryState<K> {
|
pub struct QueryState<K> {
|
||||||
#[cfg(parallel_compiler)]
|
#[cfg(parallel_compiler)]
|
||||||
active: Sharded<FxHashMap<K, QueryResult>>,
|
active: Sharded<FxHashMap<K, QueryResult>>,
|
||||||
|
@ -715,7 +717,7 @@ pub enum QueryMode {
|
||||||
|
|
||||||
pub fn get_query<Q, CTX>(tcx: CTX, span: Span, key: Q::Key, mode: QueryMode) -> Option<Q::Stored>
|
pub fn get_query<Q, CTX>(tcx: CTX, span: Span, key: Q::Key, mode: QueryMode) -> Option<Q::Stored>
|
||||||
where
|
where
|
||||||
Q: QueryDescription<CTX>,
|
Q: QueryConfig<CTX>,
|
||||||
Q::Key: DepNodeParams<CTX::DepContext>,
|
Q::Key: DepNodeParams<CTX::DepContext>,
|
||||||
Q::Value: Value<CTX::DepContext>,
|
Q::Value: Value<CTX::DepContext>,
|
||||||
CTX: QueryContext,
|
CTX: QueryContext,
|
||||||
|
@ -748,7 +750,7 @@ where
|
||||||
|
|
||||||
pub fn force_query<Q, CTX>(tcx: CTX, key: Q::Key, dep_node: DepNode<CTX::DepKind>)
|
pub fn force_query<Q, CTX>(tcx: CTX, key: Q::Key, dep_node: DepNode<CTX::DepKind>)
|
||||||
where
|
where
|
||||||
Q: QueryDescription<CTX>,
|
Q: QueryConfig<CTX>,
|
||||||
Q::Key: DepNodeParams<CTX::DepContext>,
|
Q::Key: DepNodeParams<CTX::DepContext>,
|
||||||
Q::Value: Value<CTX::DepContext>,
|
Q::Value: Value<CTX::DepContext>,
|
||||||
CTX: QueryContext,
|
CTX: QueryContext,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue