@@ -212,7 +212,7 @@ use rustc::util::common::time;
212
212
use monomorphize:: item:: { MonoItemExt , DefPathBasedNames , InstantiationMode } ;
213
213
214
214
use rustc_data_structures:: bitvec:: BitVector ;
215
- use rustc_data_structures:: sync:: { ParallelIterator , par_iter , Lock } ;
215
+ use rustc_data_structures:: sync:: { MTRef , MTLock , ParallelIterator , par_iter } ;
216
216
217
217
#[ derive( PartialEq , Eq , Hash , Clone , Copy , Debug ) ]
218
218
pub enum MonoItemCollectionMode {
@@ -305,19 +305,25 @@ pub fn collect_crate_mono_items<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
305
305
} ) ;
306
306
307
307
debug ! ( "Building mono item graph, beginning at roots" ) ;
308
- let visited = Lock :: new ( FxHashSet ( ) ) ;
309
- let inlining_map = Lock :: new ( InliningMap :: new ( ) ) ;
310
-
311
- time ( tcx. sess , "collecting mono items" , || {
312
- par_iter ( roots) . for_each ( |root| {
313
- let mut recursion_depths = DefIdMap ( ) ;
314
- collect_items_rec ( tcx,
315
- root,
316
- & visited,
317
- & mut recursion_depths,
318
- & inlining_map) ;
308
+
309
+ let mut visited = MTLock :: new ( FxHashSet ( ) ) ;
310
+ let mut inlining_map = MTLock :: new ( InliningMap :: new ( ) ) ;
311
+
312
+ {
313
+ let visited: MTRef < ' _ , _ > = & mut visited;
314
+ let inlining_map: MTRef < ' _ , _ > = & mut inlining_map;
315
+
316
+ time ( tcx. sess , "collecting mono items" , || {
317
+ par_iter ( roots) . for_each ( |root| {
318
+ let mut recursion_depths = DefIdMap ( ) ;
319
+ collect_items_rec ( tcx,
320
+ root,
321
+ visited,
322
+ & mut recursion_depths,
323
+ inlining_map) ;
324
+ } ) ;
319
325
} ) ;
320
- } ) ;
326
+ }
321
327
322
328
( visited. into_inner ( ) , inlining_map. into_inner ( ) )
323
329
}
@@ -360,10 +366,10 @@ fn collect_roots<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
360
366
// Collect all monomorphized items reachable from `starting_point`
361
367
fn collect_items_rec < ' a , ' tcx : ' a > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
362
368
starting_point : MonoItem < ' tcx > ,
363
- visited : & Lock < FxHashSet < MonoItem < ' tcx > > > ,
369
+ visited : MTRef < ' _ , MTLock < FxHashSet < MonoItem < ' tcx > > > > ,
364
370
recursion_depths : & mut DefIdMap < usize > ,
365
- inlining_map : & Lock < InliningMap < ' tcx > > ) {
366
- if !visited. lock ( ) . insert ( starting_point. clone ( ) ) {
371
+ inlining_map : MTRef < ' _ , MTLock < InliningMap < ' tcx > > > ) {
372
+ if !visited. lock_mut ( ) . insert ( starting_point. clone ( ) ) {
367
373
// We've been here already, no need to search again.
368
374
return ;
369
375
}
@@ -434,7 +440,7 @@ fn collect_items_rec<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
434
440
fn record_accesses < ' a , ' tcx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
435
441
caller : MonoItem < ' tcx > ,
436
442
callees : & [ MonoItem < ' tcx > ] ,
437
- inlining_map : & Lock < InliningMap < ' tcx > > ) {
443
+ inlining_map : MTRef < ' _ , MTLock < InliningMap < ' tcx > > > ) {
438
444
let is_inlining_candidate = |mono_item : & MonoItem < ' tcx > | {
439
445
mono_item. instantiation_mode ( tcx) == InstantiationMode :: LocalCopy
440
446
} ;
@@ -444,7 +450,7 @@ fn record_accesses<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
444
450
( * mono_item, is_inlining_candidate ( mono_item) )
445
451
} ) ;
446
452
447
- inlining_map. lock ( ) . record_accesses ( caller, accesses) ;
453
+ inlining_map. lock_mut ( ) . record_accesses ( caller, accesses) ;
448
454
}
449
455
450
456
fn check_recursion_limit < ' a , ' tcx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
0 commit comments