Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
0bf5cae
Remove __query_compute module.
cjgillot Mar 6, 2020
fc82376
Make QueryAccessor::dep_kind an associated const.
cjgillot Mar 6, 2020
cf238fd
Inline QueryAccessor::query.
cjgillot Mar 7, 2020
1249032
Move impl of Queries with its definition.
cjgillot Mar 7, 2020
b089433
Unpack type arguments for QueryStateShard.
cjgillot Mar 6, 2020
486a082
Unpack type arguments for QueryLookup.
cjgillot Mar 6, 2020
a0f57e2
Unpack type arguments for QueryState.
cjgillot Mar 6, 2020
fa02dca
Remove Q parameter from QueryCache::lookup.
cjgillot Mar 6, 2020
a18aa81
Remove Q parameter from alloc_self_profile_query_strings_for_query_ca…
cjgillot Mar 6, 2020
d125bbb
Remove Q parameter from query stats.
cjgillot Mar 6, 2020
fa0794d
Remove Q parameter from JobOwner.
cjgillot Mar 7, 2020
5dc7c2e
Remove Q parameter from try_get_cached.
cjgillot Mar 7, 2020
7d84f4f
Offload try_collect_active_jobs.
cjgillot Mar 7, 2020
7309b3c
Simplify type aliases.
cjgillot Mar 7, 2020
3abd475
Make QueryCache parameters associated types.
cjgillot Mar 7, 2020
5557407
Remove QueryState type alias.
cjgillot Mar 7, 2020
8aa1328
Make stuff private.
cjgillot Mar 15, 2020
f8178c7
rustc: use LocalDefId instead of DefId in TypeckTables.
eddyb Mar 18, 2020
82920f3
Don't unwind when hitting the macro expansion recursion limit
Zoxc Feb 26, 2020
d641ad0
Update test
Zoxc Feb 29, 2020
6cb5846
sort generic param order in generics_of
lcnr Mar 19, 2020
17c94c6
fix FIXME comment
lcnr Mar 19, 2020
5edaa7e
Fix abort-on-eprintln during process shutdown
alexcrichton Mar 12, 2020
0296d49
fix layout_test visitor name
RalfJung Mar 10, 2020
55c2cf2
add debug option to #[rustc_layout]
RalfJung Mar 10, 2020
d9f60bc
add a test for rustc_layout(debug)
RalfJung Mar 10, 2020
c62e36b
make rustc_layout also work for type definitions
RalfJung Mar 20, 2020
7b49678
fmt
RalfJung Mar 20, 2020
e548df7
normalize away preferred alignment
RalfJung Mar 21, 2020
a6596f2
Rollup merge of #69497 - Zoxc:ast-fragment-error, r=petrochenkov
Dylan-DPC Mar 21, 2020
fd3f917
Rollup merge of #69901 - RalfJung:rustc_layout, r=eddyb
Dylan-DPC Mar 21, 2020
8deeac1
Rollup merge of #69910 - cjgillot:polym, r=Zoxc
Dylan-DPC Mar 21, 2020
276b54e
Rollup merge of #69955 - alexcrichton:stderr-infallible, r=sfackler
Dylan-DPC Mar 21, 2020
266801d
Rollup merge of #70032 - lcnr:issue69970, r=varkor
Dylan-DPC Mar 21, 2020
f1ab750
Rollup merge of #70119 - eddyb:typeck-tables-local-def-id, r=petroche…
Dylan-DPC Mar 21, 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
Unpack type arguments for QueryState.
  • Loading branch information
cjgillot committed Mar 16, 2020
commit a0f57e24e35a365d9d55f37611edfc6666b5d3c9
38 changes: 23 additions & 15 deletions src/librustc/ty/query/plumbing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,25 @@ impl<'tcx, K, C: Default> Default for QueryStateShardImpl<'tcx, K, C> {
}
}

pub(crate) struct QueryState<'tcx, D: QueryAccessors<'tcx> + ?Sized> {
pub(super) cache: D::Cache,
pub(super) shards: Sharded<QueryStateShard<'tcx, D>>,
pub(crate) type QueryState<'tcx, Q> = QueryStateImpl<
'tcx,
<Q as QueryConfig<'tcx>>::Key,
<Q as QueryConfig<'tcx>>::Value,
<Q as QueryAccessors<'tcx>>::Cache,
>;

pub(crate) struct QueryStateImpl<'tcx, K, V, C: QueryCache<K, V>> {
pub(super) cache: C,
pub(super) shards: Sharded<QueryStateShardImpl<'tcx, K, C::Sharded>>,
#[cfg(debug_assertions)]
pub(super) cache_hits: AtomicUsize,
}

impl<'tcx, Q: QueryAccessors<'tcx>> QueryState<'tcx, Q> {
pub(super) fn get_lookup<K: Hash>(&'tcx self, key: &K) -> QueryLookup<'tcx, Q> {
impl<'tcx, K, V, C: QueryCache<K, V>> QueryStateImpl<'tcx, K, V, C> {
pub(super) fn get_lookup<K2: Hash>(
&'tcx self,
key: &K2,
) -> QueryLookupImpl<'tcx, QueryStateShardImpl<'tcx, K, C::Sharded>> {
// We compute the key's hash once and then use it for both the
// shard lookup and the hashmap lookup. This relies on the fact
// that both of them use `FxHasher`.
Expand All @@ -88,12 +98,10 @@ pub(super) enum QueryResult<'tcx> {
Poisoned,
}

impl<'tcx, M: QueryAccessors<'tcx>> QueryState<'tcx, M> {
impl<'tcx, K, V, C: QueryCache<K, V>> QueryStateImpl<'tcx, K, V, C> {
pub fn iter_results<R>(
&self,
f: impl for<'a> FnOnce(
Box<dyn Iterator<Item = (&'a M::Key, &'a M::Value, DepNodeIndex)> + 'a>,
) -> R,
f: impl for<'a> FnOnce(Box<dyn Iterator<Item = (&'a K, &'a V, DepNodeIndex)> + 'a>) -> R,
) -> R {
self.cache.iter(&self.shards, |shard| &mut shard.cache, f)
}
Expand All @@ -103,10 +111,10 @@ impl<'tcx, M: QueryAccessors<'tcx>> QueryState<'tcx, M> {
}
}

impl<'tcx, M: QueryAccessors<'tcx>> Default for QueryState<'tcx, M> {
fn default() -> QueryState<'tcx, M> {
QueryState {
cache: M::Cache::default(),
impl<'tcx, K, V, C: QueryCache<K, V>> Default for QueryStateImpl<'tcx, K, V, C> {
fn default() -> QueryStateImpl<'tcx, K, V, C> {
QueryStateImpl {
cache: C::default(),
shards: Default::default(),
#[cfg(debug_assertions)]
cache_hits: AtomicUsize::new(0),
Expand Down Expand Up @@ -441,7 +449,7 @@ impl<'tcx> TyCtxt<'tcx> {
{
let state = Q::query_state(self);

state.cache.lookup(
state.cache.lookup::<_, _, _, _, Q>(
state,
QueryStateShard::<Q>::get_cache,
key,
Expand Down Expand Up @@ -1035,7 +1043,7 @@ macro_rules! define_queries_inner {
let mut string_cache = QueryKeyStringCache::new();

$({
alloc_self_profile_query_strings_for_query_cache(
alloc_self_profile_query_strings_for_query_cache::<queries::$name<'_>>(
self,
stringify!($name),
&self.queries.$name,
Expand Down