10000 Move the query system to a dedicated crate by cjgillot · Pull Request #70162 · rust-lang/rust · GitHub
[go: up one dir, main page]

Skip to content

Move the query system to a dedicated crate #70162

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

Merged
merged 31 commits into from
Mar 28, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
8c1c90b
Make QueryConfig argument a type.
cjgillot Mar 8, 2020
f74fd03
Make QueryAccessor argument a type.
cjgillot Mar 8, 2020
57c3177
Make QueryDescription parameter a type.
cjgillot Mar 8, 2020
c4a451e
Make QueryCache generic on the context.
cjgillot Mar 11, 2020
ee9781c
Make QueryContext a subtrait of DepContext.
cjgillot Mar 18, 2020
2a52436
Generalise QueryJobId.
cjgillot Mar 18, 2020
a51ad88
Decouple from DepKind.
cjgillot Mar 18, 2020
232364a
Generalise QueryLatch.
cjgillot Mar 18, 2020
63087b6
Parametrise by try_collect_active_jobs.
cjgillot Mar 19, 2020
42f0db5
Move HashStable bound to the trait definition.
cjgillot Mar 19, 2020
decfd70
Generalise try_get_cached.
cjgillot Mar 19, 2020
4ac4ccd
Generalise JobOwner::try_start.
cjgillot Mar 19, 2020
27e8a95
Generalise Query starting.
cjgillot Mar 19, 2020
6184a71
Make get_query into an extension trait.
cjgillot Mar 19, 2020
5b8dac3
Move query system to librustc_query_system.
cjgillot Mar 19, 2020
8e873c3
Make librustc_query_system compile.
cjgillot Mar 19, 2020 8000
dca0344
Make librustc compile.
cjgillot Mar 19, 2020
301ad11
Rustfmt.
cjgillot Mar 26, 2020
d305b2c
Unify key types in get_lookup.
cjgillot Mar 24, 2020
228ca8e
Access QueryStateShard directly.
cjgillot Mar 24, 2020
b6033fc
Retire DepGraphSafe and HashStableContext.
cjgillot Mar 24, 2020
0e8b59a
Prune dependencies.
cjgillot Mar 24, 2020
fa06cfd
Move generics on QueryCache.
cjgillot Mar 24, 2020
5dfed41
Simplify generics on try_start.
cjgillot Mar 24, 2020
fce0d37
Add comment.
cjgillot Mar 24, 2020
d224e21
Rename read_query_job -> current_query_job and simplify it.
cjgillot Mar 25, 2020
260cfab
Don't allow access to the Session.
cjgillot Mar 25, 2020
4faf701
Remove the QueryGetter trait.
cjgillot Mar 27, 2020
db5be1f
Move QueryContext to the parent module.
cjgillot Mar 27, 2020
222d010
Cleanups.
cjgillot Mar 27, 2020
2d7bbda
Implement HashStable directly.
cjgillot Mar 27, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Move QueryContext to the parent module.
  • Loading branch information
cjgillot committed Mar 27, 2020
commit db5be1fe208d0cbdde750a0eb9f01bbd8afda1ee
2 changes: 1 addition & 1 deletion src/librustc_query_system/query/caches.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::dep_graph::DepNodeIndex;
use crate::query::config::QueryContext;
use crate::query::plumbing::{QueryLookup, QueryState};
use crate::query::QueryContext;

use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::sharded::Sharded;
Expand Down
40 changes: 2 additions & 38 deletions src/librustc_query_system/query/config.rs
10000
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
//! Query configuration and description traits.

use crate::dep_graph::DepNode;
use crate::dep_graph::SerializedDepNodeIndex;
use crate::dep_graph::{DepContext, DepGraph, DepNode};
use crate::query::caches::QueryCache;
use crate::query::job::{QueryJobId, QueryJobInfo};
use crate::query::plumbing::CycleError;
use crate::query::QueryState;
use crate::query::{QueryContext, QueryState};
use rustc_data_structures::profiling::ProfileCategory;
use rustc_span::def_id::DefId;

