@@ -215,24 +215,17 @@ impl<K: DepKind> DepGraph<K> {
215
215
cx : Ctxt ,
216
216
arg : A ,
217
217
task : fn ( Ctxt , A ) -> R ,
218
- hash_result : impl FnOnce ( & mut Ctxt :: StableHashingContext , & R ) -> Option < Fingerprint > ,
218
+ hash_result : fn ( & mut Ctxt :: StableHashingContext , & R ) -> Option < Fingerprint > ,
219
219
) -> ( R , DepNodeIndex ) {
220
- self . with_task_impl (
221
- key,
222
- cx,
223
- arg,
224
- task,
225
- |_key| {
226
- Some ( TaskDeps {
227
- #[ cfg( debug_assertions) ]
228
- node : Some ( _key) ,
229
- reads : SmallVec :: new ( ) ,
230
- read_set : Default :: default ( ) ,
231
- phantom_data : PhantomData ,
232
- } )
233
- } ,
234
- hash_result,
235
- )
220
+ if self . is_fully_enabled ( ) {
221
+ self . with_task_impl ( key, cx, arg, task, hash_result)
222
+ } else {
223
+ // Incremental compilation is turned off. We just execute the task
224
+ // without tracking. We still provide a dep-node index that uniquely
225
+ // identifies the task so that we have a cheap way of referring to
226
+ // the query for self-profiling.
227
+ ( task ( cx, arg) , self . next_virtual_depnode_index ( ) )
228
+ }
236
229
}
237
230
238
231
fn with_task_impl < Ctxt : HasDepContext < DepKind = K > , A : Debug , R > (
@@ -241,71 +234,74 @@ impl<K: DepKind> DepGraph<K> {
241
234
cx : Ctxt ,
242
235
arg : A ,
243
236
task : fn ( Ctxt , A ) -> R ,
244
- create_task : fn ( DepNode < K > ) -> Option < TaskDeps < K > > ,
245
- hash_result : impl FnOnce ( & mut Ctxt :: StableHashingContext , & R ) -> Option < Fingerprint > ,
237
+ hash_result : fn ( & mut Ctxt :: StableHashingContext , & R ) -> Option < Fingerprint > ,
246
238
) -> ( R , DepNodeIndex ) {
247
- if let Some ( ref data) = self . data {
248
- // If the following assertion triggers, it can have two reasons:
249
- // 1. Something is wrong with DepNode creation, either here or
250
- // in `DepGraph::try_mark_green()`.
251
- // 2. Two distinct query keys get mapped to the same `DepNode`
252
- // (see for example #48923).
253
- assert ! (
254
- !self . dep_node_exists( & key) ,
255
- "forcing query with already existing `DepNode`\n \
239
+ // This function is only called when the graph is enabled.
240
+ let data = self . data . as_ref ( ) . unwrap ( ) ;
241
+
242
+ // If the following assertion triggers, it can have two reasons:
243
+ // 1. Something is wrong with DepNode creation, either here or
244
+ // in `DepGraph::try_mark_green()`.
245
+ // 2. Two distinct query keys get mapped to the same `DepNode`
246
+ // (see for example #48923).
247
+ assert ! (
248
+ !self . dep_node_exists( & key) ,
249
+ "forcing query with already existing `DepNode`\n \
256
250
- query-key: {:?}\n \
257
251
- dep-node: {:?}",
258
- arg,
259
- key
260
- ) ;
252
+ arg,
253
+ key
254
+ ) ;
261
255
262
- let dcx = cx. dep_context ( ) ;
263
- let task_deps = create_task ( key) . map ( Lock :: new) ;
264
- let result = K :: with_deps ( task_deps. as_ref ( ) , || task ( cx, arg) ) ;
265
- let edges = task_deps. map_or_else ( || smallvec ! [ ] , |lock| lock. into_inner ( ) . reads ) ;
266
-
267
- let mut hcx = dcx. create_stable_hashing_context ( ) ;
268
- let hashing_timer = dcx. profiler ( ) . incr_result_hashing ( ) ;
269
- let current_fingerprint = hash_result ( & mut hcx, & result) ;
270
-
271
- let print_status = cfg ! ( debug_assertions) && dcx. sess ( ) . opts . debugging_opts . dep_tasks ;
272
-
273
- // Get timer for profiling `DepNode` interning
274
- let node_intern_timer = self
275
- . node_intern_event_id
276
- . map ( |eid| dcx. profiler ( ) . generic_activity_with_event_id ( eid) ) ;
277
- // Intern the new `DepNode`.
278
- let ( dep_node_index, prev_and_color) = data. current . intern_node (
279
- dcx. profiler ( ) ,
280
- & data. previous ,
281
- key,
282
- edges,
283
- current_fingerprint,
284
- print_status,
285
- ) ;
286
- drop ( node_intern_timer) ;
256
+ let task_deps = if key. kind . is_eval_always ( ) {
257
+ None
258
+ } else {
259
+ Some ( Lock :: new ( TaskDeps {
260
+ #[ cfg( debug_assertions) ]
261
+ node : Some ( key) ,
262
+ reads : SmallVec :: new ( ) ,
263
+ read_set : Default :: default ( ) ,
264
+ phantom_data : PhantomData ,
265
+ } ) )
266
+ } ;
267
+ let result = K :: with_deps ( task_deps. as_ref ( ) , || task ( cx, arg) ) ;
268
+ let edges = task_deps. map_or_else ( || smallvec ! [ ] , |lock| lock. into_inner ( ) . reads ) ;
269
+
270
+ let dcx = cx. dep_context ( ) ;
271
+ let mut hcx = dcx. create_stable_hashing_context ( ) ;
272
+ let hashing_timer = dcx. profiler ( ) . incr_result_hashing ( ) ;
273
+ let current_fingerprint = hash_result ( & mut hcx, & result) ;
274
+
275
+ let print_status = cfg ! ( debug_assertions) && dcx. sess ( ) . opts . debugging_opts . dep_tasks ;
276
+
277
+ // Get timer for profiling `DepNode` interning
278
+ let node_intern_timer =
279
+ self . node_intern_event_id . map ( |eid| dcx. profiler ( ) . generic_activity_with_event_id ( eid) ) ;
280
+ // Intern the new `DepNode`.
281
+ let ( dep_node_index, prev_and_color) = data. current . intern_node (
282
+ dcx. profiler ( ) ,
283
+ & data. previous ,
284
+ key,
285
+ edges,
286
+ current_fingerprint,
287
+ print_status,
288
+ ) ;
289
+ drop ( node_intern_timer) ;
287
290
288
- hashing_timer. finish_with_query_invocation_id ( dep_node_index. into ( ) ) ;
291
+ hashing_timer. finish_with_query_invocation_id ( dep_node_index. into ( ) ) ;
289
292
290
- if let Some ( ( prev_index, color) ) = prev_and_color {
291
- debug_assert ! (
292
- data. colors. get( prev_index) . is_none( ) ,
293
- "DepGraph::with_task() - Duplicate DepNodeColor \
293
+ if let Some ( ( prev_index, color) ) = prev_and_color {
294
+ debug_assert ! (
295
+ data. colors. get( prev_index) . is_none( ) ,
296
+ "DepGraph::with_task() - Duplicate DepNodeColor \
294
297
insertion for {:?}",
295
- key
296
- ) ;
297
-
298
- data. colors . insert ( prev_index, color) ;
299
- }
298
+ key
299
+ ) ;
300
300
301
- ( result, dep_node_index)
302
- } else {
303
- // Incremental compilation is turned off. We just execute the task
304
- // without tracking. We still provide a dep-node index that uniquely
305
- // identifies the task so that we have a cheap way of referring to
306
- // the query for self-profiling.
307
- ( task ( cx, arg) , self . next_virtual_depnode_index ( ) )
301
+ data. colors . insert ( prev_index, color) ;
308
302
}
303
+
304
+ ( result, dep_node_index)
309
305
}
310
306
311
307
/// Executes something within an "anonymous" task, that is, a task the
@@ -372,19 +368,6 @@ impl<K: DepKind> DepGraph<K> {
372
368
}
373
369
}
374
370
375
- /// Executes something within an "eval-always" task which is a task
376
- /// that runs whenever anything changes.
377
- pub fn with_eval_always_task < Ctxt : HasDepContext < DepKind = K > , A : Debug , R > (
378
- & self ,
379
- key : DepNode < K > ,
380
- cx : Ctxt ,
381
- arg : A ,
382
- task : fn ( Ctxt , A ) -> R ,
383
- hash_result : impl FnOnce ( & mut Ctxt :: StableHashingContext , & R ) -> Option < Fingerprint > ,
384
- ) -> ( R , DepNodeIndex ) {
385
- self . with_task_impl ( key, cx, arg, task, |_| None , hash_result)
386
- }
387
-
388
371
#[ inline]
389
372
pub fn read_index ( & self , dep_node_index : DepNodeIndex ) {
390
373
if let Some ( ref data) = self . data {
0 commit comments