@@ -382,17 +382,21 @@ where
382
382
}
383
383
384
384
#[ inline( always) ]
385
- fn try_execute_query < Q , CTX > (
385
+ fn try_execute_query < CTX , C > (
386
386
tcx : CTX ,
387
+ state : & QueryState < CTX , C > ,
387
388
span : Span ,
388
- key : Q :: Key ,
389
- lookup : QueryLookup < ' _ , CTX , Q :: Key , <Q :: Cache as QueryCache >:: Sharded > ,
390
- ) -> Q :: Stored
389
+ key : C :: Key ,
390
+ lookup : QueryLookup < ' _ , CTX , C :: Key , C :: Sharded > ,
391
+ query : & QueryVtable < CTX , C :: Key , C :: Value > ,
392
+ ) -> C :: Stored
391
393
where
392
- Q : QueryDescription < CTX > ,
394
+ C : QueryCache ,
395
+ C :: Key : Eq + Clone + Debug ,
396
+ C :: Stored : Clone ,
393
397
CTX : QueryContext ,
394
398
{
395
- let job = match JobOwner :: try_start ( tcx, Q :: query_state ( tcx ) , span, & key, lookup, & Q :: VTABLE ) {
399
+ let job = match JobOwner :: try_start ( tcx, state , span, & key, lookup, query ) {
396
400
TryGetJob :: NotYetStarted ( job) => job,
397
401
TryGetJob :: Cycle ( result) => return result,
398
402
#[ cfg( parallel_compiler) ]
@@ -406,18 +410,32 @@ where
406
410
// expensive for some `DepKind`s.
407
411
if !tcx. dep_graph ( ) . is_fully_enabled ( ) {
408
412
let null_dep_node = DepNode :: new_no_params ( DepKind :: NULL ) ;
409
- return force_query_with_job ( tcx, key, job, null_dep_node, & Q :: VTABLE ) . 0 ;
413
+ return force_query_with_job ( tcx, key, job, null_dep_node, query ) . 0 ;
410
414
}
411
415
412
- if Q :: ANON {
413
- let ( result, dep_node_index) = try_execute_anon_query ( tcx, key, job. id , & Q :: VTABLE ) ;
416
+ if query. anon {
417
+ let prof_timer = tcx. profiler ( ) . query_provider ( ) ;
418
+
419
+ let ( ( result, dep_node_index) , diagnostics) = with_diagnostics ( |diagnostics| {
420
+ tcx. start_query ( job. id , diagnostics, |tcx| {
421
+ tcx. dep_graph ( ) . with_anon_task ( query. dep_kind , || query. compute ( tcx, key) )
422
+ } )
423
+ } ) ;
424
+
425
+ prof_timer. finish_with_query_invocation_id ( dep_node_index. into ( ) ) ;
426
+
427
+ tcx. dep_graph ( ) . read_index ( dep_node_index) ;
428
+
429
+ if unlikely ! ( !diagnostics. is_empty( ) ) {
430
+ tcx. store_diagnostics_for_anon_node ( dep_node_index, diagnostics) ;
431
+ }
414
432
415
433
return job. complete ( tcx, result, dep_node_index) ;
416
434
}
417
435
418
- let dep_node = Q :: to_dep_node ( tcx, & key) ;
436
+ let dep_node = query . to_dep_node ( tcx, & key) ;
419
437
420
- if !Q :: EVAL_ALWAYS {
438
+ if !query . eval_always {
421
439
// The diagnostics for this query will be
422
440
// promoted to the current session during
423
441
// `try_mark_green()`, so we can ignore them here.
@@ -431,7 +449,7 @@ where
431
449
prev_dep_node_index,
432
450
dep_node_index,
433
451
& dep_node,
434
- & Q :: VTABLE ,
452
+ query ,
435
453
) ,
436
454
dep_node_index,
437
455
)
@@ -442,40 +460,11 @@ where
442
460
}
443
461
}
444
462
445
- let ( result, dep_node_index) = force_query_with_job ( tcx, key, job, dep_node, & Q :: VTABLE ) ;
463
+ let ( result, dep_node_index) = force_query_with_job ( tcx, key, job, dep_node, query ) ;
446
464
tcx. dep_graph ( ) . read_index ( dep_node_index) ;
447
465
result
448
466
}
449
467
450
- fn try_execute_anon_query < CTX , K , V > (
451
- tcx : CTX ,
452
- key : K ,
453
- job_id : QueryJobId < CTX :: DepKind > ,
454
- query : & QueryVtable < CTX , K , V > ,
455
- ) -> ( V , DepNodeIndex )
456
- where
457
- CTX : QueryContext ,
458
- {
459
- debug_assert ! ( query. anon) ;
460
- let prof_timer = tcx. profiler ( ) . query_provider ( ) ;
461
-
462
- let ( ( result, dep_node_index) , diagnostics) = with_diagnostics ( |diagnostics| {
463
- tcx. start_query ( job_id, diagnostics, |tcx| {
464
- tcx. dep_graph ( ) . with_anon_task ( query. dep_kind , || query. compute ( tcx, key) )
465
- } )
466
- } ) ;
467
-
468
- prof_timer. finish_with_query_invocation_id ( dep_node_index. into ( ) ) ;
469
-
470
- tcx. dep_graph ( ) . read_index ( dep_node_index) ;
471
-
472
- if unlikely ! ( !diagnostics. is_empty( ) ) {
473
- tcx. store_diagnostics_for_anon_node ( dep_node_index, diagnostics) ;
474
- }
475
-
476
- ( result, dep_node_index)
477
- }
478
-
479
468
fn load_from_disk_and_cache_in_memory < CTX , K , V > (
480
469
tcx : CTX ,
481
470
key : K ,
@@ -639,7 +628,7 @@ where
639
628
tcx. dep_graph ( ) . read_index ( index) ;
640
629
value. clone ( )
641
630
} ,
642
- |key, lookup| try_execute_query :: < Q , _ > ( tcx, span, key, lookup) ,
631
+ |key, lookup| try_execute_query ( tcx , Q :: query_state ( tcx) , span, key, lookup, & Q :: VTABLE ) ,
643
632
)
644
633
}
645
634
0 commit comments