@@ -92,6 +92,9 @@ pub struct SerializedDepGraph {
9292 /// Stores a map from fingerprints to nodes per dep node kind.
9393 /// This is the reciprocal of `nodes`.
9494 index : Vec < UnhashMap < PackedFingerprint , SerializedDepNodeIndex > > ,
95+ /// The number of previous compilation sessions. This is used to generate
96+ /// unique anon dep nodes per session.
97+ session_count : u64 ,
9598}
9699
97100impl SerializedDepGraph {
@@ -146,6 +149,11 @@ impl SerializedDepGraph {
146149 pub fn node_count ( & self ) -> usize {
147150 self . nodes . len ( )
148151 }
152+
153+ #[ inline]
154+ pub fn session_count ( & self ) -> u64 {
155+ self . session_count
156+ }
149157}
150158
151159/// A packed representation of an edge's start index and byte width.
@@ -252,6 +260,8 @@ impl SerializedDepGraph {
252260 . map ( |_| UnhashMap :: with_capacity_and_hasher ( d. read_u32 ( ) as usize , Default :: default ( ) ) )
253261 . collect ( ) ;
254262
263+ let session_count = d. read_u64 ( ) ;
264+
255265 for ( idx, node) in nodes. iter_enumerated ( ) {
256266 if index[ node. kind . as_usize ( ) ] . insert ( node. hash , idx) . is_some ( ) {
257267 // Side effect nodes can have duplicates
@@ -273,6 +283,7 @@ impl SerializedDepGraph {
273283 edge_list_indices,
274284 edge_list_data,
275285 index,
286+ session_count,
276287 } )
277288 }
278289}
@@ -601,7 +612,7 @@ impl<D: Deps> EncoderState<D> {
601612 stats : _,
602613 kind_stats,
603614 marker : _,
604- previous : _ ,
615+ previous,
605616 } = self ;
606617
607618 let node_count = total_node_count. try_into ( ) . unwrap ( ) ;
@@ -612,6 +623,8 @@ impl<D: Deps> EncoderState<D> {
612623 count. encode ( & mut encoder) ;
613624 }
614625
626+ previous. session_count . checked_add ( 1 ) . unwrap ( ) . encode ( & mut encoder) ;
627+
615628 debug ! ( ?node_count, ?edge_count) ;
616629 debug ! ( "position: {:?}" , encoder. position( ) ) ;
617630 IntEncodedWithFixedSize ( node_count) . encode ( & mut encoder) ;
0 commit comments