@@ -175,15 +175,14 @@ where
175
175
/// This function is inlined because that results in a noticeable speed-up
176
176
/// for some compile-time benchmarks.
177
177
#[ inline( always) ]
178
- pub ( super ) fn try_start < Q > (
178
+ pub ( super ) fn try_start (
179
179
tcx : TyCtxt < ' tcx > ,
180
+ state : & ' tcx QueryState < ' tcx , C > ,
180
181
span : Span ,
181
182
key : & C :: Key ,
182
183
mut lookup : QueryLookup < ' tcx , C :: Key , C :: Sharded > ,
183
- ) -> TryGetJob < ' tcx , C >
184
- where
185
- Q : QueryDescription < ' tcx , Key = C :: Key , Value = C :: Value , Cache = C > ,
186
- {
184
+ query : & QueryVtable < ' tcx , C :: Key , C :: Value > ,
185
+ ) -> TryGetJob < ' tcx , C > {
187
186
let lock = & mut * lookup. lock ;
188
187
189
188
let ( latch, mut _query_blocked_prof_timer) = match lock. active . entry ( ( * key) . clone ( ) ) {
@@ -200,7 +199,7 @@ where
200
199
} ;
201
200
202
201
// Create the id of the job we're waiting for
203
- let id = QueryJobId :: new ( job. id , lookup. shard , Q :: DEP_KIND ) ;
202
+ let id = QueryJobId :: new ( job. id , lookup. shard , query . dep_kind ) ;
204
203
205
204
( job. latch ( id) , _query_blocked_prof_timer)
206
205
}
@@ -215,14 +214,13 @@ where
215
214
lock. jobs = id;
216
215
let id = QueryShardJobId ( NonZeroU32 :: new ( id) . unwrap ( ) ) ;
217
216
218
- let global_id = QueryJobId :: new ( id, lookup. shard , Q :: DEP_KIND ) ;
217
+ let global_id = QueryJobId :: new ( id, lookup. shard , query . dep_kind ) ;
219
218
220
219
let job = tls:: with_related_context ( tcx, |icx| QueryJob :: new ( id, span, icx. query ) ) ;
221
220
222
221
entry. insert ( QueryResult :: Started ( job) ) ;
223
222
224
- let owner =
225
- JobOwner { state : Q :: query_state ( tcx) , id : global_id, key : ( * key) . clone ( ) } ;
223
+ let owner = JobOwner { state, id : global_id, key : ( * key) . clone ( ) } ;
226
224
return TryGetJob :: NotYetStarted ( owner) ;
227
225
}
228
226
} ;
@@ -232,7 +230,7 @@ where
232
230
// so we just return the error.
233
231
#[ cfg( not( parallel_compiler) ) ]
234
232
return TryGetJob :: Cycle ( cold_path ( || {
235
- Q :: handle_cycle_error ( tcx, latch. find_cycle_in_stack ( tcx, span) )
233
+ query . handle_cycle_error ( tcx, latch. find_cycle_in_stack ( tcx, span) )
236
234
} ) ) ;
237
235
238
236
// With parallel queries we might just have to wait on some other
@@ -242,11 +240,11 @@ where
242
240
let result = latch. wait_on ( tcx, span) ;
243
241
244
242
if let Err ( cycle) = result {
245
- return TryGetJob :: Cycle ( Q :: handle_cycle_error ( tcx, cycle) ) ;
243
+ return TryGetJob :: Cycle ( query . handle_cycle_error ( tcx, cycle) ) ;
246
244
}
247
245
248
246
let cached = tcx. try_get_cached (
249
- Q :: query_state ( self ) ,
247
+ state ,
250
248
( * key) . clone ( ) ,
251
249
|value, index| ( value. clone ( ) , index) ,
252
250
|_, _| panic ! ( "value must be in cache after waiting" ) ,
@@ -531,15 +529,16 @@ impl<'tcx> TyCtxt<'tcx> {
531
529
key : Q :: Key ,
532
530
lookup : QueryLookup < ' tcx , Q :: Key , <Q :: Cache as QueryCache >:: Sharded > ,
533
531
) -> Q :: Value {
534
- let job = match JobOwner :: try_start :: < Q > ( self , span, & key, lookup) {
535
- TryGetJob :: NotYetStarted ( job) => job,
536
- TryGetJob :: Cycle ( result) => return result,
537
- #[ cfg( parallel_compiler) ]
538
- TryGetJob :: JobCompleted ( ( v, index) ) => {
539
- self . dep_graph . read_index ( index) ;
540
- return v;
541
- }
542
- } ;
532
+ let job =
533
+ match JobOwner :: try_start ( self , Q :: query_state ( self ) , span, & key, lookup, & Q :: VTABLE ) {
534
+ TryGetJob :: NotYetStarted ( job) => job,
535
+ TryGetJob :: Cycle ( result) => return result,
536
+ #[ cfg( parallel_compiler) ]
537
+ TryGetJob :: JobCompleted ( ( v, index) ) => {
538
+ self . dep_graph . read_index ( index) ;
539
+ return v;
540
+ }
541
+ } ;
543
542
544
543
// Fast path for when incr. comp. is off. `to_dep_node` is
545
544
// expensive for some `DepKind`s.
@@ -826,7 +825,14 @@ impl<'tcx> TyCtxt<'tcx> {
826
825
// Cache hit, do nothing
827
826
} ,
828
827
|key, lookup| {
829
- let job = match JobOwner :: try_start :: < Q > ( self , span, & key, lookup) {
828
+ let job = match JobOwner :: try_start (
829
+ self ,
830
+ Q :: query_state ( self ) ,
831
+ span,
832
+ & key,
833
+ lookup,
834
+ & Q :: VTABLE ,
835
+ ) {
830
836
TryGetJob :: NotYetStarted ( job) => job,
831
837
TryGetJob :: Cycle ( _) => return ,
832
838
#[ cfg( parallel_compiler) ]
0 commit comments