fixed liveness analysis
authorjjenista <jjenista>
Wed, 15 Apr 2009 21:27:31 +0000 (21:27 +0000)
committerjjenista <jjenista>
Wed, 15 Apr 2009 21:27:31 +0000 (21:27 +0000)
Robust/src/Analysis/MLP/MLPAnalysis.java
Robust/src/Analysis/MLP/VarSrcTokTable.java
Robust/src/Analysis/MLP/VariableSourceToken.java
Robust/src/Tests/mlp/tinyTest/test.java

index c64542c4ee4c55196517aea2e9a1b25f14c40578..5abe02d77a6c40a64dac344fb5c50e9242bd1291 100644 (file)
@@ -125,15 +125,13 @@ public class MLPAnalysis {
       FlatSESEEnterNode fsenChild = childItr.next();
       computeReadAndWriteSetBackward( fsenChild );
     }
-    
-    System.out.println( "backwards on "+fsen );
 
     // start from an SESE exit, visit nodes in reverse up to
     // SESE enter in a fixed-point scheme, where children SESEs
     // should already be analyzed and therefore can be skipped 
     // because child SESE enter node has all necessary info
     Set<FlatNode> flatNodesToVisit = new HashSet<FlatNode>();
-    flatNodesToVisit.add( fsen );
+    //flatNodesToVisit.add( fsen );
 
     FlatSESEExitNode fsexn = fsen.getFlatExit();
     for( int i = 0; i < fsexn.numPrev(); i++ ) {
@@ -160,10 +158,6 @@ public class MLPAnalysis {
 
       VarSrcTokTable curr = analyzeFlatNodeBackward( fn, inUnion, fsen );
 
-      
-      //System.out.println( "\nConsidering "+fn+" and\n  prev="+prev+"\n  curr="+curr );
-
-
       // if a new result, schedule backward nodes for analysis
       if( !curr.equals( prev ) ) {
 
@@ -179,8 +173,6 @@ public class MLPAnalysis {
       }
     }
     
-    if( pointResults.get( fsen ) == null ) { System.out.println( "UGH" ); }
-
     fsen.addInVarSet( pointResults.get( fsen ).get() );
 
     if( state.MLPDEBUG ) { 
@@ -239,36 +231,17 @@ public class MLPAnalysis {
 
     case FKind.FlatSESEEnterNode: {
       FlatSESEEnterNode fsen = (FlatSESEEnterNode) fn;
-      vstTable.addAll( fsen.getInVarSet() );
+      //vstTable.addAll( fsen.getInVarSet() );
+      vstTable = vstTable.age( currentSESE );
     } break;
 
     case FKind.FlatSESEExitNode: {
       FlatSESEExitNode fsexn = (FlatSESEExitNode) fn;
-
       
       //FlatSESEEnterNode fsen  = fsexn.getFlatEnter();
-      //assert fsen == seseStack.pop();
-      //seseStack.peek().addInVarSet ( fsen.getInVarSet()  );
-      //seseStack.peek().addOutVarSet( fsen.getOutVarSet() );
     } break;
 
-    /*  
-    case FKind.FlatMethod: {
-      FlatMethod fm = (FlatMethod) fn;
-    } break;
-    */
-
-      /*
-    case FKind.FlatOpNode: 
-    case FKind.FlatCastNode:
-    case FKind.FlatFieldNode:
-    case FKind.FlatSetFieldNode: 
-    case FKind.FlatElementNode:
-    case FKind.FlatSetElementNode:
-      */
-
     default: {
-
       // handle effects of statement in reverse, writes then reads
       TempDescriptor [] writeTemps = fn.writesTemps();
       for( int i = 0; i < writeTemps.length; ++i ) {
@@ -286,46 +259,8 @@ public class MLPAnalysis {
       }
     } break;
 
-    /*
-    case FKind.FlatNew: {
-      FlatNew fnn = (FlatNew) fn;
-      lhs = fnn.getDst();
-      if( !lhs.getType().isImmutable() || lhs.getType().isArray() ) {
-       //AllocationSite as = getAllocationSiteFromFlatNewPRIVATE( fnn );
-      }
-    } break;
-    */
-
-    /*
-    case FKind.FlatCall: {
-      FlatCall fc = (FlatCall) fn;
-      MethodDescriptor md = fc.getMethod();
-      FlatMethod flatm = state.getMethodFlat( md );
-
-
-      if( md.isStatic() ) {
-
-      } else {
-       // if the method descriptor is virtual, then there could be a
-       // set of possible methods that will actually be invoked, so
-       // find all of them and merge all of their results together
-       TypeDescriptor typeDesc = fc.getThis().getType();
-       Set possibleCallees = callGraph.getMethods( md, typeDesc );
-
-       Iterator i = possibleCallees.iterator();
-       while( i.hasNext() ) {
-         MethodDescriptor possibleMd = (MethodDescriptor) i.next();
-         FlatMethod pflatm = state.getMethodFlat( possibleMd );
-
-       }
-      }
-
-    } break;
-    */
-
     } // end switch
 
-
     return vstTable;
   }
 }
index 296c8ece869c92501f8c15333360d9fe03b71564..dac2cfc0d6ff3e2796a9e2bd1313572d5e8fd4e8 100644 (file)
@@ -201,6 +201,33 @@ public class VarSrcTokTable {
     trueSet.remove( vst );
   }
 
+
+  // return a new table based on this one and
+  // age tokens with respect to SESE curr, where
+  // any child becomes curr with age 0, and any
+  // curr tokens increase age by 1
+  public VarSrcTokTable age( FlatSESEEnterNode curr ) {
+    VarSrcTokTable out = new VarSrcTokTable();
+
+    Iterator<VariableSourceToken> itr = trueSet.iterator();
+    while( itr.hasNext() ) {
+      VariableSourceToken vst = itr.next();
+      if( vst.getSESE().equals( curr ) ) {
+        out.add( new VariableSourceToken( curr, 
+                                          vst.getVar(), 
+                                          vst.getAge()+1 ) );
+      } else {
+        assert curr.getChildren().contains( vst.getSESE() );
+        out.add( new VariableSourceToken( curr, 
+                                          vst.getVar(), 
+                                          new Integer( 0 ) ) );
+      }
+    }
+
+    return out;
+  }
+
+
   public boolean equals( Object o ) {
     if( o == null ) {
       return false;
index 089ea9144e79ff3929b202a07f7d5614860051dc..251a31e9a9e980b407672c18c2d3edb4f86da583 100644 (file)
@@ -54,6 +54,6 @@ public class VariableSourceToken {
 
 
   public String toString() {
-    return "["+sese+", "+var+", "+age+"]";
+    return "["+sese.getPrettyIdentifier()+", "+var+", "+age+"]";
   }
 }
index 239734bb3c275f55df6124e3130475b130a58fb1..dd09c80a0bb94145e4c09ac23333be3904239afd 100644 (file)
@@ -5,7 +5,7 @@ public class Test {
     // in the main method
     sese root {
       int n = 10;
-
+      
       sese top {     
        int x = 0;