@@ -8,7 +8,6 @@ use rustc_data_structures::sync::{AtomicU32, AtomicU64, Lock, Lrc, Ordering};
8
8
use rustc_data_structures:: unord:: UnordMap ;
9
9
use rustc_index:: IndexVec ;
10
10
use rustc_serialize:: opaque:: { FileEncodeResult , FileEncoder } ;
11
- use smallvec:: { smallvec, SmallVec } ;
12
11
use std:: assert_matches:: assert_matches;
13
12
use std:: collections:: hash_map:: Entry ;
14
13
use std:: fmt:: Debug ;
@@ -19,6 +18,7 @@ use std::sync::atomic::Ordering::Relaxed;
19
18
use super :: query:: DepGraphQuery ;
20
19
use super :: serialized:: { GraphEncoder , SerializedDepGraph , SerializedDepNodeIndex } ;
21
20
use super :: { DepContext , DepKind , DepNode , HasDepContext , WorkProductId } ;
21
+ use crate :: dep_graph:: EdgesVec ;
22
22
use crate :: ich:: StableHashingContext ;
23
23
use crate :: query:: { QueryContext , QuerySideEffects } ;
24
24
@@ -137,7 +137,7 @@ impl<K: DepKind> DepGraph<K> {
137
137
let _green_node_index = current. intern_new_node (
138
138
profiler,
139
139
DepNode { kind : DepKind :: NULL , hash : current. anon_id_seed . into ( ) } ,
140
- smallvec ! [ ] ,
140
+ EdgesVec :: new ( ) ,
141
141
Fingerprint :: ZERO ,
142
142
) ;
143
143
assert_eq ! ( _green_node_index, DepNodeIndex :: SINGLETON_DEPENDENCYLESS_ANON_NODE ) ;
@@ -147,7 +147,7 @@ impl<K: DepKind> DepGraph<K> {
147
147
profiler,
148
148
& prev_graph,
149
149
DepNode { kind : DepKind :: RED , hash : Fingerprint :: ZERO . into ( ) } ,
150
- smallvec ! [ ] ,
150
+ EdgesVec :: new ( ) ,
151
151
None ,
152
152
false ,
153
153
) ;
@@ -356,12 +356,12 @@ impl<K: DepKind> DepGraphData<K> {
356
356
357
357
let with_deps = |task_deps| K :: with_deps ( task_deps, || task ( cx, arg) ) ;
358
358
let ( result, edges) = if cx. dep_context ( ) . is_eval_always ( key. kind ) {
359
- ( with_deps ( TaskDepsRef :: EvalAlways ) , smallvec ! [ ] )
359
+ ( with_deps ( TaskDepsRef :: EvalAlways ) , EdgesVec :: new ( ) )
360
360
} else {
361
361
let task_deps = Lock :: new ( TaskDeps {
362
362
#[ cfg( debug_assertions) ]
363
363
node : Some ( key) ,
364
- reads : SmallVec :: new ( ) ,
364
+ reads : EdgesVec :: new ( ) ,
365
365
read_set : Default :: default ( ) ,
366
366
phantom_data : PhantomData ,
367
367
} ) ;
@@ -486,14 +486,14 @@ impl<K: DepKind> DepGraph<K> {
486
486
487
487
// As long as we only have a low number of reads we can avoid doing a hash
488
488
// insert and potentially allocating/reallocating the hashmap
489
- let new_read = if task_deps. reads . len ( ) < TASK_DEPS_READS_CAP {
489
+ let new_read = if task_deps. reads . len ( ) < EdgesVec :: INLINE_CAPACITY {
490
490
task_deps. reads . iter ( ) . all ( |other| * other != dep_node_index)
491
491
} else {
492
492
task_deps. read_set . insert ( dep_node_index)
493
493
} ;
494
494
if new_read {
495
495
task_deps. reads . push ( dep_node_index) ;
496
- if task_deps. reads . len ( ) == TASK_DEPS_READS_CAP {
496
+ if task_deps. reads . len ( ) == EdgesVec :: INLINE_CAPACITY {
497
497
// Fill `read_set` with what we have so far so we can use the hashset
498
498
// next time
499
499
task_deps. read_set . extend ( task_deps. reads . iter ( ) . copied ( ) ) ;
@@ -572,9 +572,13 @@ impl<K: DepKind> DepGraph<K> {
572
572
}
573
573
}
574
574
575
- let mut edges = SmallVec :: new ( ) ;
575
+ let mut edges = EdgesVec :: new ( ) ;
576
576
K :: read_deps ( |task_deps| match task_deps {
577
- TaskDepsRef :: Allow ( deps) => edges. extend ( deps. lock ( ) . reads . iter ( ) . copied ( ) ) ,
577
+ TaskDepsRef :: Allow ( deps) => {
578
+ for index in deps. lock ( ) . reads . iter ( ) . copied ( ) {
579
+ edges. push ( index) ;
580
+ }
581
+ }
578
582
TaskDepsRef :: EvalAlways => {
579
583
edges. push ( DepNodeIndex :: FOREVER_RED_NODE ) ;
580
584
}
@@ -872,7 +876,7 @@ impl<K: DepKind> DepGraphData<K> {
872
876
873
877
let prev_deps = self . previous . edge_targets_from ( prev_dep_node_index) ;
874
878
875
- for & dep_dep_node_index in prev_deps {
879
+ for dep_dep_node_index in prev_deps {
876
880
self . try_mark_parent_green ( qcx, dep_dep_node_index, dep_node, Some ( & frame) ) ?;
877
881
}
878
882
@@ -1308,8 +1312,7 @@ impl<K: DepKind> CurrentDepGraph<K> {
1308
1312
let key = prev_graph. index_to_node ( prev_index) ;
1309
1313
let edges = prev_graph
1310
1314
. edge_targets_from ( prev_index)
1311
- . iter ( )
1312
- . map ( |i| prev_index_to_index[ * i] . unwrap ( ) )
1315
+ . map ( |i| prev_index_to_index[ i] . unwrap ( ) )
1313
1316
. collect ( ) ;
1314
1317
let fingerprint = prev_graph. fingerprint_by_index ( prev_index) ;
1315
1318
let dep_node_index = self . encoder . borrow ( ) . send ( profiler, key, fingerprint, edges) ;
@@ -1335,10 +1338,6 @@ impl<K: DepKind> CurrentDepGraph<K> {
1335
1338
}
1336
1339
}
1337
1340
1338
- /// The capacity of the `reads` field `SmallVec`
1339
- const TASK_DEPS_READS_CAP : usize = 8 ;
1340
- type EdgesVec = SmallVec < [ DepNodeIndex ; TASK_DEPS_READS_CAP ] > ;
1341
-
1342
1341
#[ derive( Debug , Clone , Copy ) ]
1343
1342
pub enum TaskDepsRef < ' a , K : DepKind > {
1344
1343
/// New dependencies can be added to the
0 commit comments