@@ -168,14 +168,15 @@ where
168
168
/// This function is inlined because that results in a noticeable speed-up
169
169
/// for some compile-time benchmarks.
170
170
#[ inline( always) ]
171
- fn try_start < ' a , ' b , Q > (
171
+ fn try_start < ' a , ' b > (
172
172
tcx : CTX ,
173
+ state : & ' b QueryState < CTX , C > ,
173
174
span : Span ,
174
175
key : & C :: Key ,
175
176
mut lookup : QueryLookup < ' a , CTX , C :: Key , C :: Sharded > ,
177
+ query : & QueryVtable < CTX , C :: Key , C :: Value > ,
176
178
) -> TryGetJob < ' b , CTX , C >
177
179
where
178
- Q : QueryDescription < CTX , Key = C :: Key , Stored = C :: Stored , Value = C :: Value , Cache = C > ,
179
180
CTX : QueryContext ,
180
181
{
181
182
let lock = & mut * lookup. lock ;
@@ -194,7 +195,7 @@ where
194
195
} ;
195
196
196
197
// Create the id of the job we're waiting for
197
- let id = QueryJobId :: new ( job. id , lookup. shard , Q :: DEP_KIND ) ;
198
+ let id = QueryJobId :: new ( job. id , lookup. shard , query . dep_kind ) ;
198
199
199
200
( job. latch ( id) , _query_blocked_prof_timer)
200
201
}
@@ -209,15 +210,14 @@ where
209
210
lock. jobs = id;
210
211
let id = QueryShardJobId ( NonZeroU32 :: new ( id) . unwrap ( ) ) ;
211
212
212
- let global_id = QueryJobId :: new ( id, lookup. shard , Q :: DEP_KIND ) ;
213
+ let global_id = QueryJobId :: new ( id, lookup. shard , query . dep_kind ) ;
213
214
214
215
let job = tcx. current_query_job ( ) ;
215
216
let job = QueryJob :: new ( id, span, job) ;
216
217
217
218
entry. insert ( QueryResult :: Started ( job) ) ;
218
219
219
- let owner =
220
- JobOwner { state : Q :: query_state ( tcx) , id : global_id, key : ( * key) . clone ( ) } ;
220
+ let owner = JobOwner { state, id : global_id, key : ( * key) . clone ( ) } ;
221
221
return TryGetJob :: NotYetStarted ( owner) ;
222
222
}
223
223
} ;
@@ -227,8 +227,8 @@ where
227
227
// so we just return the error.
228
228
#[ cfg( not( parallel_compiler) ) ]
229
229
return TryGetJob :: Cycle ( cold_path ( || {
230
- let value = Q :: handle_cycle_error ( tcx, latch. find_cycle_in_stack ( tcx, span) ) ;
231
- Q :: query_state ( tcx ) . cache . store_nocache ( value)
230
+ let value = query . handle_cycle_error ( tcx, latch. find_cycle_in_stack ( tcx, span) ) ;
231
+ state . cache . store_nocache ( value)
232
232
} ) ) ;
233
233
234
234
// With parallel queries we might just have to wait on some other
@@ -238,14 +238,14 @@ where
238
238
let result = latch. wait_on ( tcx, span) ;
239
239
240
240
if let Err ( cycle) = result {
241
- let value = Q :: handle_cycle_error ( tcx, cycle) ;
242
- let value = Q :: query_state ( tcx ) . cache . store_nocache ( value) ;
241
+ let value = query . handle_cycle_error ( tcx, cycle) ;
242
+ let value = state . cache . store_nocache ( value) ;
243
243
return TryGetJob :: Cycle ( value) ;
244
244
}
245
245
246
246
let cached = try_get_cached (
247
247
tcx,
248
- Q :: query_state ( tcx ) ,
248
+ state ,
249
249
( * key) . clone ( ) ,
250
250
|value, index| ( value. clone ( ) , index) ,
251
251
|_, _| panic ! ( "value must be in cache after waiting" ) ,
@@ -392,7 +392,7 @@ where
392
392
Q : QueryDescription < CTX > ,
393
393
CTX : QueryContext ,
394
394
{
395
- let job = match JobOwner :: try_start :: < Q > ( tcx, span, & key, lookup) {
395
+ let job = match JobOwner :: try_start ( tcx , Q :: query_state ( tcx) , span, & key, lookup, & Q :: VTABLE ) {
396
396
TryGetJob :: NotYetStarted ( job) => job,
397
397
TryGetJob :: Cycle ( result) => return result,
398
398
#[ cfg( parallel_compiler) ]
@@ -697,12 +697,14 @@ where
697
697
// Cache hit, do nothing
698
698
} ,
699
699
|key, lookup| {
700
- let job = match JobOwner :: try_start :: < Q > ( tcx, span, & key, lookup) {
701
- TryGetJob :: NotYetStarted ( job) => job,
702
- TryGetJob :: Cycle ( _) => return ,
703
- #[ cfg( parallel_compiler) ]
704
- TryGetJob :: JobCompleted ( _) => return ,
705
- } ;
700
+ let job =
701
+ match JobOwner :: try_start ( tcx, Q :: query_state ( tcx) , span, & key, lookup, & Q :: VTABLE )
702
+ {
703
+ TryGetJob :: NotYetStarted ( job) => job,
704
+ TryGetJob :: Cycle ( _) => return ,
705
+ #[ cfg( parallel_compiler) ]
706
+ TryGetJob :: JobCompleted ( _) => return ,
707
+ } ;
706
708
force_query_with_job ( tcx, key, job, dep_node, & Q :: VTABLE ) ;
707
709
} ,
708
710
) ;
0 commit comments