1
1
use rustc_data_structures:: fingerprint:: Fingerprint ;
2
2
use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
3
3
use rustc_data_structures:: profiling:: QueryInvocationId ;
4
+ use rustc_data_structures:: profiling:: SelfProfilerRef ;
4
5
use rustc_data_structures:: sharded:: { self , Sharded } ;
5
6
use rustc_data_structures:: stable_hasher:: { HashStable , StableHasher } ;
6
7
use rustc_data_structures:: steal:: Steal ;
@@ -241,6 +242,7 @@ impl<K: DepKind> DepGraph<K> {
241
242
242
243
// Intern the new `DepNode`.
243
244
let ( dep_node_index, prev_and_color) = data. current . intern_node (
245
+ dcx. profiler ( ) ,
244
246
& data. previous ,
245
247
key,
246
248
edges,
@@ -271,7 +273,12 @@ impl<K: DepKind> DepGraph<K> {
271
273
272
274
/// Executes something within an "anonymous" task, that is, a task the
273
275
/// `DepNode` of which is determined by the list of inputs it read from.
274
- pub fn with_anon_task < OP , R > ( & self , dep_kind : K , op : OP ) -> ( R , DepNodeIndex )
276
+ pub fn with_anon_task < Ctxt : DepContext < DepKind = K > , OP , R > (
277
+ & self ,
278
+ cx : Ctxt ,
279
+ dep_kind : K ,
280
+ op : OP ,
281
+ ) -> ( R , DepNodeIndex )
275
282
where
276
283
OP : FnOnce ( ) -> R ,
277
284
{
@@ -298,8 +305,12 @@ impl<K: DepKind> DepGraph<K> {
298
305
hash : data. current . anon_id_seed . combine ( hasher. finish ( ) ) . into ( ) ,
299
306
} ;
300
307
301
- let dep_node_index =
302
- data. current . intern_new_node ( target_dep_node, task_deps. reads , Fingerprint :: ZERO ) ;
308
+ let dep_node_index = data. current . intern_new_node (
309
+ cx. profiler ( ) ,
310
+ target_dep_node,
311
+ task_deps. reads ,
312
+ Fingerprint :: ZERO ,
313
+ ) ;
303
314
304
315
( result, dep_node_index)
305
316
} else {
@@ -628,8 +639,11 @@ impl<K: DepKind> DepGraph<K> {
628
639
629
640
// We allocating an entry for the node in the current dependency graph and
630
641
// adding all the appropriate edges imported from the previous graph
631
- let dep_node_index =
632
- data. current . promote_node_and_deps_to_current ( & data. previous , prev_dep_node_index) ;
642
+ let dep_node_index = data. current . promote_node_and_deps_to_current (
643
+ tcx. dep_context ( ) . profiler ( ) ,
644
+ & data. previous ,
645
+ prev_dep_node_index,
646
+ ) ;
633
647
634
648
// ... emitting any stored diagnostic ...
635
649
@@ -943,14 +957,16 @@ impl<K: DepKind> CurrentDepGraph<K> {
943
957
/// Assumes that this is a node that has no equivalent in the previous dep-graph.
944
958
fn intern_new_node (
945
959
& self ,
960
+ profiler : & SelfProfilerRef ,
946
961
key : DepNode < K > ,
947
962
edges : EdgesVec ,
948
963
current_fingerprint : Fingerprint ,
949
964
) -> DepNodeIndex {
950
965
match self . new_node_to_index . get_shard_by_value ( & key) . lock ( ) . entry ( key) {
951
966
Entry :: Occupied ( entry) => * entry. get ( ) ,
952
967
Entry :: Vacant ( entry) => {
953
- let dep_node_index = self . encoder . borrow ( ) . send ( key, current_fingerprint, edges) ;
968
+ let dep_node_index =
969
+ self . encoder . borrow ( ) . send ( profiler, key, current_fingerprint, edges) ;
954
970
entry. insert ( dep_node_index) ;
955
971
#[ cfg( debug_assertions) ]
956
972
self . record_edge ( dep_node_index, key) ;
@@ -961,6 +977,7 @@ impl<K: DepKind> CurrentDepGraph<K> {
961
977
962
978
fn intern_node (
963
979
& self ,
980
+ profiler : & SelfProfilerRef ,
964
981
prev_graph : & PreviousDepGraph < K > ,
965
982
key : DepNode < K > ,
966
983
edges : EdgesVec ,
@@ -985,7 +1002,7 @@ impl<K: DepKind> CurrentDepGraph<K> {
985
1002
Some ( dep_node_index) => dep_node_index,
986
1003
None => {
987
1004
let dep_node_index =
988
- self . encoder . borrow ( ) . send ( key, fingerprint, edges) ;
1005
+ self . encoder . borrow ( ) . send ( profiler , key, fingerprint, edges) ;
989
1006
prev_index_to_index[ prev_index] = Some ( dep_node_index) ;
990
1007
dep_node_index
991
1008
}
@@ -1007,7 +1024,7 @@ impl<K: DepKind> CurrentDepGraph<K> {
1007
1024
Some ( dep_node_index) => dep_node_index,
1008
1025
None => {
1009
1026
let dep_node_index =
1010
- self . encoder . borrow ( ) . send ( key, fingerprint, edges) ;
1027
+ self . encoder . borrow ( ) . send ( profiler , key, fingerprint, edges) ;
1011
1028
prev_index_to_index[ prev_index] = Some ( dep_node_index) ;
1012
1029
dep_node_index
1013
1030
}
@@ -1032,7 +1049,7 @@ impl<K: DepKind> CurrentDepGraph<K> {
1032
1049
Some ( dep_node_index) => dep_node_index,
1033
1050
None => {
1034
1051
let dep_node_index =
1035
- self . encoder . borrow ( ) . send ( key, Fingerprint :: ZERO , edges) ;
1052
+ self . encoder . borrow ( ) . send ( profiler , key, Fingerprint :: ZERO , edges) ;
1036
1053
prev_index_to_index[ prev_index] = Some ( dep_node_index) ;
1037
1054
dep_node_index
1038
1055
}
@@ -1050,14 +1067,15 @@ impl<K: DepKind> CurrentDepGraph<K> {
1050
1067
let fingerprint = fingerprint. unwrap_or ( Fingerprint :: ZERO ) ;
1051
1068
1052
1069
// This is a new node: it didn't exist in the previous compilation session.
1053
- let dep_node_index = self . intern_new_node ( key, edges, fingerprint) ;
1070
+ let dep_node_index = self . intern_new_node ( profiler , key, edges, fingerprint) ;
1054
1071
1055
1072
( dep_node_index, None )
1056
1073
}
1057
1074
}
1058
1075
1059
1076
fn promote_node_and_deps_to_current (
1060
1077
& self ,
1078
+ profiler : & SelfProfilerRef ,
1061
1079
prev_graph : & PreviousDepGraph < K > ,
1062
1080
prev_index : SerializedDepNodeIndex ,
1063
1081
) -> DepNodeIndex {
@@ -1070,6 +1088,7 @@ impl<K: DepKind> CurrentDepGraph<K> {
1070
1088
None => {
1071
1089
let key = prev_graph. index_to_node ( prev_index) ;
1072
1090
let dep_node_index = self . encoder . borrow ( ) . send (
1091
+ profiler,
1073
1092
key,
1074
1093
prev_graph. fingerprint_by_index ( prev_index) ,
1075
1094
prev_graph
0 commit comments