@@ -12,12 +12,13 @@ use crate::query::job::{report_cycle, QueryInfo, QueryJob, QueryJobId, QueryJobI
1212use crate :: query:: SerializedDepNodeIndex ;
1313use crate :: query:: { QueryContext , QueryMap , QuerySideEffects , QueryStackFrame } ;
1414use crate :: HandleCycleError ;
15+ #[ cfg( parallel_compiler) ]
16+ use rustc_data_structures:: cold_path;
1517use rustc_data_structures:: fingerprint:: Fingerprint ;
1618use rustc_data_structures:: fx:: FxHashMap ;
19+ use rustc_data_structures:: sharded:: Sharded ;
1720use rustc_data_structures:: stack:: ensure_sufficient_stack;
1821use rustc_data_structures:: sync:: Lock ;
19- #[ cfg( parallel_compiler) ]
20- use rustc_data_structures:: { cold_path, sharded:: Sharded } ;
2122use rustc_errors:: { DiagnosticBuilder , ErrorGuaranteed , FatalError } ;
2223use rustc_span:: { Span , DUMMY_SP } ;
2324use std:: cell:: Cell ;
@@ -30,10 +31,7 @@ use thin_vec::ThinVec;
3031use super :: QueryConfig ;
3132
3233pub struct QueryState < K , D : DepKind > {
33- #[ cfg( parallel_compiler) ]
3434 active : Sharded < FxHashMap < K , QueryResult < D > > > ,
35- #[ cfg( not( parallel_compiler) ) ]
36- active : Lock < FxHashMap < K , QueryResult < D > > > ,
3735}
3836
3937/// Indicates the state of a query for a given key in a query map.
5250 D : DepKind ,
5351{
5452 pub fn all_inactive ( & self ) -> bool {
55- #[ cfg( parallel_compiler) ]
56- {
57- let shards = self . active . lock_shards ( ) ;
58- shards. iter ( ) . all ( |shard| shard. is_empty ( ) )
59- }
60- #[ cfg( not( parallel_compiler) ) ]
61- {
62- self . active . lock ( ) . is_empty ( )
63- }
53+ self . active . lock_shards ( ) . all ( |shard| shard. is_empty ( ) )
6454 }
6555
6656 pub fn try_collect_active_jobs < Qcx : Copy > (
@@ -71,26 +61,10 @@ where
7161 ) -> Option < ( ) > {
7262 let mut active = Vec :: new ( ) ;
7363
74- #[ cfg( parallel_compiler) ]
75- {
76- // We use try_lock_shards here since we are called from the
77- // deadlock handler, and this shouldn't be locked.
78- let shards = self . active . try_lock_shards ( ) ?;
79- for shard in shards. iter ( ) {
80- for ( k, v) in shard. iter ( ) {
81- if let QueryResult :: Started ( ref job) = * v {
82- active. push ( ( * k, job. clone ( ) ) ) ;
83- }
84- }
85- }
86- }
87- #[ cfg( not( parallel_compiler) ) ]
88- {
89- // We use try_lock here since we are called from the
90- // deadlock handler, and this shouldn't be locked.
91- // (FIXME: Is this relevant for non-parallel compilers? It doesn't
92- // really hurt much.)
93- for ( k, v) in self . active . try_lock ( ) ?. iter ( ) {
64+ // We use try_lock_shards here since we are called from the
65+ // deadlock handler, and this shouldn't be locked.
66+ for shard in self . active . try_lock_shards ( ) {
67+ for ( k, v) in shard?. iter ( ) {
9468 if let QueryResult :: Started ( ref job) = * v {
9569 active. push ( ( * k, job. clone ( ) ) ) ;
9670 }
@@ -184,10 +158,7 @@ where
184158 cache. complete ( key, result, dep_node_index) ;
185159
186160 let job = {
187- #[ cfg( parallel_compiler) ]
188161 let mut lock = state. active . get_shard_by_value ( & key) . lock ( ) ;
189- #[ cfg( not( parallel_compiler) ) ]
190- let mut lock = state. active . lock ( ) ;
191162 match lock. remove ( & key) . unwrap ( ) {
192163 QueryResult :: Started ( job) => job,
193164 QueryResult :: Poisoned => panic ! ( ) ,
@@ -209,10 +180,7 @@ where
209180 // Poison the query so jobs waiting on it panic.
210181 let state = self . state ;
211182 let job = {
212- #[ cfg( parallel_compiler) ]
213183 let mut shard = state. active . get_shard_by_value ( & self . key ) . lock ( ) ;
214- #[ cfg( not( parallel_compiler) ) ]
215- let mut shard = state. active . lock ( ) ;
216184 let job = match shard. remove ( & self . key ) . unwrap ( ) {
217185 QueryResult :: Started ( job) => job,
218186 QueryResult :: Poisoned => panic ! ( ) ,
@@ -336,10 +304,7 @@ where
336304 Qcx : QueryContext ,
337305{
338306 let state = query. query_state ( qcx) ;
339- #[ cfg( parallel_compiler) ]
340307 let mut state_lock = state. active . get_shard_by_value ( & key) . lock ( ) ;
341- #[ cfg( not( parallel_compiler) ) ]
342- let mut state_lock = state. active . lock ( ) ;
343308
344309 // For the parallel compiler we need to check both the query cache and query state structures
345310 // while holding the state lock to ensure that 1) the query has not yet completed and 2) the
0 commit comments