@@ -1937,6 +1937,7 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
19371937 task_id : TaskId ,
19381938 result : Result < RawVc , TurboTasksExecutionError > ,
19391939 cell_counters : & AutoMap < ValueTypeId , u32 , BuildHasherDefault < FxHasher > , 8 > ,
1940+ #[ cfg( feature = "verify_determinism" ) ] stateful : bool ,
19401941 has_invalidator : bool ,
19411942 turbo_tasks : & dyn TurboTasksBackendApi < TurboTasksBackend < B > > ,
19421943 ) -> bool {
@@ -1994,6 +1995,8 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
19941995 task_id,
19951996 result,
19961997 cell_counters,
1998+ #[ cfg( feature = "verify_determinism" ) ]
1999+ stateful,
19972000 has_invalidator,
19982001 )
19992002 else {
@@ -2068,6 +2071,7 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
20682071 task_id : TaskId ,
20692072 result : Result < RawVc , TurboTasksExecutionError > ,
20702073 cell_counters : & AutoMap < ValueTypeId , u32 , BuildHasherDefault < FxHasher > , 8 > ,
2074+ #[ cfg( feature = "verify_determinism" ) ] stateful : bool ,
20712075 has_invalidator : bool ,
20722076 ) -> Option < TaskExecutionCompletePrepareResult > {
20732077 let mut task = ctx. task ( task_id, TaskDataCategory :: All ) ;
@@ -2132,6 +2136,12 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
21322136 // take the children from the task to process them
21332137 let mut new_children = take ( new_children) ;
21342138
2139+ // handle stateful (only tracked when verify_determinism is enabled)
2140+ #[ cfg( feature = "verify_determinism" ) ]
2141+ if stateful {
2142+ task. set_stateful ( true ) ;
2143+ }
2144+
21352145 // handle has_invalidator
21362146 if has_invalidator {
21372147 task. set_invalidator ( true ) ;
@@ -2575,7 +2585,8 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
25752585 } ;
25762586
25772587 // Update the dirty state
2578- if old_dirtyness != new_dirtyness {
2588+ let dirty_changed = old_dirtyness != new_dirtyness;
2589+ if dirty_changed {
25792590 if let Some ( value) = new_dirtyness {
25802591 task. set_dirty ( value) ;
25812592 } else if old_dirtyness. is_some ( ) {
@@ -3139,7 +3150,7 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
31393150 "Task {} {} doesn't report to any root but is reachable from one (uppers: \
31403151 {:?})",
31413152 task_id,
3142- ctx . get_task_description( task_id ) ,
3153+ task . get_task_description( ) ,
31433154 uppers
31443155 ) ;
31453156 }
@@ -3150,14 +3161,14 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
31503161 . collect ( ) ;
31513162 for collectible in aggregated_collectibles {
31523163 collectibles
3153- . entry ( collectible)
3164+ . entry ( * collectible)
31543165 . or_insert_with ( || ( false , Vec :: new ( ) ) )
31553166 . 1
31563167 . push ( task_id) ;
31573168 }
31583169
31593170 let own_collectibles: Vec < _ > = task
3160- . iter_collectibles_entries ( )
3171+ . iter_collectibles ( )
31613172 . filter_map ( |( & collectible, & value) | ( value > 0 ) . then_some ( collectible) )
31623173 . collect :: < Vec < _ > > ( ) ;
31633174 for collectible in own_collectibles {
@@ -3195,22 +3206,25 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
31953206
31963207 if should_be_in_upper {
31973208 for upper_id in uppers {
3198- let task = ctx. task ( upper_id, TaskDataCategory :: All ) ;
3199- let in_upper = task
3209+ let upper = ctx. task ( upper_id, TaskDataCategory :: All ) ;
3210+ let in_upper = upper
32003211 . get_aggregated_dirty_containers ( & task_id)
32013212 . is_some_and ( |& dirty| dirty > 0 ) ;
32023213 if !in_upper {
3203- let containers: Vec < _ > = task
3204- . iter_aggregated_dirty_containers_entries ( )
3214+ let containers: Vec < _ > = upper
3215+ . iter_aggregated_dirty_containers ( )
32053216 . map ( |( & k, & v) | ( k, v) )
32063217 . collect ( ) ;
3218+ let upper_task_desc = upper. get_task_description ( ) ;
3219+ drop ( upper) ;
32073220 panic ! (
32083221 "Task {} ({}) is dirty, but is not listed in the upper task {} \
32093222 ({})\n These dirty containers are present:\n {:#?}",
32103223 task_id,
3211- ctx. get_task_description( task_id) ,
3224+ ctx. task( task_id, TaskDataCategory :: Data )
3225+ . get_task_description( ) ,
32123226 upper_id,
3213- ctx . get_task_description ( upper_id ) ,
3227+ upper_task_desc ,
32143228 containers,
32153229 ) ;
32163230 }
@@ -3229,7 +3243,10 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
32293243 collectible,
32303244 task_ids
32313245 . iter( )
3232- . map( |t| format!( "{t} {}" , ctx. get_task_description( * t) ) )
3246+ . map( |t| format!(
3247+ "{t} {}" ,
3248+ ctx. task( * t, TaskDataCategory :: Data ) . get_task_description( )
3249+ ) )
32333250 . collect:: <Vec <_>>( )
32343251 )
32353252 . unwrap ( ) ;
@@ -3245,8 +3262,8 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
32453262 writeln ! ( stdout, "{task_id:?} -> {upper_id:?}" ) . unwrap ( ) ;
32463263 }
32473264 while let Some ( task_id) = queue. pop ( ) {
3248- let desc = ctx. get_task_description ( task_id) ;
32493265 let task = ctx. task ( task_id, TaskDataCategory :: All ) ;
3266+ let desc = task. get_task_description ( ) ;
32503267 let aggregated_collectible = task
32513268 . get_aggregated_collectibles ( & collectible)
32523269 . copied ( )
@@ -3436,13 +3453,16 @@ impl<B: BackingStorage> Backend for TurboTasksBackend<B> {
34363453 task_id : TaskId ,
34373454 result : Result < RawVc , TurboTasksExecutionError > ,
34383455 cell_counters : & AutoMap < ValueTypeId , u32 , BuildHasherDefault < FxHasher > , 8 > ,
3456+ #[ cfg( feature = "verify_determinism" ) ] stateful : bool ,
34393457 has_invalidator : bool ,
34403458 turbo_tasks : & dyn TurboTasksBackendApi < Self > ,
34413459 ) -> bool {
34423460 self . 0 . task_execution_completed (
34433461 task_id,
34443462 result,
34453463 cell_counters,
3464+ #[ cfg( feature = "verify_determinism" ) ]
3465+ stateful,
34463466 has_invalidator,
34473467 turbo_tasks,
34483468 )
0 commit comments