Skip to content

Commit c8191a2

Browse files
committed
Create a job immediately when looking in the query map and start it later
1 parent 3dfda16 commit c8191a2

File tree

5 files changed

+216
-245
lines changed

5 files changed

+216
-245
lines changed

src/librustc/ty/maps/config.rs

+10-4
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,24 @@ use traits::query::{CanonicalProjectionGoal, CanonicalTyGoal};
1515
use ty::{self, ParamEnvAnd, Ty, TyCtxt};
1616
use ty::subst::Substs;
1717
use ty::maps::queries;
18+
use ty::maps::Query;
19+
use ty::maps::QueryMap;
1820

1921
use std::hash::Hash;
2022
use syntax_pos::symbol::InternedString;
23+
use rustc_data_structures::sync::Lock;
2124

2225
/// Query configuration and description traits.
2326
24-
pub trait QueryConfig {
27+
pub trait QueryConfig<'tcx> {
2528
type Key: Eq + Hash + Clone;
26-
type Value;
29+
type Value: Clone;
30+
31+
fn query(key: Self::Key) -> Query<'tcx>;
32+
fn query_map<'a>(tcx: TyCtxt<'a, 'tcx, '_>) -> &'a Lock<QueryMap<'tcx, Self>>;
2733
}
2834

29-
pub(super) trait QueryDescription<'tcx>: QueryConfig {
35+
pub(super) trait QueryDescription<'tcx>: QueryConfig<'tcx> {
3036
fn describe(tcx: TyCtxt, key: Self::Key) -> String;
3137

3238
#[inline]
@@ -41,7 +47,7 @@ pub(super) trait QueryDescription<'tcx>: QueryConfig {
4147
}
4248
}
4349

44-
impl<'tcx, M: QueryConfig<Key=DefId>> QueryDescription<'tcx> for M {
50+
impl<'tcx, M: QueryConfig<'tcx, Key=DefId>> QueryDescription<'tcx> for M {
4551
default fn describe(tcx: TyCtxt, def_id: DefId) -> String {
4652
if !tcx.sess.verbose() {
4753
format!("processing `{}`", tcx.item_path_str(def_id))

src/librustc/ty/maps/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ pub use self::plumbing::force_from_dep_node;
6868

6969
mod job;
7070
pub use self::job::{QueryJob, QueryInfo};
71-
use self::job::QueryResult;
7271

7372
mod keys;
7473
pub use self::keys::Key;

src/librustc/ty/maps/on_disk_cache.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,8 @@ impl<'sess> OnDiskCache<'sess> {
239239
encode_query_results::<specialization_graph_of, _>(tcx, enc, qri)?;
240240

241241
// const eval is special, it only encodes successfully evaluated constants
242-
use ty::maps::plumbing::GetCacheInternal;
243-
for (key, entry) in const_eval::get_cache_internal(tcx).map.iter() {
242+
use ty::maps::QueryConfig;
243+
for (key, entry) in const_eval::query_map(tcx).borrow().map.iter() {
244244
use ty::maps::config::QueryDescription;
245245
if const_eval::cache_on_disk(key.clone()) {
246246
let entry = match *entry {
@@ -1124,7 +1124,7 @@ fn encode_query_results<'enc, 'a, 'tcx, Q, E>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
11241124
encoder: &mut CacheEncoder<'enc, 'a, 'tcx, E>,
11251125
query_result_index: &mut EncodedQueryResultIndex)
11261126
-> Result<(), E::Error>
1127-
where Q: super::plumbing::GetCacheInternal<'tcx>,
1127+
where Q: super::config::QueryDescription<'tcx>,
11281128
E: 'enc + TyEncoder,
11291129
Q::Value: Encodable,
11301130
{
@@ -1133,7 +1133,7 @@ fn encode_query_results<'enc, 'a, 'tcx, Q, E>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
11331133

11341134
time(tcx.sess, desc, || {
11351135

1136-
for (key, entry) in Q::get_cache_internal(tcx).map.iter() {
1136+
for (key, entry) in Q::query_map(tcx).borrow().map.iter() {
11371137
if Q::cache_on_disk(key.clone()) {
11381138
let entry = match *entry {
11391139
QueryResult::Complete(ref v) => v,

0 commit comments

Comments
 (0)