@@ -8,7 +8,6 @@ use rustc_data_structures::sync::{AtomicU32, AtomicU64, Lock, Lrc, Ordering};
88use rustc_data_structures:: unord:: UnordMap ;
99use rustc_index:: IndexVec ;
1010use rustc_serialize:: opaque:: { FileEncodeResult , FileEncoder } ;
11- use smallvec:: { smallvec, SmallVec } ;
1211use std:: assert_matches:: assert_matches;
1312use std:: collections:: hash_map:: Entry ;
1413use std:: fmt:: Debug ;
@@ -19,6 +18,7 @@ use std::sync::atomic::Ordering::Relaxed;
1918use super :: query:: DepGraphQuery ;
2019use super :: serialized:: { GraphEncoder , SerializedDepGraph , SerializedDepNodeIndex } ;
2120use super :: { DepContext , DepKind , DepNode , HasDepContext , WorkProductId } ;
21+ use crate :: dep_graph:: EdgesVec ;
2222use crate :: ich:: StableHashingContext ;
2323use crate :: query:: { QueryContext , QuerySideEffects } ;
2424
@@ -137,7 +137,7 @@ impl<K: DepKind> DepGraph<K> {
137137 let _green_node_index = current. intern_new_node (
138138 profiler,
139139 DepNode { kind : DepKind :: NULL , hash : current. anon_id_seed . into ( ) } ,
140- smallvec ! [ ] ,
140+ EdgesVec :: new ( ) ,
141141 Fingerprint :: ZERO ,
142142 ) ;
143143 assert_eq ! ( _green_node_index, DepNodeIndex :: SINGLETON_DEPENDENCYLESS_ANON_NODE ) ;
@@ -147,7 +147,7 @@ impl<K: DepKind> DepGraph<K> {
147147 profiler,
148148 & prev_graph,
149149 DepNode { kind : DepKind :: RED , hash : Fingerprint :: ZERO . into ( ) } ,
150- smallvec ! [ ] ,
150+ EdgesVec :: new ( ) ,
151151 None ,
152152 false ,
153153 ) ;
@@ -356,12 +356,12 @@ impl<K: DepKind> DepGraphData<K> {
356356
357357 let with_deps = |task_deps| K :: with_deps ( task_deps, || task ( cx, arg) ) ;
358358 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 ( ) )
360360 } else {
361361 let task_deps = Lock :: new ( TaskDeps {
362362 #[ cfg( debug_assertions) ]
363363 node : Some ( key) ,
364- reads : SmallVec :: new ( ) ,
364+ reads : EdgesVec :: new ( ) ,
365365 read_set : Default :: default ( ) ,
366366 phantom_data : PhantomData ,
367367 } ) ;
@@ -486,14 +486,14 @@ impl<K: DepKind> DepGraph<K> {
486486
487487 // As long as we only have a low number of reads we can avoid doing a hash
488488 // 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 {
490490 task_deps. reads . iter ( ) . all ( |other| * other != dep_node_index)
491491 } else {
492492 task_deps. read_set . insert ( dep_node_index)
493493 } ;
494494 if new_read {
495495 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 {
497497 // Fill `read_set` with what we have so far so we can use the hashset
498498 // next time
499499 task_deps. read_set . extend ( task_deps. reads . iter ( ) . copied ( ) ) ;
@@ -572,9 +572,13 @@ impl<K: DepKind> DepGraph<K> {
572572 }
573573 }
574574
575- let mut edges = SmallVec :: new ( ) ;
575+ let mut edges = EdgesVec :: new ( ) ;
576576 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+ }
578582 TaskDepsRef :: EvalAlways => {
579583 edges. push ( DepNodeIndex :: FOREVER_RED_NODE ) ;
580584 }
@@ -872,7 +876,7 @@ impl<K: DepKind> DepGraphData<K> {
872876
873877 let prev_deps = self . previous . edge_targets_from ( prev_dep_node_index) ;
874878
875- for & dep_dep_node_index in prev_deps {
879+ for dep_dep_node_index in prev_deps {
876880 self . try_mark_parent_green ( qcx, dep_dep_node_index, dep_node, Some ( & frame) ) ?;
877881 }
878882
@@ -1308,8 +1312,7 @@ impl<K: DepKind> CurrentDepGraph<K> {
13081312 let key = prev_graph. index_to_node ( prev_index) ;
13091313 let edges = prev_graph
13101314 . 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 ( ) )
13131316 . collect ( ) ;
13141317 let fingerprint = prev_graph. fingerprint_by_index ( prev_index) ;
13151318 let dep_node_index = self . encoder . borrow ( ) . send ( profiler, key, fingerprint, edges) ;
@@ -1335,10 +1338,6 @@ impl<K: DepKind> CurrentDepGraph<K> {
13351338 }
13361339}
13371340
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-
13421341#[ derive( Debug , Clone , Copy ) ]
13431342pub enum TaskDepsRef < ' a , K : DepKind > {
13441343 /// New dependencies can be added to the
0 commit comments