@@ -17,7 +17,17 @@ public class Utils
1717 public static AssociativeGraph . GraphNode GetGraphNodeAtPC ( int pc , List < AssociativeGraph . GraphNode > graphNodesInScope )
1818 {
1919 Validity . Assert ( graphNodesInScope != null ) ;
20- return graphNodesInScope . FirstOrDefault ( g => g . isActive && g . isDirty && g . updateBlock . startpc == pc ) ;
20+
21+ for ( int i = 0 ; i < graphNodesInScope . Count ; i ++ )
22+ {
23+ var g = graphNodesInScope [ i ] ;
24+ if ( g . isActive && g . isDirty && g . updateBlock . startpc == pc )
25+ {
26+ return g ;
27+ }
28+ }
29+
30+ return null ;
2131 }
2232
2333 /// <summary>
@@ -29,7 +39,17 @@ public static AssociativeGraph.GraphNode GetGraphNodeAtPC(int pc, List<Associati
2939 public static AssociativeGraph . GraphNode GetFirstDirtyGraphNodeFromPC ( int pc , List < AssociativeGraph . GraphNode > graphNodesInScope )
3040 {
3141 Validity . Assert ( graphNodesInScope != null ) ;
32- return graphNodesInScope . FirstOrDefault ( g => g . isActive && g . isDirty && g . updateBlock . startpc >= pc ) ;
42+
43+ for ( int i = 0 ; i < graphNodesInScope . Count ; i ++ )
44+ {
45+ var g = graphNodesInScope [ i ] ;
46+ if ( g . isActive && g . isDirty && g . updateBlock . startpc >= pc )
47+ {
48+ return g ;
49+ }
50+ }
51+
52+ return null ;
3353 }
3454
3555 /// <summary>
@@ -659,39 +679,39 @@ public static bool IsGraphNodeRedefined(AssociativeGraph.GraphNode gnode, Associ
659679 List < AssociativeGraph . GraphNode > redefinedNodes = new List < AssociativeGraph . GraphNode > ( ) ;
660680 if ( executingGraphNode != null )
661681 {
662- // Remove this condition when full SSA is enabled
663- bool isssa = ( ! executingGraphNode . IsSSANode ( ) && executingGraphNode . DependsOnTempSSA ( ) ) ;
664-
682+ bool isssa ;
665683 if ( runtimeCore . Options . ExecuteSSA )
666684 {
667685 isssa = executingGraphNode . IsSSANode ( ) ;
668686 }
687+ else
688+ {
689+ // Remove this condition when full SSA is enabled
690+ isssa = ( ! executingGraphNode . IsSSANode ( ) && executingGraphNode . DependsOnTempSSA ( ) ) ;
691+ }
692+
669693 if ( ! isssa )
670694 {
671- foreach ( AssociativeGraph . GraphNode graphNode in nodesInScope )
672- {
673- bool allowRedefine = true ;
674695
675- SymbolNode symbol = executingGraphNode . updateNodeRefList [ 0 ] . nodeList [ 0 ] . symbol ;
676- bool isMember = symbol . classScope != Constants . kInvalidIndex
677- && symbol . functionIndex == Constants . kInvalidIndex ;
696+ SymbolNode symbol = executingGraphNode . updateNodeRefList [ 0 ] . nodeList [ 0 ] . symbol ;
697+ bool isMember = symbol . classScope != Constants . kInvalidIndex
698+ && symbol . functionIndex == Constants . kInvalidIndex ;
678699
700+ foreach ( AssociativeGraph . GraphNode graphNode in nodesInScope )
701+ {
679702 if ( isMember )
680703 {
681704 // For member vars, do not allow if not in the same scope
682705 if ( symbol . classScope != graphNode . classIndex || symbol . functionIndex != graphNode . procIndex )
683706 {
684- allowRedefine = false ;
707+ continue ;
685708 }
686709 }
687710
688- if ( allowRedefine )
711+ // Check if graphnode was redefined by executingGraphNode
712+ if ( AssociativeEngine . Utils . IsGraphNodeRedefined ( graphNode , executingGraphNode ) )
689713 {
690- // Check if graphnode was redefined by executingGraphNode
691- if ( AssociativeEngine . Utils . IsGraphNodeRedefined ( graphNode , executingGraphNode ) )
692- {
693- redefinedNodes . Add ( graphNode ) ;
694- }
714+ redefinedNodes . Add ( graphNode ) ;
695715 }
696716 }
697717 }
@@ -1475,8 +1495,13 @@ public bool IsSSANode()
14751495 return false ;
14761496 }
14771497
1478- var firstNode = updateNodeRefList . First ( ) . nodeList . FirstOrDefault ( ) ;
1479- return firstNode != null && firstNode . nodeType == UpdateNodeType . Symbol && firstNode . symbol . isSSATemp ;
1498+ if ( updateNodeRefList [ 0 ] . nodeList . Count > 0 )
1499+ {
1500+ var firstNode = updateNodeRefList [ 0 ] . nodeList [ 0 ] ;
1501+ return firstNode != null && firstNode . nodeType == UpdateNodeType . Symbol && firstNode . symbol . isSSATemp ;
1502+ }
1503+
1504+ return false ;
14801505 }
14811506 }
14821507
0 commit comments