@@ -46,9 +46,9 @@ impl std::convert::From<DepNodeIndex> for QueryInvocationId {
46
46
}
47
47
48
48
struct DepGraphData < K : DepKind > {
49
- /// The dep-graph from the previous compilation session. It contains all
49
+ /// The dep-graph from the compilation session. It contains all
50
50
/// nodes and edges as well as all fingerprints of nodes that have them.
51
- previous : RwLock < CurrentDepGraph < K > > ,
51
+ graph : RwLock < CurrentDepGraph < K > > ,
52
52
53
53
/// Anonymous `DepNode`s are nodes whose IDs we compute from the list of
54
54
/// their edges. This has the beneficial side-effect that multiple anonymous
@@ -120,7 +120,7 @@ impl<K: DepKind> DepGraph<K> {
120
120
121
121
DepGraph {
122
122
data : Some ( Lrc :: new ( DepGraphData {
123
- previous : RwLock :: new ( CurrentDepGraph :: new ( prev_graph) ) ,
123
+ graph : RwLock :: new ( CurrentDepGraph :: new ( prev_graph) ) ,
124
124
emitting_diagnostics : Default :: default ( ) ,
125
125
previous_work_products : prev_work_products,
126
126
dep_node_debug : Default :: default ( ) ,
@@ -148,7 +148,7 @@ impl<K: DepKind> DepGraph<K> {
148
148
149
149
pub fn query ( & self ) -> DepGraphQuery < K > {
150
150
let data = self . data . as_ref ( ) . unwrap ( ) ;
151
- data. previous . read ( ) . query ( )
151
+ data. graph . read ( ) . query ( )
152
152
}
153
153
154
154
pub fn assert_ignored ( & self ) {
@@ -238,7 +238,7 @@ impl<K: DepKind> DepGraph<K> {
238
238
let current_fingerprint = hash_result ( & mut hcx, & result) ;
239
239
240
240
// Intern the new `DepNode`.
241
- let dep_node_index = data. previous . write ( ) . intern_task_node (
241
+ let dep_node_index = data. graph . write ( ) . intern_task_node (
242
242
key,
243
243
& edges[ ..] ,
244
244
current_fingerprint,
@@ -284,8 +284,8 @@ impl<K: DepKind> DepGraph<K> {
284
284
hash : data. anon_id_seed . combine ( hasher. finish ( ) ) . into ( ) ,
285
285
} ;
286
286
287
- let mut previous = data . previous . write ( ) ;
288
- let dep_node_index = previous . intern_anon_node ( target_dep_node, & task_deps. reads [ ..] ) ;
287
+ let dep_node_index =
288
+ data . graph . write ( ) . intern_anon_node ( target_dep_node, & task_deps. reads [ ..] ) ;
289
289
290
290
( result, dep_node_index)
291
291
} else {
@@ -295,7 +295,7 @@ impl<K: DepKind> DepGraph<K> {
295
295
296
296
/// Executes something within an "eval-always" task which is a task
297
297
/// that runs whenever anything changes.
298
- pub fn with_eval_always_task < Ctxt : HasDepContext < DepKind = K > , A , R > (
298
+ pub ( crate ) fn with_eval_always_task < Ctxt : HasDepContext < DepKind = K > , A , R > (
299
299
& self ,
300
300
key : DepNode < K > ,
301
301
cx : Ctxt ,
@@ -350,31 +350,26 @@ impl<K: DepKind> DepGraph<K> {
350
350
}
351
351
352
352
#[ inline]
353
- pub fn dep_node_index_of ( & self , dep_node : & DepNode < K > ) -> DepNodeIndex {
354
- self . dep_node_index_of_opt ( dep_node) . unwrap ( )
355
- }
356
-
357
- #[ inline]
358
- pub fn dep_node_index_of_opt ( & self , dep_node : & DepNode < K > ) -> Option < DepNodeIndex > {
359
- let data = self . data . as_ref ( ) . unwrap ( ) ;
360
- data. previous . read ( ) . dep_node_index_of_opt ( dep_node)
353
+ fn dep_node_index_of_opt ( & self , dep_node : & DepNode < K > ) -> Option < DepNodeIndex > {
354
+ let data = self . data . as_ref ( ) ?;
355
+ data. graph . read ( ) . dep_node_index_of_opt ( dep_node)
361
356
}
362
357
363
358
#[ inline]
364
359
pub fn dep_node_exists ( & self , dep_node : & DepNode < K > ) -> bool {
365
- self . data . is_some ( ) && self . dep_node_index_of_opt ( dep_node) . is_some ( )
360
+ self . dep_node_index_of_opt ( dep_node) . is_some ( )
366
361
}
367
362
368
363
#[ inline]
369
- pub fn dep_node_of ( & self , dep_node_index : DepNodeIndex ) -> DepNode < K > {
364
+ fn dep_node_of ( & self , dep_node_index : DepNodeIndex ) -> DepNode < K > {
370
365
let data = self . data . as_ref ( ) . unwrap ( ) ;
371
- data. previous . read ( ) . dep_node_of ( dep_node_index)
366
+ data. graph . read ( ) . dep_node_of ( dep_node_index)
372
367
}
373
368
374
369
#[ inline]
375
- pub fn fingerprint_of ( & self , dep_node_index : DepNodeIndex ) -> Fingerprint {
370
+ pub ( crate ) fn fingerprint_of ( & self , dep_node_index : DepNodeIndex ) -> Fingerprint {
376
371
let data = self . data . as_ref ( ) . unwrap ( ) ;
377
- data. previous . read ( ) . fingerprint_of ( dep_node_index)
372
+ data. graph . read ( ) . fingerprint_of ( dep_node_index)
378
373
}
379
374
380
375
/// Checks whether a previous work product exists for `v` and, if
@@ -390,7 +385,7 @@ impl<K: DepKind> DepGraph<K> {
390
385
}
391
386
392
387
#[ inline( always) ]
393
- pub fn register_dep_node_debug_str < F > ( & self , dep_node : DepNode < K > , debug_str_gen : F )
388
+ pub ( crate ) fn register_dep_node_debug_str < F > ( & self , dep_node : DepNode < K > , debug_str_gen : F )
394
389
where
395
390
F : FnOnce ( ) -> String ,
396
391
{
@@ -409,9 +404,9 @@ impl<K: DepKind> DepGraph<K> {
409
404
410
405
pub fn node_color ( & self , dep_node : & DepNode < K > ) -> Option < DepNodeColor > {
411
406
if let Some ( ref data) = self . data {
412
- let previous = data. previous . read ( ) ;
413
- if let Some ( prev_index) = previous . node_to_index_opt ( dep_node) {
414
- return previous . color ( prev_index) ;
407
+ let graph = data. graph . read ( ) ;
408
+ if let Some ( prev_index) = graph . node_to_index_opt ( dep_node) {
409
+ return graph . color ( prev_index) ;
415
410
} else {
416
411
// This is a node that did not exist in the previous compilation
417
412
// session, so we consider it to be red.
@@ -426,7 +421,7 @@ impl<K: DepKind> DepGraph<K> {
426
421
/// A node will have an index, when it's already been marked green, or when we can mark it
427
422
/// green. This function will mark the current task as a reader of the specified node, when
428
423
/// a node index can be found for that node.
429
- pub fn try_mark_green_and_read < Ctxt : QueryContext < DepKind = K > > (
424
+ pub ( crate ) fn try_mark_green_and_read < Ctxt : QueryContext < DepKind = K > > (
430
425
& self ,
431
426
tcx : Ctxt ,
432
427
dep_node : & DepNode < K > ,
@@ -449,8 +444,8 @@ impl<K: DepKind> DepGraph<K> {
449
444
let data = self . data . as_ref ( ) ?;
450
445
451
446
// Return None if the dep node didn't exist in the previous session
452
- let prev_index = data. previous . read ( ) . node_to_index_opt ( dep_node) ?;
453
- let prev_deps = data. previous . read ( ) . color_or_edges ( prev_index) ;
447
+ let prev_index = data. graph . read ( ) . node_to_index_opt ( dep_node) ?;
448
+ let prev_deps = data. graph . read ( ) . color_or_edges ( prev_index) ;
454
449
let prev_deps = match prev_deps {
455
450
Err ( prev_deps) => prev_deps,
456
451
Ok ( DepNodeColor :: Green ) => return Some ( ( prev_index, prev_index. rejuvenate ( ) ) ) ,
@@ -473,7 +468,7 @@ impl<K: DepKind> DepGraph<K> {
473
468
parent_dep_node_index : SerializedDepNodeIndex ,
474
469
dep_node : & DepNode < K > ,
475
470
) -> Option < ( ) > {
476
- let dep_dep_node_color = data. previous . read ( ) . color_or_edges ( parent_dep_node_index) ;
471
+ let dep_dep_node_color = data. graph . read ( ) . color_or_edges ( parent_dep_node_index) ;
477
472
let prev_deps = match dep_dep_node_color {
478
473
Ok ( DepNodeColor :: Green ) => {
479
474
// This dependency has been marked as green before, we are
@@ -482,7 +477,7 @@ impl<K: DepKind> DepGraph<K> {
482
477
debug ! (
483
478
"try_mark_parent_green({:?}) --- found dependency {:?} to be immediately green" ,
484
479
dep_node,
485
- data. previous . read( ) . index_to_node( parent_dep_node_index)
480
+ data. graph . read( ) . index_to_node( parent_dep_node_index)
486
481
) ;
487
482
return Some ( ( ) ) ;
488
483
}
@@ -494,7 +489,7 @@ impl<K: DepKind> DepGraph<K> {
494
489
debug ! (
495
490
"try_mark_parent_green({:?}) - END - dependency {:?} was immediately red" ,
496
491
dep_node,
497
- data. previous . read( ) . index_to_node( parent_dep_node_index)
492
+ data. graph . read( ) . index_to_node( parent_dep_node_index)
498
493
) ;
499
494
return None ;
500
495
}
@@ -508,12 +503,12 @@ impl<K: DepKind> DepGraph<K> {
508
503
is unknown, trying to mark it green",
509
504
dep_node,
510
505
{
511
- let dep_dep_node = data. previous . read( ) . index_to_node( parent_dep_node_index) ;
506
+ let dep_dep_node = data. graph . read( ) . index_to_node( parent_dep_node_index) ;
512
507
( dep_dep_node, dep_dep_node. hash)
513
508
}
514
509
) ;
515
510
516
- let dep_dep_node = & data. previous . read ( ) . index_to_node ( parent_dep_node_index) ;
511
+ let dep_dep_node = & data. graph . read ( ) . index_to_node ( parent_dep_node_index) ;
517
512
let node_index =
518
513
self . try_mark_previous_green ( tcx, data, parent_dep_node_index, prev_deps, dep_dep_node) ;
519
514
if node_index. is_some ( ) {
@@ -538,7 +533,7 @@ impl<K: DepKind> DepGraph<K> {
538
533
return None ;
539
534
}
540
535
541
- let dep_dep_node_color = data. previous . read ( ) . color ( parent_dep_node_index) ;
536
+ let dep_dep_node_color = data. graph . read ( ) . color ( parent_dep_node_index) ;
542
537
543
538
match dep_dep_node_color {
544
539
Some ( DepNodeColor :: Green ) => {
@@ -597,15 +592,15 @@ impl<K: DepKind> DepGraph<K> {
597
592
598
593
// We never try to mark eval_always nodes as green
599
594
debug_assert ! ( !dep_node. kind. is_eval_always( ) ) ;
600
- debug_assert_eq ! ( data. previous . read( ) . index_to_node( prev_dep_node_index) , * dep_node) ;
595
+ debug_assert_eq ! ( data. graph . read( ) . index_to_node( prev_dep_node_index) , * dep_node) ;
601
596
602
597
for & dep_dep_node_index in prev_deps {
603
598
self . try_mark_parent_green ( tcx, data, dep_dep_node_index, dep_node) ?
604
599
}
605
600
606
601
#[ cfg( not( parallel_compiler) ) ]
607
602
debug_assert_eq ! (
608
- data. previous . read( ) . color( prev_dep_node_index) ,
603
+ data. graph . read( ) . color( prev_dep_node_index) ,
609
604
None ,
610
605
"DepGraph::try_mark_previous_green() - Duplicate DepNodeColor \
611
606
insertion for {:?}",
@@ -621,7 +616,7 @@ impl<K: DepKind> DepGraph<K> {
621
616
let dep_node_index = {
622
617
// We allocating an entry for the node in the current dependency graph and
623
618
// adding all the appropriate edges imported from the previous graph
624
- data. previous . write ( ) . intern_dark_green_node ( prev_dep_node_index)
619
+ data. graph . write ( ) . intern_dark_green_node ( prev_dep_node_index)
625
620
} ;
626
621
627
622
// ... and emitting any stored diagnostic.
@@ -677,11 +672,11 @@ impl<K: DepKind> DepGraph<K> {
677
672
let _prof_timer = tcx. profiler ( ) . generic_activity ( "incr_comp_query_cache_promotion" ) ;
678
673
679
674
let data = self . data . as_ref ( ) . unwrap ( ) ;
680
- let previous = data. previous . read ( ) ;
681
- for prev_index in previous . serialized_indices ( ) {
682
- match previous . color ( prev_index) {
675
+ let graph = data. graph . read ( ) ;
676
+ for prev_index in graph . serialized_indices ( ) {
677
+ match graph . color ( prev_index) {
683
678
Some ( DepNodeColor :: Green ) => {
684
- let dep_node = data. previous . read ( ) . index_to_node ( prev_index) ;
679
+ let dep_node = data. graph . read ( ) . index_to_node ( prev_index) ;
685
680
debug ! ( "PROMOTE {:?} {:?}" , prev_index, dep_node) ;
686
681
qcx. try_load_from_on_disk_cache ( & dep_node) ;
687
682
}
@@ -697,11 +692,11 @@ impl<K: DepKind> DepGraph<K> {
697
692
// Register reused dep nodes (i.e. nodes we've marked red or green) with the context.
698
693
pub fn register_reused_dep_nodes < Ctxt : DepContext < DepKind = K > > ( & self , tcx : Ctxt ) {
699
694
let data = self . data . as_ref ( ) . unwrap ( ) ;
700
- let previous = data. previous . read ( ) ;
701
- for prev_index in previous . serialized_indices ( ) {
702
- match previous . color ( prev_index) {
695
+ let graph = data. graph . read ( ) ;
696
+ for prev_index in graph . serialized_indices ( ) {
697
+ match graph . color ( prev_index) {
703
698
Some ( _) => {
704
- let dep_node = data. previous . read ( ) . index_to_node ( prev_index) ;
699
+ let dep_node = data. graph . read ( ) . index_to_node ( prev_index) ;
705
700
tcx. register_reused_dep_node ( & dep_node) ;
706
701
}
707
702
None => { }
@@ -718,7 +713,7 @@ impl<K: DepKind> DepGraph<K> {
718
713
}
719
714
720
715
let data = self . data . as_ref ( ) . unwrap ( ) ;
721
- let prev = & data. previous . read ( ) ;
716
+ let prev = & data. graph . read ( ) ;
722
717
723
718
let mut stats: FxHashMap < _ , Stat < K > > = FxHashMap :: with_hasher ( Default :: default ( ) ) ;
724
719
@@ -797,14 +792,14 @@ impl<K: DepKind> DepGraph<K> {
797
792
}
798
793
799
794
pub fn compression_map ( & self ) -> IndexVec < DepNodeIndex , Option < SerializedDepNodeIndex > > {
800
- self . data . as_ref ( ) . unwrap ( ) . previous . read ( ) . compression_map ( )
795
+ self . data . as_ref ( ) . unwrap ( ) . graph . read ( ) . compression_map ( )
801
796
}
802
797
803
798
pub fn encode < E : Encoder > ( & self , encoder : & mut E ) -> Result < ( ) , E :: Error >
804
799
where
805
800
K : Encodable < E > ,
806
801
{
807
- if let Some ( data) = & self . data { data. previous . read ( ) . encode ( encoder) } else { Ok ( ( ) ) }
802
+ if let Some ( data) = & self . data { data. graph . read ( ) . encode ( encoder) } else { Ok ( ( ) ) }
808
803
}
809
804
}
810
805
0 commit comments