@@ -112,7 +112,7 @@ impl<'a, 'tcx, Q: QueryDescription<'tcx>> JobOwner<'a, 'tcx, Q> {
112
112
let mut lock = cache. get_shard_by_value ( key) . lock ( ) ;
113
113
if let Some ( value) = lock. results . get ( key) {
114
114
profq_msg ! ( tcx, ProfileQueriesMsg :: CacheHit ) ;
115
- tcx. sess . profiler ( |p| p . record_query_hit ( Q :: NAME ) ) ;
115
+ tcx. prof . query_cache_hit ( Q :: NAME ) ;
116
116
let result = ( value. value . clone ( ) , value. index ) ;
117
117
#[ cfg( debug_assertions) ]
118
118
{
@@ -128,7 +128,7 @@ impl<'a, 'tcx, Q: QueryDescription<'tcx>> JobOwner<'a, 'tcx, Q> {
128
128
// in another thread has completed. Record how long we wait in the
129
129
// self-profiler.
130
130
#[ cfg( parallel_compiler) ]
131
- tcx. sess . profiler ( |p| p . query_blocked_start ( Q :: NAME ) ) ;
131
+ tcx. prof . query_blocked_start ( Q :: NAME ) ;
132
132
133
133
job. clone ( )
134
134
} ,
@@ -170,7 +170,7 @@ impl<'a, 'tcx, Q: QueryDescription<'tcx>> JobOwner<'a, 'tcx, Q> {
170
170
#[ cfg( parallel_compiler) ]
171
171
{
172
172
let result = job. r#await ( tcx, span) ;
173
- tcx. sess . profiler ( |p| p . query_blocked_end ( Q :: NAME ) ) ;
173
+ tcx. prof . query_blocked_end ( Q :: NAME ) ;
174
174
175
175
if let Err ( cycle) = result {
176
176
return TryGetJob :: Cycle ( Q :: handle_cycle_error ( tcx, cycle) ) ;
@@ -382,8 +382,9 @@ impl<'tcx> TyCtxt<'tcx> {
382
382
}
383
383
384
384
if Q :: ANON {
385
+
385
386
profq_msg ! ( self , ProfileQueriesMsg :: ProviderBegin ) ;
386
- self . sess . profiler ( |p| p . start_query ( Q :: NAME ) ) ;
387
+ let prof_timer = self . prof . query_provider ( Q :: NAME ) ;
387
388
388
389
let ( ( result, dep_node_index) , diagnostics) = with_diagnostics ( |diagnostics| {
389
390
self . start_query ( job. job . clone ( ) , diagnostics, |tcx| {
@@ -393,7 +394,7 @@ impl<'tcx> TyCtxt<'tcx> {
393
394
} )
394
395
} ) ;
395
396
396
- self . sess . profiler ( |p| p . end_query ( Q :: NAME ) ) ;
397
+ drop ( prof_timer ) ;
397
398
profq_msg ! ( self , ProfileQueriesMsg :: ProviderEnd ) ;
398
399
399
400
self . dep_graph . read_index ( dep_node_index) ;
@@ -451,9 +452,8 @@ impl<'tcx> TyCtxt<'tcx> {
451
452
// First we try to load the result from the on-disk cache.
452
453
let result = if Q :: cache_on_disk ( self , key. clone ( ) , None ) &&
453
454
self . sess . opts . debugging_opts . incremental_queries {
454
- self . sess . profiler ( |p| p . incremental_load_result_start ( Q :: NAME ) ) ;
455
+ let _prof_timer = self . prof . incr_cache_loading ( Q :: NAME ) ;
455
456
let result = Q :: try_load_from_disk ( self , prev_dep_node_index) ;
456
- self . sess . profiler ( |p| p. incremental_load_result_end ( Q :: NAME ) ) ;
457
457
458
458
// We always expect to find a cached result for things that
459
459
// can be forced from `DepNode`.
@@ -469,21 +469,17 @@ impl<'tcx> TyCtxt<'tcx> {
469
469
470
470
let result = if let Some ( result) = result {
471
471
profq_msg ! ( self , ProfileQueriesMsg :: CacheHit ) ;
472
- self . sess . profiler ( |p| p. record_query_hit ( Q :: NAME ) ) ;
473
-
474
472
result
475
473
} else {
476
474
// We could not load a result from the on-disk cache, so
477
475
// recompute.
478
-
479
- self . sess . profiler ( |p| p. start_query ( Q :: NAME ) ) ;
476
+ let _prof_timer = self . prof . query_provider ( Q :: NAME ) ;
480
477
481
478
// The dep-graph for this computation is already in-place.
482
479
let result = self . dep_graph . with_ignore ( || {
483
480
Q :: compute ( self , key)
484
481
} ) ;
485
482
486
- self . sess . profiler ( |p| p. end_query ( Q :: NAME ) ) ;
487
483
result
488
484
} ;
489
485
@@ -551,7 +547,7 @@ impl<'tcx> TyCtxt<'tcx> {
551
547
key, dep_node) ;
552
548
553
549
profq_msg ! ( self , ProfileQueriesMsg :: ProviderBegin ) ;
554
- self . sess . profiler ( |p| p . start_query ( Q :: NAME ) ) ;
550
+ let prof_timer = self . prof . query_provider ( Q :: NAME ) ;
555
551
556
552
let ( ( result, dep_node_index) , diagnostics) = with_diagnostics ( |diagnostics| {
557
553
self . start_query ( job. job . clone ( ) , diagnostics, |tcx| {
@@ -571,7 +567,7 @@ impl<'tcx> TyCtxt<'tcx> {
571
567
} )
572
568
} ) ;
573
569
574
- self . sess . profiler ( |p| p . end_query ( Q :: NAME ) ) ;
570
+ drop ( prof_timer ) ;
575
571
profq_msg ! ( self , ProfileQueriesMsg :: ProviderEnd ) ;
576
572
577
573
if unlikely ! ( self . sess. opts. debugging_opts. query_dep_graph) {
@@ -619,7 +615,7 @@ impl<'tcx> TyCtxt<'tcx> {
619
615
let _ = self . get_query :: < Q > ( DUMMY_SP , key) ;
620
616
} else {
621
617
profq_msg ! ( self , ProfileQueriesMsg :: CacheHit ) ;
622
- self . sess . profiler ( |p| p . record_query_hit ( Q :: NAME ) ) ;
618
+ self . prof . query_cache_hit ( Q :: NAME ) ;
623
619
}
624
620
}
625
621
0 commit comments