@@ -14,9 +14,9 @@ use std::num::NonZeroU32;
14
14
15
15
#[ cfg( parallel_compiler) ]
16
16
use {
17
+ crate :: dep_graph:: DepKind ,
17
18
parking_lot:: { Condvar , Mutex } ,
18
19
rustc_data_structures:: fx:: FxHashSet ,
19
- rustc_data_structures:: stable_hasher:: { HashStable , StableHasher } ,
20
20
rustc_data_structures:: sync:: Lock ,
21
21
rustc_data_structures:: sync:: Lrc ,
22
22
rustc_data_structures:: { jobserver, OnDrop } ,
@@ -417,30 +417,23 @@ where
417
417
418
418
// Deterministically pick an query from a list
419
419
#[ cfg( parallel_compiler) ]
420
- fn pick_query < ' a , CTX , T , F > (
421
- query_map : & QueryMap < CTX :: DepKind > ,
422
- tcx : CTX ,
423
- queries : & ' a [ T ] ,
424
- f : F ,
425
- ) -> & ' a T
420
+ fn pick_query < ' a , D , T , F > ( query_map : & QueryMap < D > , queries : & ' a [ T ] , f : F ) -> & ' a T
426
421
where
427
- CTX : QueryContext ,
428
- F : Fn ( & T ) -> ( Span , QueryJobId < CTX :: DepKind > ) ,
422
+ D : Copy + Clone + Eq + Hash ,
423
+ F : Fn ( & T ) -> ( Span , QueryJobId < D > ) ,
429
424
{
430
425
// Deterministically pick an entry point
431
426
// FIXME: Sort this instead
432
- let mut hcx = tcx. dep_context ( ) . create_stable_hashing_context ( ) ;
433
427
queries
434
428
. iter ( )
435
429
. min_by_key ( |v| {
436
430
let ( span, query) = f ( v) ;
437
- let mut stable_hasher = StableHasher :: new ( ) ;
438
- query. query ( query_map) . hash_stable ( & mut hcx, & mut stable_hasher) ;
431
+ let hash = query. query ( query_map) . hash ;
439
432
// Prefer entry points which have valid spans for nicer error messages
440
433
// We add an integer to the tuple ensuring that entry points
441
434
// with valid spans are picked first
442
435
let span_cmp = if span == DUMMY_SP { 1 } else { 0 } ;
443
- ( span_cmp, stable_hasher . finish :: < u64 > ( ) )
436
+ ( span_cmp, hash )
444
437
} )
445
438
. unwrap ( )
446
439
}
@@ -451,11 +444,10 @@ where
451
444
/// If a cycle was not found, the starting query is removed from `jobs` and
452
445
/// the function returns false.
453
446
#[ cfg( parallel_compiler) ]
454
- fn remove_cycle < CTX : QueryContext > (
455
- query_map : & QueryMap < CTX :: DepKind > ,
456
- jobs : & mut Vec < QueryJobId < CTX :: DepKind > > ,
457
- wakelist : & mut Vec < Lrc < QueryWaiter < CTX :: DepKind > > > ,
458
- tcx : CTX ,
447
+ fn remove_cycle < D : DepKind > (
448
+ query_map : & QueryMap < D > ,
449
+ jobs : & mut Vec < QueryJobId < D > > ,
450
+ wakelist : & mut Vec < Lrc < QueryWaiter < D > > > ,
459
451
) -> bool {
460
452
let mut visited = FxHashSet :: default ( ) ;
461
453
let mut stack = Vec :: new ( ) ;
@@ -505,15 +497,15 @@ fn remove_cycle<CTX: QueryContext>(
505
497
None
506
498
} else {
507
499
// Deterministically pick one of the waiters to show to the user
508
- let waiter = * pick_query ( query_map, tcx , & waiters, |s| * s) ;
500
+ let waiter = * pick_query ( query_map, & waiters, |s| * s) ;
509
501
Some ( ( span, query, Some ( waiter) ) )
510
502
}
511
503
}
512
504
} )
513
- . collect :: < Vec < ( Span , QueryJobId < CTX :: DepKind > , Option < ( Span , QueryJobId < CTX :: DepKind > ) > ) > > ( ) ;
505
+ . collect :: < Vec < ( Span , QueryJobId < D > , Option < ( Span , QueryJobId < D > ) > ) > > ( ) ;
514
506
515
507
// Deterministically pick an entry point
516
- let ( _, entry_point, usage) = pick_query ( query_map, tcx , & entry_points, |e| ( e. 0 , e. 1 ) ) ;
508
+ let ( _, entry_point, usage) = pick_query ( query_map, & entry_points, |e| ( e. 0 , e. 1 ) ) ;
517
509
518
510
// Shift the stack so that our entry point is first
519
511
let entry_point_pos = stack. iter ( ) . position ( |( _, query) | query == entry_point) ;
@@ -570,7 +562,7 @@ pub fn deadlock<CTX: QueryContext>(tcx: CTX, registry: &rayon_core::Registry) {
570
562
let mut found_cycle = false ;
571
563
572
564
while jobs. len ( ) > 0 {
573
- if remove_cycle ( & query_map, & mut jobs, & mut wakelist, tcx ) {
565
+ if remove_cycle ( & query_map, & mut jobs, & mut wakelist) {
574
566
found_cycle = true ;
575
567
}
576
568
}
0 commit comments