@@ -3,7 +3,6 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
33use rustc_data_structures:: profiling:: { EventId , QueryInvocationId , SelfProfilerRef } ;
44use rustc_data_structures:: sharded:: { self , Sharded } ;
55use rustc_data_structures:: stable_hasher:: { HashStable , StableHasher } ;
6- use rustc_data_structures:: steal:: Steal ;
76use rustc_data_structures:: sync:: { AtomicU32 , AtomicU64 , Lock , Lrc } ;
87use rustc_data_structures:: unord:: UnordMap ;
98use rustc_index:: IndexVec ;
@@ -195,8 +194,11 @@ impl DepGraph {
195194 }
196195
197196 pub fn with_query ( & self , f : impl Fn ( & DepGraphQuery ) ) {
198- if let Some ( data) = & self . data {
199- data. current . encoder . borrow ( ) . with_query ( f)
197+ if let Some ( data) = & self . data
198+ && let Some ( record_graph) = & data. current . record_graph
199+ {
200+ let record_graph = record_graph. lock ( ) ;
201+ f ( & * record_graph)
200202 }
201203 }
202204
@@ -984,7 +986,7 @@ impl DepGraph {
984986
985987 pub fn finish_encoding ( & self , profiler : & SelfProfilerRef ) -> FileEncodeResult {
986988 if let Some ( data) = & self . data {
987- data. current . encoder . steal ( ) . finish ( profiler)
989+ data. current . encoder . lock ( ) . finish ( profiler)
988990 } else {
989991 Ok ( 0 )
990992 }
@@ -1070,7 +1072,8 @@ rustc_index::newtype_index! {
10701072/// manipulating both, we acquire `new_node_to_index` or `prev_index_to_index`
10711073/// first, and `data` second.
10721074pub ( super ) struct CurrentDepGraph {
1073- encoder : Steal < GraphEncoder > ,
1075+ encoder : Lock < GraphEncoder > ,
1076+ record_graph : Option < Lock < DepGraphQuery > > ,
10741077 new_node_to_index : Sharded < FxHashMap < DepNode , DepNodeIndex > > ,
10751078 prev_index_to_index : Lock < IndexVec < SerializedDepNodeIndex , Option < DepNodeIndex > > > ,
10761079
@@ -1146,12 +1149,9 @@ impl CurrentDepGraph {
11461149 . map ( EventId :: from_label) ;
11471150
11481151 CurrentDepGraph {
1149- encoder : Steal :: new ( GraphEncoder :: new :: < D > (
1150- encoder,
1151- prev_graph_node_count,
1152- record_graph,
1153- record_stats,
1154- ) ) ,
1152+ encoder : Lock :: new ( GraphEncoder :: new :: < D > ( encoder, record_stats) ) ,
1153+ record_graph : record_graph
1154+ . then ( || Lock :: new ( DepGraphQuery :: new ( prev_graph_node_count) ) ) ,
11551155 new_node_to_index : Sharded :: new ( || {
11561156 FxHashMap :: with_capacity_and_hasher (
11571157 new_node_count_estimate / sharded:: shards ( ) ,
@@ -1192,8 +1192,13 @@ impl CurrentDepGraph {
11921192 let dep_node_index = match self . new_node_to_index . lock_shard_by_value ( & key) . entry ( key) {
11931193 Entry :: Occupied ( entry) => * entry. get ( ) ,
11941194 Entry :: Vacant ( entry) => {
1195- let dep_node_index =
1196- self . encoder . borrow ( ) . send ( profiler, key, current_fingerprint, edges) ;
1195+ let dep_node_index = self . encoder . lock ( ) . send (
1196+ profiler,
1197+ key,
1198+ current_fingerprint,
1199+ edges,
1200+ & self . record_graph ,
1201+ ) ;
11971202 entry. insert ( dep_node_index) ;
11981203 dep_node_index
11991204 }
@@ -1224,8 +1229,13 @@ impl CurrentDepGraph {
12241229 let dep_node_index = match prev_index_to_index[ prev_index] {
12251230 Some ( dep_node_index) => dep_node_index,
12261231 None => {
1227- let dep_node_index =
1228- self . encoder . borrow ( ) . send ( profiler, key, fingerprint, edges) ;
1232+ let dep_node_index = self . encoder . lock ( ) . send (
1233+ profiler,
1234+ key,
1235+ fingerprint,
1236+ edges,
1237+ & self . record_graph ,
1238+ ) ;
12291239 prev_index_to_index[ prev_index] = Some ( dep_node_index) ;
12301240 dep_node_index
12311241 }
@@ -1287,7 +1297,8 @@ impl CurrentDepGraph {
12871297 . map ( |i| prev_index_to_index[ i] . unwrap ( ) )
12881298 . collect ( ) ;
12891299 let fingerprint = prev_graph. fingerprint_by_index ( prev_index) ;
1290- let dep_node_index = self . encoder . borrow ( ) . send ( profiler, key, fingerprint, edges) ;
1300+ let dep_node_index =
1301+ self . encoder . lock ( ) . send ( profiler, key, fingerprint, edges, & self . record_graph ) ;
12911302 prev_index_to_index[ prev_index] = Some ( dep_node_index) ;
12921303 #[ cfg( debug_assertions) ]
12931304 self . record_edge ( dep_node_index, key, fingerprint) ;
0 commit comments