@@ -3,7 +3,6 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet};
3
3
use rustc_data_structures:: profiling:: { EventId , QueryInvocationId , SelfProfilerRef } ;
4
4
use rustc_data_structures:: sharded:: { self , Sharded } ;
5
5
use rustc_data_structures:: stable_hasher:: { HashStable , StableHasher } ;
6
- use rustc_data_structures:: steal:: Steal ;
7
6
use rustc_data_structures:: sync:: { AtomicU32 , AtomicU64 , Lock , Lrc } ;
8
7
use rustc_data_structures:: unord:: UnordMap ;
9
8
use rustc_index:: IndexVec ;
@@ -195,8 +194,11 @@ impl DepGraph {
195
194
}
196
195
197
196
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)
200
202
}
201
203
}
202
204
@@ -984,7 +986,7 @@ impl DepGraph {
984
986
985
987
pub fn finish_encoding ( & self , profiler : & SelfProfilerRef ) -> FileEncodeResult {
986
988
if let Some ( data) = & self . data {
987
- data. current . encoder . steal ( ) . finish ( profiler)
989
+ data. current . encoder . lock ( ) . finish ( profiler)
988
990
} else {
989
991
Ok ( 0 )
990
992
}
@@ -1070,7 +1072,8 @@ rustc_index::newtype_index! {
1070
1072
/// manipulating both, we acquire `new_node_to_index` or `prev_index_to_index`
1071
1073
/// first, and `data` second.
1072
1074
pub ( super ) struct CurrentDepGraph {
1073
- encoder : Steal < GraphEncoder > ,
1075
+ encoder : Lock < GraphEncoder > ,
1076
+ record_graph : Option < Lock < DepGraphQuery > > ,
1074
1077
new_node_to_index : Sharded < FxHashMap < DepNode , DepNodeIndex > > ,
1075
1078
prev_index_to_index : Lock < IndexVec < SerializedDepNodeIndex , Option < DepNodeIndex > > > ,
1076
1079
@@ -1146,12 +1149,9 @@ impl CurrentDepGraph {
1146
1149
. map ( EventId :: from_label) ;
1147
1150
1148
1151
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) ) ) ,
1155
1155
new_node_to_index : Sharded :: new ( || {
1156
1156
FxHashMap :: with_capacity_and_hasher (
1157
1157
new_node_count_estimate / sharded:: shards ( ) ,
@@ -1192,8 +1192,13 @@ impl CurrentDepGraph {
1192
1192
let dep_node_index = match self . new_node_to_index . lock_shard_by_value ( & key) . entry ( key) {
1193
1193
Entry :: Occupied ( entry) => * entry. get ( ) ,
1194
1194
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
+ ) ;
1197
1202
entry. insert ( dep_node_index) ;
1198
1203
dep_node_index
1199
1204
}
@@ -1224,8 +1229,13 @@ impl CurrentDepGraph {
1224
1229
let dep_node_index = match prev_index_to_index[ prev_index] {
1225
1230
Some ( dep_node_index) => dep_node_index,
1226
1231
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
+ ) ;
1229
1239
prev_index_to_index[ prev_index] = Some ( dep_node_index) ;
1230
1240
dep_node_index
1231
1241
}
@@ -1287,7 +1297,8 @@ impl CurrentDepGraph {
1287
1297
. map ( |i| prev_index_to_index[ i] . unwrap ( ) )
1288
1298
. collect ( ) ;
1289
1299
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 ) ;
1291
1302
prev_index_to_index[ prev_index] = Some ( dep_node_index) ;
1292
1303
#[ cfg( debug_assertions) ]
1293
1304
self . record_edge ( dep_node_index, key, fingerprint) ;
0 commit comments