use rustc_data_structures::fingerprint::Fingerprint;
use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::stable_hasher::HashStable;
use rustc_data_structures::sync::Lock;
use rustc_data_structures::thin_vec::ThinVec;
use rustc_errors::Diagnostic;
use std::borrow::Cow;
use std::fmt::Debug;
use std::hash::Hash;
Expand All @@ -29,36 +23,6 @@ pub trait QueryConfig<CTX> {
type Value: Clone;
}

pub trait QueryContext: DepContext {
type Query: Clone + HashStable<Self::StableHashingContext>;

fn incremental_verify_ich(&self) -> bool;
fn verbose(&self) -> bool;

/// Get string representation from DefPath.
fn def_path_str(&self, def_id: DefId) -> String;

/// Access the DepGraph.
fn dep_graph(&self) -> &DepGraph<Self::DepKind>;

/// Get the query information from the TLS context.
fn current_query_job(&self) -> Option<QueryJobId<Self::DepKind>>;

fn try_collect_active_jobs(
&self,
) -> Option<FxHashMap<QueryJobId<Self::DepKind>, QueryJobInfo<Self>>>;

/// Executes a job by changing the `ImplicitCtxt` to point to the
/// new query job while it executes. It returns the diagnostics
/// captured during execution and the actual result.
fn start_query<R>(
&self,
token: QueryJobId<Self::DepKind>,
diagnostics: Option<&Lock<ThinVec<Diagnostic>>>,
compute: impl FnOnce(Self) -> R,
) -> R;
}

pub trait QueryAccessors<CTX: QueryContext>: QueryConfig<CTX> {
const ANON: bool;
const EVAL_ALWAYS: bool;
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_query_system/query/job.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::dep_graph::{DepContext, DepKind};
use crate::query::config::QueryContext;
use crate::query::plumbing::CycleError;
use crate::query::QueryContext;

use rustc_data_structures::fx::FxHashMap;
use rustc_span::Span;
Expand Down
41 changes: 40 additions & 1 deletion src/librustc_query_system/query/mod.rs
FE8D
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,43 @@ mod caches;
pub use self::caches::{CacheSelector, DefaultCacheSelector, QueryCache};

mod config;
pub use self::config::{QueryAccessors, QueryConfig, QueryContext, QueryDescription};
pub use self::config::{QueryAccessors, QueryConfig, QueryDescription};

use crate::dep_graph::{DepContext, DepGraph};

use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::stable_hasher::HashStable;
use rustc_data_structures::sync::Lock;
use rustc_data_structures::thin_vec::ThinVec;
use rustc_errors::Diagnostic;
use rustc_span::def_id::DefId;

pub trait QueryContext: DepContext {
type Query: Clone + HashStable<Self::StableHashingContext>;

fn incremental_verify_ich(&self) -> bool;
fn verbose(&self) -> bool;

/// Get string representation from DefPath.
fn def_path_str(&self, def_id: DefId) -> String;

/// Access the DepGraph.
fn dep_graph(&self) -> &DepGraph<Self::DepKind>;

/// Get the query information from the TLS context.
fn current_query_job(&self) -> Option<QueryJobId<Self::DepKind>>;

fn try_collect_active_jobs(
&self,
) -> Option<FxHashMap<QueryJobId<Self::DepKind>, QueryJobInfo<Self>>>;

/// Executes a job by changing the `ImplicitCtxt` to point to the
/// new query job while it executes. It returns the diagnostics
/// captured during execution and the actual result.
fn start_query<R>(
&self,
token: QueryJobId<Self::DepKind>,
diagnostics: Option<&Lock<ThinVec<Diagnostic>>>,
compute: impl FnOnce(Self) -> R,
) -> R;
}
3 changes: 2 additions & 1 deletion src/librustc_query_system/query/plumbing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
use crate::dep_graph::{DepKind, DepNode};
use crate::dep_graph::{DepNodeIndex, SerializedDepNodeIndex};
use crate::query::caches::QueryCache;
use crate::query::config::{QueryContext, QueryDescription};
use crate::query::config::QueryDescription;
use crate::query::job::{QueryInfo, QueryJob, QueryJobId, QueryJobInfo, QueryShardJobId};
use crate::query::QueryContext;

#[cfg(not(parallel_compiler))]
use rustc_data_structures::cold_path;
Expand Down
0