Move provider fields back to rustc_query_impl
This commit is contained in:
parent
265e1e968d
commit
067bf2ac13
7 changed files with 28 additions and 39 deletions
|
@ -676,7 +676,9 @@ pub fn create_global_ctxt<'tcx>(
|
||||||
callback(sess, &mut local_providers, &mut extern_providers);
|
callback(sess, &mut local_providers, &mut extern_providers);
|
||||||
}
|
}
|
||||||
|
|
||||||
let queries = queries.get_or_init(|| TcxQueries::new(query_result_on_disk_cache));
|
let queries = queries.get_or_init(|| {
|
||||||
|
TcxQueries::new(local_providers, extern_providers, query_result_on_disk_cache)
|
||||||
|
});
|
||||||
|
|
||||||
sess.time("setup_global_ctxt", || {
|
sess.time("setup_global_ctxt", || {
|
||||||
gcx_cell.get_or_init(move || {
|
gcx_cell.get_or_init(move || {
|
||||||
|
@ -688,8 +690,6 @@ pub fn create_global_ctxt<'tcx>(
|
||||||
untracked,
|
untracked,
|
||||||
dep_graph,
|
dep_graph,
|
||||||
queries.on_disk_cache.as_ref().map(OnDiskCache::as_dyn),
|
queries.on_disk_cache.as_ref().map(OnDiskCache::as_dyn),
|
||||||
local_providers,
|
|
||||||
extern_providers,
|
|
||||||
queries.as_dyn(),
|
queries.as_dyn(),
|
||||||
rustc_query_impl::query_callbacks(arena),
|
rustc_query_impl::query_callbacks(arena),
|
||||||
)
|
)
|
||||||
|
|
|
@ -18,8 +18,6 @@ use crate::mir::{
|
||||||
use crate::thir::Thir;
|
use crate::thir::Thir;
|
||||||
use crate::traits;
|
use crate::traits;
|
||||||
use crate::traits::solve::{ExternalConstraints, ExternalConstraintsData};
|
use crate::traits::solve::{ExternalConstraints, ExternalConstraintsData};
|
||||||
use crate::ty::query::ExternProviders;
|
|
||||||
use crate::ty::query::Providers;
|
|
||||||
use crate::ty::query::{self, TyCtxtAt};
|
use crate::ty::query::{self, TyCtxtAt};
|
||||||
use crate::ty::{
|
use crate::ty::{
|
||||||
self, AdtDef, AdtDefData, AdtKind, Binder, Const, ConstData, DefIdTree, FloatTy, FloatVar,
|
self, AdtDef, AdtDefData, AdtKind, Binder, Const, ConstData, DefIdTree, FloatTy, FloatVar,
|
||||||
|
@ -641,8 +639,6 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
untracked: Untracked,
|
untracked: Untracked,
|
||||||
dep_graph: DepGraph,
|
dep_graph: DepGraph,
|
||||||
on_disk_cache: Option<&'tcx dyn OnDiskCache<'tcx>>,
|
on_disk_cache: Option<&'tcx dyn OnDiskCache<'tcx>>,
|
||||||
local_providers: Providers,
|
|
||||||
extern_providers: ExternProviders,
|
|
||||||
queries: &'tcx dyn query::QueryEngine<'tcx>,
|
queries: &'tcx dyn query::QueryEngine<'tcx>,
|
||||||
query_kinds: &'tcx [DepKindStruct<'tcx>],
|
query_kinds: &'tcx [DepKindStruct<'tcx>],
|
||||||
) -> GlobalCtxt<'tcx> {
|
) -> GlobalCtxt<'tcx> {
|
||||||
|
@ -668,7 +664,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
untracked,
|
untracked,
|
||||||
on_disk_cache,
|
on_disk_cache,
|
||||||
queries,
|
queries,
|
||||||
query_system: query::QuerySystem::new(local_providers, extern_providers),
|
query_system: Default::default(),
|
||||||
query_kinds,
|
query_kinds,
|
||||||
ty_rcache: Default::default(),
|
ty_rcache: Default::default(),
|
||||||
pred_rcache: Default::default(),
|
pred_rcache: Default::default(),
|
||||||
|
|
|
@ -71,24 +71,12 @@ use std::sync::Arc;
|
||||||
pub(crate) use rustc_query_system::query::QueryJobId;
|
pub(crate) use rustc_query_system::query::QueryJobId;
|
||||||
use rustc_query_system::query::*;
|
use rustc_query_system::query::*;
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
pub struct QuerySystem<'tcx> {
|
pub struct QuerySystem<'tcx> {
|
||||||
pub local_providers: Box<Providers>,
|
|
||||||
pub extern_providers: Box<ExternProviders>,
|
|
||||||
pub arenas: QueryArenas<'tcx>,
|
pub arenas: QueryArenas<'tcx>,
|
||||||
pub caches: QueryCaches<'tcx>,
|
pub caches: QueryCaches<'tcx>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'tcx> QuerySystem<'tcx> {
|
|
||||||
pub fn new(local_providers: Providers, extern_providers: ExternProviders) -> Self {
|
|
||||||
QuerySystem {
|
|
||||||
local_providers: Box::new(local_providers),
|
|
||||||
extern_providers: Box::new(extern_providers),
|
|
||||||
arenas: Default::default(),
|
|
||||||
caches: Default::default(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
pub struct TyCtxtAt<'tcx> {
|
pub struct TyCtxtAt<'tcx> {
|
||||||
pub tcx: TyCtxt<'tcx>,
|
pub tcx: TyCtxt<'tcx>,
|
||||||
|
|
|
@ -21,10 +21,10 @@ use rustc_data_structures::sync::AtomicU64;
|
||||||
use rustc_middle::arena::Arena;
|
use rustc_middle::arena::Arena;
|
||||||
use rustc_middle::dep_graph::{self, DepKindStruct};
|
use rustc_middle::dep_graph::{self, DepKindStruct};
|
||||||
use rustc_middle::query::Key;
|
use rustc_middle::query::Key;
|
||||||
use rustc_middle::ty::query::QueryEngine;
|
|
||||||
use rustc_middle::ty::query::{
|
use rustc_middle::ty::query::{
|
||||||
query_keys, query_provided, query_provided_to_value, query_storage, query_values,
|
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_middle::ty::TyCtxt;
|
||||||
use rustc_span::Span;
|
use rustc_span::Span;
|
||||||
|
|
||||||
|
|
|
@ -278,13 +278,13 @@ macro_rules! hash_result {
|
||||||
|
|
||||||
macro_rules! get_provider {
|
macro_rules! get_provider {
|
||||||
([][$tcx:expr, $name:ident, $key:expr]) => {{
|
([][$tcx:expr, $name:ident, $key:expr]) => {{
|
||||||
$tcx.query_system.local_providers.$name
|
$tcx.queries.local_providers.$name
|
||||||
}};
|
}};
|
||||||
([(separate_provide_extern) $($rest:tt)*][$tcx:expr, $name:ident, $key:expr]) => {{
|
([(separate_provide_extern) $($rest:tt)*][$tcx:expr, $name:ident, $key:expr]) => {{
|
||||||
if $key.query_crate_is_local() {
|
if $key.query_crate_is_local() {
|
||||||
$tcx.query_system.local_providers.$name
|
$tcx.queries.local_providers.$name
|
||||||
} else {
|
} else {
|
||||||
$tcx.query_system.extern_providers.$name
|
$tcx.queries.extern_providers.$name
|
||||||
}
|
}
|
||||||
}};
|
}};
|
||||||
([$other:tt $($modifiers:tt)*][$($args:tt)*]) => {
|
([$other:tt $($modifiers:tt)*][$($args:tt)*]) => {
|
||||||
|
@ -500,12 +500,11 @@ macro_rules! define_queries {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
// key is only sometimes used
|
|
||||||
#[allow(unused_variables)]
|
#[allow(unused_variables)]
|
||||||
fn compute(tcx: TyCtxt<'tcx>, key: Self::Key) -> Self::Value {
|
fn compute(qcx: QueryCtxt<'tcx>, key: Self::Key) -> Self::Value {
|
||||||
query_provided_to_value::$name(
|
query_provided_to_value::$name(
|
||||||
tcx,
|
qcx.tcx,
|
||||||
get_provider!([$($modifiers)*][tcx, $name, key])(tcx, key)
|
get_provider!([$($modifiers)*][qcx, $name, key])(qcx.tcx, key)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -664,12 +663,18 @@ macro_rules! define_queries {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
use crate::OnDiskCache;
|
use crate::{ExternProviders, OnDiskCache, Providers};
|
||||||
|
|
||||||
impl<'tcx> Queries<'tcx> {
|
impl<'tcx> Queries<'tcx> {
|
||||||
pub fn new(on_disk_cache: Option<OnDiskCache<'tcx>>) -> Self {
|
pub fn new(
|
||||||
|
local_providers: Providers,
|
||||||
|
extern_providers: ExternProviders,
|
||||||
|
on_disk_cache: Option<OnDiskCache<'tcx>>,
|
||||||
|
) -> Self {
|
||||||
use crate::query_structs;
|
use crate::query_structs;
|
||||||
Queries {
|
Queries {
|
||||||
|
local_providers: Box::new(local_providers),
|
||||||
|
extern_providers: Box::new(extern_providers),
|
||||||
query_structs: make_dep_kind_array!(query_structs).to_vec(),
|
query_structs: make_dep_kind_array!(query_structs).to_vec(),
|
||||||
on_disk_cache,
|
on_disk_cache,
|
||||||
jobs: AtomicU64::new(1),
|
jobs: AtomicU64::new(1),
|
||||||
|
@ -683,6 +688,8 @@ macro_rules! define_queries_struct {
|
||||||
input: ($(([$($modifiers:tt)*] [$($attr:tt)*] [$name:ident]))*)) => {
|
input: ($(([$($modifiers:tt)*] [$($attr:tt)*] [$name:ident]))*)) => {
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Queries<'tcx> {
|
pub struct Queries<'tcx> {
|
||||||
|
local_providers: Box<Providers>,
|
||||||
|
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,
|
||||||
|
|
|
@ -39,7 +39,7 @@ pub trait QueryConfig<Qcx: QueryContext> {
|
||||||
// Don't use this method to compute query results, instead use the methods on TyCtxt
|
// Don't use this method to compute query results, instead use the methods on TyCtxt
|
||||||
fn execute_query(tcx: Qcx::DepContext, k: Self::Key) -> Self::Value;
|
fn execute_query(tcx: Qcx::DepContext, k: Self::Key) -> Self::Value;
|
||||||
|
|
||||||
fn compute(tcx: Qcx::DepContext, key: Self::Key) -> Self::Value;
|
fn compute(tcx: Qcx, key: Self::Key) -> Self::Value;
|
||||||
|
|
||||||
fn try_load_from_disk(qcx: Qcx, idx: &Self::Key) -> TryLoadFromDisk<Qcx, Self>;
|
fn try_load_from_disk(qcx: Qcx, idx: &Self::Key) -> TryLoadFromDisk<Qcx, Self>;
|
||||||
|
|
||||||
|
|
|
@ -425,8 +425,7 @@ where
|
||||||
// Fast path for when incr. comp. is off.
|
// Fast path for when incr. comp. is off.
|
||||||
if !dep_graph.is_fully_enabled() {
|
if !dep_graph.is_fully_enabled() {
|
||||||
let prof_timer = qcx.dep_context().profiler().query_provider();
|
let prof_timer = qcx.dep_context().profiler().query_provider();
|
||||||
let result =
|
let result = qcx.start_query(job_id, Q::DEPTH_LIMIT, None, || Q::compute(qcx, key));
|
||||||
qcx.start_query(job_id, Q::DEPTH_LIMIT, None, || Q::compute(*qcx.dep_context(), key));
|
|
||||||
let dep_node_index = dep_graph.next_virtual_depnode_index();
|
let dep_node_index = dep_graph.next_virtual_depnode_index();
|
||||||
prof_timer.finish_with_query_invocation_id(dep_node_index.into());
|
prof_timer.finish_with_query_invocation_id(dep_node_index.into());
|
||||||
return (result, dep_node_index);
|
return (result, dep_node_index);
|
||||||
|
@ -452,16 +451,15 @@ where
|
||||||
let (result, dep_node_index) =
|
let (result, dep_node_index) =
|
||||||
qcx.start_query(job_id, Q::DEPTH_LIMIT, Some(&diagnostics), || {
|
qcx.start_query(job_id, Q::DEPTH_LIMIT, Some(&diagnostics), || {
|
||||||
if Q::ANON {
|
if Q::ANON {
|
||||||
return dep_graph.with_anon_task(*qcx.dep_context(), Q::DEP_KIND, || {
|
return dep_graph
|
||||||
Q::compute(*qcx.dep_context(), key)
|
.with_anon_task(*qcx.dep_context(), Q::DEP_KIND, || Q::compute(qcx, key));
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// `to_dep_node` is expensive for some `DepKind`s.
|
// `to_dep_node` is expensive for some `DepKind`s.
|
||||||
let dep_node =
|
let dep_node =
|
||||||
dep_node_opt.unwrap_or_else(|| Q::construct_dep_node(*qcx.dep_context(), &key));
|
dep_node_opt.unwrap_or_else(|| Q::construct_dep_node(*qcx.dep_context(), &key));
|
||||||
|
|
||||||
dep_graph.with_task(dep_node, *qcx.dep_context(), key, Q::compute, Q::HASH_RESULT)
|
dep_graph.with_task(dep_node, qcx, key, Q::compute, Q::HASH_RESULT)
|
||||||
});
|
});
|
||||||
|
|
||||||
prof_timer.finish_with_query_invocation_id(dep_node_index.into());
|
prof_timer.finish_with_query_invocation_id(dep_node_index.into());
|
||||||
|
@ -552,7 +550,7 @@ where
|
||||||
let prof_timer = qcx.dep_context().profiler().query_provider();
|
let prof_timer = qcx.dep_context().profiler().query_provider();
|
||||||
|
|
||||||
// The dep-graph for this computation is already in-place.
|
// The dep-graph for this computation is already in-place.
|
||||||
let result = dep_graph.with_ignore(|| Q::compute(*qcx.dep_context(), key.clone()));
|
let result = dep_graph.with_ignore(|| Q::compute(qcx, key.clone()));
|
||||||
|
|
||||||
prof_timer.finish_with_query_invocation_id(dep_node_index.into());
|
prof_timer.finish_with_query_invocation_id(dep_node_index.into());
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue