@@ -31,7 +31,7 @@ use turbo_tasks::{
3131 TraitTypeId , TurboTasksBackendApi , ValueTypeId ,
3232 backend:: {
3333 Backend , CachedTaskType , CellContent , TaskExecutionSpec , TransientTaskRoot ,
34- TransientTaskType , TurboTasksExecutionError , TypedCellContent ,
34+ TransientTaskType , TurboTasksExecutionError , TypedCellContent , VerificationMode ,
3535 } ,
3636 event:: { Event , EventListener } ,
3737 message_queue:: TimingEvent ,
@@ -423,6 +423,8 @@ struct TaskExecutionCompletePrepareResult {
423423 pub new_children : FxHashSet < TaskId > ,
424424 pub removed_data : Vec < CachedDataItem > ,
425425 pub is_now_immutable : bool ,
426+ #[ cfg( feature = "verify_determinism" ) ]
427+ pub no_output_set : bool ,
426428 pub new_output : Option < OutputValue > ,
427429 pub output_dependent_tasks : SmallVec < [ TaskId ; 4 ] > ,
428430}
@@ -1765,6 +1767,8 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
17651767 new_children,
17661768 mut removed_data,
17671769 is_now_immutable,
1770+ #[ cfg( feature = "verify_determinism") ]
1771+ no_output_set,
17681772 new_output,
17691773 output_dependent_tasks,
17701774 } ) = self . task_execution_completed_prepare (
@@ -1809,6 +1813,8 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
18091813 if self . task_execution_completed_finish (
18101814 & mut ctx,
18111815 task_id,
1816+ #[ cfg( feature = "verify_determinism" ) ]
1817+ no_output_set,
18121818 new_output,
18131819 & mut removed_data,
18141820 is_now_immutable,
@@ -1843,6 +1849,8 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
18431849 new_children : Default :: default ( ) ,
18441850 removed_data : Default :: default ( ) ,
18451851 is_now_immutable : false ,
1852+ #[ cfg( feature = "verify_determinism" ) ]
1853+ no_output_set : false ,
18461854 new_output : None ,
18471855 output_dependent_tasks : Default :: default ( ) ,
18481856 } ) ;
@@ -2021,6 +2029,8 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
20212029
20222030 // Check if output need to be updated
20232031 let current_output = get ! ( task, Output ) ;
2032+ #[ cfg( feature = "verify_determinism" ) ]
2033+ let no_output_set = current_output. is_none ( ) ;
20242034 let new_output = match result {
20252035 Ok ( RawVc :: TaskOutput ( output_task_id) ) => {
20262036 if let Some ( OutputValue :: Output ( current_task_id) ) = current_output
@@ -2092,6 +2102,8 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
20922102 new_children,
20932103 removed_data,
20942104 is_now_immutable,
2105+ #[ cfg( feature = "verify_determinism" ) ]
2106+ no_output_set,
20952107 new_output,
20962108 output_dependent_tasks,
20972109 } )
@@ -2232,6 +2244,7 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
22322244 & self ,
22332245 ctx : & mut impl ExecuteContext < ' _ > ,
22342246 task_id : TaskId ,
2247+ #[ cfg( feature = "verify_determinism" ) ] no_output_set : bool ,
22352248 new_output : Option < OutputValue > ,
22362249 removed_data : & mut Vec < CachedDataItem > ,
22372250 is_now_immutable : bool ,
@@ -2306,7 +2319,8 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
23062319 None
23072320 } ;
23082321
2309- let data_update = if old_dirty_state != new_dirty_state {
2322+ let dirty_changed = old_dirty_state != new_dirty_state;
2323+ let data_update = if dirty_changed {
23102324 if let Some ( new_dirty_state) = new_dirty_state {
23112325 task. insert ( CachedDataItem :: Dirty {
23122326 value : new_dirty_state,
@@ -2353,17 +2367,32 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
23532367 None
23542368 } ;
23552369
2356- drop ( task) ;
2357- drop ( old_content) ;
2370+ #[ cfg( feature = "verify_determinism" ) ]
2371+ let reschedule = ( dirty_changed || no_output_set) && !task_id. is_transient ( ) ;
2372+ #[ cfg( not( feature = "verify_determinism" ) ) ]
2373+ let reschedule = false ;
2374+ if reschedule {
2375+ task. add_new ( CachedDataItem :: InProgress {
2376+ value : InProgressState :: Scheduled {
2377+ done_event,
2378+ reason : TaskExecutionReason :: Stale ,
2379+ } ,
2380+ } ) ;
2381+ drop ( task) ;
2382+ } else {
2383+ drop ( task) ;
2384+
2385+ // Notify dependent tasks that are waiting for this task to finish
2386+ done_event. notify ( usize:: MAX ) ;
2387+ }
23582388
2359- // Notify dependent tasks that are waiting for this task to finish
2360- done_event. notify ( usize:: MAX ) ;
2389+ drop ( old_content) ;
23612390
23622391 if let Some ( data_update) = data_update {
23632392 AggregationUpdateQueue :: run ( data_update, ctx) ;
23642393 }
23652394
2366- false
2395+ reschedule
23672396 }
23682397
23692398 fn task_execution_completed_cleanup ( & self , ctx : & mut impl ExecuteContext < ' _ > , task_id : TaskId ) {
@@ -2652,12 +2681,14 @@ impl<B: BackingStorage> TurboTasksBackendInner<B> {
26522681 task_id : TaskId ,
26532682 cell : CellId ,
26542683 content : CellContent ,
2684+ verification_mode : VerificationMode ,
26552685 turbo_tasks : & dyn TurboTasksBackendApi < TurboTasksBackend < B > > ,
26562686 ) {
26572687 operation:: UpdateCellOperation :: run (
26582688 task_id,
26592689 cell,
26602690 content,
2691+ verification_mode,
26612692 self . execute_context ( turbo_tasks) ,
26622693 ) ;
26632694 }
@@ -3251,9 +3282,11 @@ impl<B: BackingStorage> Backend for TurboTasksBackend<B> {
32513282 task_id : TaskId ,
32523283 cell : CellId ,
32533284 content : CellContent ,
3285+ verification_mode : VerificationMode ,
32543286 turbo_tasks : & dyn TurboTasksBackendApi < Self > ,
32553287 ) {
3256- self . 0 . update_task_cell ( task_id, cell, content, turbo_tasks) ;
3288+ self . 0
3289+ . update_task_cell ( task_id, cell, content, verification_mode, turbo_tasks) ;
32573290 }
32583291
32593292 fn mark_own_task_as_finished (
0 commit comments