@@ -199,11 +199,27 @@ impl DepGraph {
199
199
-> ( R , DepNodeIndex )
200
200
where C : DepGraphSafe + StableHashingContextProvider < ContextType =HCX > ,
201
201
R : HashStable < HCX > ,
202
+ {
203
+ self . with_task_impl ( key, cx, arg, task,
204
+ |data, key| data. borrow_mut ( ) . push_task ( key) ,
205
+ |data, key| data. borrow_mut ( ) . pop_task ( key) )
206
+ }
207
+
208
+ fn with_task_impl < C , A , R , HCX > ( & self ,
209
+ key : DepNode ,
210
+ cx : C ,
211
+ arg : A ,
212
+ task : fn ( C , A ) -> R ,
213
+ push : fn ( & RefCell < CurrentDepGraph > , DepNode ) ,
214
+ pop : fn ( & RefCell < CurrentDepGraph > , DepNode ) -> DepNodeIndex )
215
+ -> ( R , DepNodeIndex )
216
+ where C : DepGraphSafe + StableHashingContextProvider < ContextType =HCX > ,
217
+ R : HashStable < HCX > ,
202
218
{
203
219
if let Some ( ref data) = self . data {
204
220
debug_assert ! ( !data. colors. borrow( ) . contains_key( & key) ) ;
205
221
206
- data. current . borrow_mut ( ) . push_task ( key) ;
222
+ push ( & data. current , key) ;
207
223
if cfg ! ( debug_assertions) {
208
224
profq_msg ( ProfileQueriesMsg :: TaskBegin ( key. clone ( ) ) )
209
225
} ;
@@ -220,7 +236,7 @@ impl DepGraph {
220
236
profq_msg ( ProfileQueriesMsg :: TaskEnd )
221
237
} ;
222
238
223
- let dep_node_index = data. current . borrow_mut ( ) . pop_task ( key) ;
239
+ let dep_node_index = pop ( & data. current , key) ;
224
240
225
241
let mut stable_hasher = StableHasher :: new ( ) ;
226
242
result. hash_stable ( & mut hcx, & mut stable_hasher) ;
@@ -290,6 +306,22 @@ impl DepGraph {
290
306
}
291
307
}
292
308
309
+ /// Execute something within an "eval-always" task which is a task
310
+ // that runs whenever anything changes.
311
+ pub fn with_eval_always_task < C , A , R , HCX > ( & self ,
312
+ key : DepNode ,
313
+ cx : C ,
314
+ arg : A ,
315
+ task : fn ( C , A ) -> R )
316
+ -> ( R , DepNodeIndex )
317
+ where C : DepGraphSafe + StableHashingContextProvider < ContextType =HCX > ,
318
+ R : HashStable < HCX > ,
319
+ {
320
+ self . with_task_impl ( key, cx, arg, task,
321
+ |data, key| data. borrow_mut ( ) . push_eval_always_task ( key) ,
322
+ |data, key| data. borrow_mut ( ) . pop_eval_always_task ( key) )
323
+ }
324
+
293
325
#[ inline]
294
326
pub fn read ( & self , v : DepNode ) {
295
327
if let Some ( ref data) = self . data {
@@ -788,6 +820,24 @@ impl CurrentDepGraph {
788
820
}
789
821
}
790
822
823
+ fn push_eval_always_task ( & mut self , key : DepNode ) {
824
+ self . task_stack . push ( OpenTask :: EvalAlways { node : key } ) ;
825
+ }
826
+
827
+ fn pop_eval_always_task ( & mut self , key : DepNode ) -> DepNodeIndex {
828
+ let popped_node = self . task_stack . pop ( ) . unwrap ( ) ;
829
+
830
+ if let OpenTask :: EvalAlways {
831
+ node,
832
+ } = popped_node {
833
+ debug_assert_eq ! ( node, key) ;
834
+ let krate_idx = self . node_to_node_index [ & DepNode :: new_no_params ( DepKind :: Krate ) ] ;
835
+ self . alloc_node ( node, vec ! [ krate_idx] )
836
+ } else {
837
+ bug ! ( "pop_eval_always_task() - Expected eval always task to be popped" ) ;
838
+ }
839
+ }
840
+
791
841
fn read_index ( & mut self , source : DepNodeIndex ) {
792
842
match self . task_stack . last_mut ( ) {
793
843
Some ( & mut OpenTask :: Regular {
@@ -818,7 +868,8 @@ impl CurrentDepGraph {
818
868
reads. push ( source) ;
819
869
}
820
870
}
821
- Some ( & mut OpenTask :: Ignore ) | None => {
871
+ Some ( & mut OpenTask :: Ignore ) |
872
+ Some ( & mut OpenTask :: EvalAlways { .. } ) | None => {
822
873
// ignore
823
874
}
824
875
}
@@ -851,4 +902,7 @@ enum OpenTask {
851
902
read_set : FxHashSet < DepNodeIndex > ,
852
903
} ,
853
904
Ignore ,
905
+ EvalAlways {
906
+ node : DepNode ,
907
+ } ,
854
908
}
0 commit comments