1
+ use super :: query:: DepGraphQuery ;
2
+ use super :: serialized:: { GraphEncoder , SerializedDepGraph , SerializedDepNodeIndex } ;
3
+ use super :: { DepContext , DepKind , DepNode , Deps , HasDepContext , WorkProductId } ;
4
+ use crate :: dep_graph:: edges:: EdgesVec ;
5
+ use crate :: ich:: StableHashingContext ;
6
+ use crate :: query:: { QueryContext , QuerySideEffects } ;
1
7
use rustc_data_structures:: fingerprint:: Fingerprint ;
2
8
use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
3
9
use rustc_data_structures:: profiling:: { EventId , QueryInvocationId , SelfProfilerRef } ;
4
10
use rustc_data_structures:: sharded:: { self , Sharded } ;
5
11
use rustc_data_structures:: stable_hasher:: { HashStable , StableHasher } ;
6
12
use rustc_data_structures:: steal:: Steal ;
7
- use rustc_data_structures:: sync:: { AtomicU32 , AtomicU64 , Lock , Lrc } ;
13
+ use rustc_data_structures:: sync:: { AtomicU32 , AtomicU64 , AtomicUsize , Lock , Lrc } ;
8
14
use rustc_data_structures:: unord:: UnordMap ;
9
15
use rustc_index:: IndexVec ;
10
16
use rustc_serialize:: opaque:: { FileEncodeResult , FileEncoder } ;
@@ -15,13 +21,6 @@ use std::hash::Hash;
15
21
use std:: marker:: PhantomData ;
16
22
use std:: sync:: atomic:: Ordering ;
17
23
18
- use super :: query:: DepGraphQuery ;
19
- use super :: serialized:: { GraphEncoder , SerializedDepGraph , SerializedDepNodeIndex } ;
20
- use super :: { DepContext , DepKind , DepNode , Deps , HasDepContext , WorkProductId } ;
21
- use crate :: dep_graph:: edges:: EdgesVec ;
22
- use crate :: ich:: StableHashingContext ;
23
- use crate :: query:: { QueryContext , QuerySideEffects } ;
24
-
25
24
#[ cfg( debug_assertions) ]
26
25
use { super :: debug:: EdgeFilter , std:: env} ;
27
26
@@ -218,6 +217,15 @@ impl<D: Deps> DepGraph<D> {
218
217
D :: with_deps ( TaskDepsRef :: Ignore , op)
219
218
}
220
219
220
+ pub ( crate ) fn with_replay < R > (
221
+ & self ,
222
+ prev_side_effects : & QuerySideEffects ,
223
+ created_def_ids : & AtomicUsize ,
224
+ op : impl FnOnce ( ) -> R ,
225
+ ) -> R {
226
+ D :: with_deps ( TaskDepsRef :: Replay { prev_side_effects, created_def_ids } , op)
227
+ }
228
+
221
229
/// Used to wrap the deserialization of a query result from disk,
222
230
/// This method enforces that no new `DepNodes` are created during
223
231
/// query result deserialization.
@@ -272,6 +280,7 @@ impl<D: Deps> DepGraph<D> {
272
280
}
273
281
274
282
#[ inline( always) ]
283
+ /// A helper for `codegen_cranelift`.
275
284
pub fn with_task < Ctxt : HasDepContext < Deps = D > , A : Debug , R > (
276
285
& self ,
277
286
key : DepNode ,
@@ -468,6 +477,12 @@ impl<D: Deps> DepGraph<D> {
468
477
return ;
469
478
}
470
479
TaskDepsRef :: Ignore => return ,
480
+ // We don't need to record dependencies when rerunning a query
481
+ // because we have no disk cache entry to load. The dependencies
482
+ // are preserved.
483
+ // FIXME: assert that the dependencies don't change instead of
484
+ // recording them.
485
+ TaskDepsRef :: Replay { .. } => return ,
471
486
TaskDepsRef :: Forbid => {
472
487
panic ! ( "Illegal read of: {dep_node_index:?}" )
473
488
}
@@ -573,6 +588,7 @@ impl<D: Deps> DepGraph<D> {
573
588
edges. push ( DepNodeIndex :: FOREVER_RED_NODE ) ;
574
589
}
575
590
TaskDepsRef :: Ignore => { }
591
+ TaskDepsRef :: Replay { .. } => { }
576
592
TaskDepsRef :: Forbid => {
577
593
panic ! ( "Cannot summarize when dependencies are not recorded." )
578
594
}
@@ -1323,6 +1339,16 @@ pub enum TaskDepsRef<'a> {
1323
1339
/// to ensure that the decoding process doesn't itself
1324
1340
/// require the execution of any queries.
1325
1341
Forbid ,
1342
+ /// Side effects from the previous run made available to
1343
+ /// queries when they are reexecuted because their result was not
1344
+ /// available in the cache. The query removes entries from the
1345
+ /// side effect table. The table must be empty
1346
+ Replay {
1347
+ prev_side_effects : & ' a QuerySideEffects ,
1348
+ /// Every new `DefId` is pushed here so we can check
1349
+ /// that they match the cached ones.
1350
+ created_def_ids : & ' a AtomicUsize ,
1351
+ } ,
1326
1352
}
1327
1353
1328
1354
#[ derive( Debug ) ]
0 commit comments