@@ -12,12 +12,13 @@ use crate::query::job::{report_cycle, QueryInfo, QueryJob, QueryJobId, QueryJobI
12
12
use crate :: query:: SerializedDepNodeIndex ;
13
13
use crate :: query:: { QueryContext , QueryMap , QuerySideEffects , QueryStackFrame } ;
14
14
use crate :: HandleCycleError ;
15
+ #[ cfg( parallel_compiler) ]
16
+ use rustc_data_structures:: cold_path;
15
17
use rustc_data_structures:: fingerprint:: Fingerprint ;
16
18
use rustc_data_structures:: fx:: FxHashMap ;
19
+ use rustc_data_structures:: sharded:: Sharded ;
17
20
use rustc_data_structures:: stack:: ensure_sufficient_stack;
18
21
use rustc_data_structures:: sync:: Lock ;
19
- #[ cfg( parallel_compiler) ]
20
- use rustc_data_structures:: { cold_path, sharded:: Sharded } ;
21
22
use rustc_errors:: { DiagnosticBuilder , ErrorGuaranteed , FatalError } ;
22
23
use rustc_span:: { Span , DUMMY_SP } ;
23
24
use std:: cell:: Cell ;
@@ -30,10 +31,7 @@ use thin_vec::ThinVec;
30
31
use super :: QueryConfig ;
31
32
32
33
pub struct QueryState < K , D : DepKind > {
33
- #[ cfg( parallel_compiler) ]
34
34
active : Sharded < FxHashMap < K , QueryResult < D > > > ,
35
- #[ cfg( not( parallel_compiler) ) ]
36
- active : Lock < FxHashMap < K , QueryResult < D > > > ,
37
35
}
38
36
39
37
/// Indicates the state of a query for a given key in a query map.
52
50
D : DepKind ,
53
51
{
54
52
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 ( ) )
64
54
}
65
55
66
56
pub fn try_collect_active_jobs < Qcx : Copy > (
@@ -71,26 +61,10 @@ where
71
61
) -> Option < ( ) > {
72
62
let mut active = Vec :: new ( ) ;
73
63
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 ( ) {
94
68
if let QueryResult :: Started ( ref job) = * v {
95
69
active. push ( ( * k, job. clone ( ) ) ) ;
96
70
}
@@ -184,10 +158,7 @@ where
184
158
cache. complete ( key, result, dep_node_index) ;
185
159
186
160
let job = {
187
- #[ cfg( parallel_compiler) ]
188
161
let mut lock = state. active . get_shard_by_value ( & key) . lock ( ) ;
189
- #[ cfg( not( parallel_compiler) ) ]
190
- let mut lock = state. active . lock ( ) ;
191
162
match lock. remove ( & key) . unwrap ( ) {
192
163
QueryResult :: Started ( job) => job,
193
164
QueryResult :: Poisoned => panic ! ( ) ,
@@ -209,10 +180,7 @@ where
209
180
// Poison the query so jobs waiting on it panic.
210
181
let state = self . state ;
211
182
let job = {
212
- #[ cfg( parallel_compiler) ]
213
183
let mut shard = state. active . get_shard_by_value ( & self . key ) . lock ( ) ;
214
- #[ cfg( not( parallel_compiler) ) ]
215
- let mut shard = state. active . lock ( ) ;
216
184
let job = match shard. remove ( & self . key ) . unwrap ( ) {
217
185
QueryResult :: Started ( job) => job,
218
186
QueryResult :: Poisoned => panic ! ( ) ,
@@ -336,10 +304,7 @@ where
336
304
Qcx : QueryContext ,
337
305
{
338
306
let state = query. query_state ( qcx) ;
339
- #[ cfg( parallel_compiler) ]
340
307
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 ( ) ;
343
308
344
309
// For the parallel compiler we need to check both the query cache and query state structures
345
310
// while holding the state lock to ensure that 1) the query has not yet completed and 2) the
0 commit comments