@@ -375,10 +375,10 @@ impl CalcStack {
375375 fn on_scc_detected ( & self , raw : Vec1 < CalcId > ) -> SccDetectedResult {
376376 let calc_stack_vec = self . into_vec ( ) ;
377377
378- // Create the new SCC - this computes min_stack_depth as the anchor's position
378+ // Create the new SCC
379379 let new_scc = Scc :: new ( raw, & calc_stack_vec) ;
380380 let detected_at = new_scc. detected_at . dupe ( ) ;
381- let cycle_start_pos = new_scc. min_stack_depth ;
381+ let cycle_start_pos = new_scc. anchor_pos ;
382382
383383 // Check for overlapping SCCs and merge if needed
384384 let mut scc_stack = self . scc_stack . borrow_mut ( ) ;
@@ -552,18 +552,18 @@ impl CalcStack {
552552 // use it to determine how much of the CalcStack needs to be merged in order
553553 // to ensure bindings that weren't yet part of a known SCC are included.
554554 let mut sccs_to_merge: Vec < Scc > = Vec :: new ( ) ;
555- let mut target_min_stack_depth : Option < usize > = None ;
555+ let mut target_anchor_pos : Option < usize > = None ;
556556 while let Some ( scc) = scc_stack. pop ( ) {
557557 let is_target = scc. detected_at ( ) == * detected_at_of_scc;
558558 if is_target {
559- target_min_stack_depth = Some ( scc. min_stack_depth ) ;
559+ target_anchor_pos = Some ( scc. anchor_pos ) ;
560560 }
561561 sccs_to_merge. push ( scc) ;
562562 if is_target {
563563 break ;
564564 }
565565 }
566- let min_depth = target_min_stack_depth
566+ let min_depth = target_anchor_pos
567567 . expect ( "Target SCC not found during merge - this indicates a bug in SCC tracking" ) ;
568568 let sccs_to_merge = Vec1 :: try_from_vec ( sccs_to_merge)
569569 . expect ( "Target SCC not found during merge - this indicates a bug in SCC tracking" ) ;
@@ -702,13 +702,6 @@ pub struct Scc {
702702 node_state : HashMap < CalcId , NodeState > ,
703703 /// Where we detected the SCC (for debugging only)
704704 detected_at : CalcId ,
705- /// The minimum CalcStack depth of any participant - specifically, the
706- /// position of the anchor (minimal CalcId) on the CalcStack when the SCC
707- /// was created. This is well-defined because the anchor is the last
708- /// participant to finish during unwinding.
709- /// Used as a fast filter to skip SCCs that can't possibly overlap with
710- /// a newly detected cycle.
711- min_stack_depth : usize ,
712705 /// Stack position of the SCC anchor (the position of the detected_at CalcId).
713706 /// The detected_at CalcId is the one that was pushed twice, triggering cycle
714707 /// detection; its first occurrence is at the deepest position in the cycle
@@ -763,7 +756,6 @@ impl Scc {
763756 break_at : break_at_set,
764757 node_state,
765758 detected_at,
766- min_stack_depth : anchor_pos,
767759 anchor_pos,
768760 segment_size,
769761 }
@@ -841,8 +833,6 @@ impl Scc {
841833 }
842834 // Keep the smallest detected_at for consistency/determinism
843835 self . detected_at = self . detected_at . min ( other. detected_at ) ;
844- // Keep the minimum stack depth (the earliest anchor position)
845- self . min_stack_depth = self . min_stack_depth . min ( other. min_stack_depth ) ;
846836 // Keep the minimum anchor position
847837 self . anchor_pos = self . anchor_pos . min ( other. anchor_pos ) ;
848838 // Note: segment_size is NOT updated here. After a merge, everything from
@@ -1540,15 +1530,14 @@ mod scc_tests {
15401530 break_at : Vec < CalcId > ,
15411531 node_state : HashMap < CalcId , NodeState > ,
15421532 detected_at : CalcId ,
1543- min_stack_depth : usize ,
1533+ anchor_pos : usize ,
15441534 ) -> Scc {
15451535 let segment_size = node_state. len ( ) ;
15461536 Scc {
15471537 break_at : break_at. into_iter ( ) . collect ( ) ,
15481538 node_state,
15491539 detected_at,
1550- min_stack_depth,
1551- anchor_pos : min_stack_depth,
1540+ anchor_pos,
15521541 segment_size,
15531542 }
15541543 }
@@ -1784,13 +1773,13 @@ mod scc_tests {
17841773 vec ! [ a. dupe( ) ] ,
17851774 fresh_nodes ( & [ a. dupe ( ) , b. dupe ( ) ] ) ,
17861775 a. dupe ( ) ,
1787- 0 , // min_stack_depth
1776+ 0 , // anchor_pos
17881777 ) ;
17891778 let scc2 = make_test_scc (
17901779 vec ! [ c. dupe( ) ] ,
17911780 fresh_nodes ( & [ c. dupe ( ) , d. dupe ( ) ] ) ,
17921781 c. dupe ( ) ,
1793- 2 , // min_stack_depth
1782+ 2 , // anchor_pos
17941783 ) ;
17951784
17961785 let merged = Scc :: merge_many ( vec1 ! [ scc1, scc2] , a. dupe ( ) ) ;
@@ -1803,8 +1792,8 @@ mod scc_tests {
18031792 // All nodes should be present
18041793 assert_eq ! ( merged. node_state. len( ) , 4 ) ;
18051794
1806- // min_stack_depth should be the minimum (0)
1807- assert_eq ! ( merged. min_stack_depth , 0 ) ;
1795+ // anchor_pos should be the minimum (0)
1796+ assert_eq ! ( merged. anchor_pos , 0 ) ;
18081797 }
18091798
18101799 #[ test]
@@ -1857,24 +1846,24 @@ mod scc_tests {
18571846 }
18581847
18591848 #[ test]
1860- fn test_merge_many_keeps_minimum_stack_depth ( ) {
1849+ fn test_merge_many_keeps_minimum_anchor_pos ( ) {
18611850 let a = CalcId :: for_test ( "m" , 0 ) ;
18621851 let b = CalcId :: for_test ( "m" , 1 ) ;
18631852 let c = CalcId :: for_test ( "m" , 2 ) ;
18641853
1865- // SCC1 with min_stack_depth = 5
1854+ // SCC1 with anchor_pos = 5
18661855 let scc1 = make_test_scc (
18671856 vec ! [ a. dupe( ) ] ,
18681857 fresh_nodes ( & [ a. dupe ( ) , b. dupe ( ) ] ) ,
18691858 a. dupe ( ) ,
18701859 5 ,
18711860 ) ;
1872- // SCC2 with min_stack_depth = 2
1861+ // SCC2 with anchor_pos = 2
18731862 let scc2 = make_test_scc ( vec ! [ c. dupe( ) ] , fresh_nodes ( & [ c. dupe ( ) ] ) , c. dupe ( ) , 2 ) ;
18741863
18751864 let merged = Scc :: merge_many ( vec1 ! [ scc1, scc2] , a. dupe ( ) ) ;
18761865
1877- // Should keep the minimum stack depth
1878- assert_eq ! ( merged. min_stack_depth , 2 ) ;
1866+ // Should keep the minimum anchor_pos
1867+ assert_eq ! ( merged. anchor_pos , 2 ) ;
18791868 }
18801869}
0 commit comments