rblock in set vars get tainted on rblock enter and wiped at rblock exit, works nicely
authorjjenista <jjenista>
Thu, 24 Jun 2010 18:15:37 +0000 (18:15 +0000)
committerjjenista <jjenista>
Thu, 24 Jun 2010 18:15:37 +0000 (18:15 +0000)
Robust/src/Analysis/Disjoint/Canonical.java
Robust/src/Analysis/Disjoint/DisjointAnalysis.java
Robust/src/Analysis/Disjoint/ReachGraph.java
Robust/src/Analysis/OoOJava/OoOJavaAnalysis.java
Robust/src/Tests/disjoint/taintTest1/makefile
Robust/src/Tests/disjoint/taintTest1/test.java

index bc69349121c0188ee75fe2c4199e63da6cad7c06..40bd77a1f5947583518c83525eb4f359d778668e 100644 (file)
@@ -1417,4 +1417,30 @@ abstract public class Canonical {
     return out;
   }
 
+
+  // BOO, HISS! SESE (rblock) operand does NOT extend
+  // Canonical, so we can't cache this op by its
+  // canonical arguments--THINK ABOUT A BETTER WAY!
+  public static TaintSet removeTaintsBy( TaintSet          ts,
+                                         FlatSESEEnterNode sese ) {
+    assert ts != null;
+    assert ts.isCanonical();
+    assert sese != null;
+
+    // NEVER a cached result... (cry)
+    TaintSet out = new TaintSet();
+
+    Iterator<Taint> tItr = ts.iterator();
+    while( tItr.hasNext() ) {
+      Taint t = tItr.next();
+
+      if( !t.getSESE().equals( sese ) ) {
+        out.taints.add( t );
+      }
+    }
+    
+    out = (TaintSet) makeCanonical( out );
+    //op2result.put( op, out ); CRY CRY
+    return out;
+  }
 }
index 5595e5caa56cf01a324fa343543a5001cc3d0c01..03bfb6d4ddb657f58f939167629e163a98e9f356 100644 (file)
@@ -336,6 +336,9 @@ public class DisjointAnalysis {
   public RBlockRelationAnalysis rblockRel;
   public TypeUtil         typeUtil;
   public int              allocationDepth;
+
+  protected boolean doEffectsAnalysis = false;
+
   
   // data structure for public interface
   private Hashtable< Descriptor, HashSet<AllocSite> > 
@@ -473,8 +476,6 @@ public class DisjointAnalysis {
 
   private Hashtable<FlatCall, Descriptor> fc2enclosing;  
 
-  //protected RBlockRelationAnalysis rra;
-
 
   // allocate various structures that are not local
   // to a single class method--should be done once
@@ -577,6 +578,11 @@ public class DisjointAnalysis {
     this.liveness                = liveness;
     this.arrayReferencees        = arrayReferencees;
     this.rblockRel               = rra;
+
+    if( rblockRel != null ) {
+      doEffectsAnalysis = true;
+    }
+
     this.allocationDepth         = state.DISJOINTALLOCDEPTH;
     this.releaseMode             = state.DISJOINTRELEASEMODE;
     this.determinismDesired      = state.DISJOINTDETERMINISM;
@@ -910,10 +916,6 @@ public class DisjointAnalysis {
        }
       }
       
-      //if(rra.isEndOfRegion(fn)){
-      //  rg.clearAccessibleVarSet();
-      //  also need to clear stall mapping
-      //}
 
       if( takeDebugSnapshots && 
          d.getSymbol().equals( descSymbolDebug ) 
@@ -1005,6 +1007,13 @@ public class DisjointAnalysis {
     // nullified in the graph to reduce edges
     //rg.nullifyDeadVars( liveness.getLiveInTemps( fmContaining, fn ) );
 
+    /*
+      if( doEffectsAnalysis &&
+        rra.isEndOfRegion(fn)){
+      rg.clearAccessibleVarSet();
+      also need to clear stall mapping
+    }
+    */
          
     TempDescriptor  lhs;
     TempDescriptor  rhs;
@@ -1050,6 +1059,24 @@ public class DisjointAnalysis {
        lhs = fon.getDest();
        rhs = fon.getLeft();
        rg.assignTempXEqualToTempY( lhs, rhs );
+
+        /*
+        if( doEffectsAnalysis ) {         
+          // current sese is top of stack at this program point
+          FlatSESEEnterNode sese = 
+            rblockRel.getRBlockStacks( fmContaining, fn ).peek();
+
+          // if we are assigning to an out-set var, the taint
+          // on the out-set var edges should be TRUE (and propagate
+          // back to callers
+
+          rg.taintTemp( sese, 
+                        null, 
+                        lhs,
+                        ReachGraph.predsTrue 
+                        );
+        }
+        */
       }
       break;
 
@@ -1131,19 +1158,20 @@ public class DisjointAnalysis {
       }
       break;
 
-      /*
     case FKind.FlatSESEEnterNode:
-      FlatSESEEnterNode sese = (FlatSESEEnterNode) fn;
-      rg.taintLiveTemps( sese,
-                         liveness.getLiveInTemps( fmContaining, fn ) 
-                         );
+      if( doEffectsAnalysis ) {
+        FlatSESEEnterNode sese = (FlatSESEEnterNode) fn;
+        rg.taintInSetVars( sese );                         
+      }
       break;
 
     case FKind.FlatSESEExitNode:
-      FlatSESEExitNode fsexn = (FlatSESEExitNode) fn;
-      rg.removeInContextTaints( fsexn.getFlatEnter() );
+      if( doEffectsAnalysis ) {
+        FlatSESEExitNode fsexn = (FlatSESEExitNode) fn;
+        rg.removeInContextTaints( fsexn.getFlatEnter() );
+      }
       break;
-      */
+
 
     case FKind.FlatCall: {
       Descriptor mdCaller;
index ec80db16781fb8e1d5688c724c4f6434feee476f..cfe73e3921c749c892a510e0159168dca37ecbe3 100644 (file)
@@ -21,9 +21,9 @@ public class ReachGraph {
   protected static final ReachSet   rsetWithEmptyState = Canonical.makePredsTrue(ReachSet.factory( rstateEmpty ));
 
   // predicate constants
-  protected static final ExistPred    predTrue   = ExistPred.factory(); // if no args, true
-  protected static final ExistPredSet predsEmpty = ExistPredSet.factory();
-  protected static final ExistPredSet predsTrue  = ExistPredSet.factory( predTrue );
+  public static final ExistPred    predTrue   = ExistPred.factory(); // if no args, true
+  public static final ExistPredSet predsEmpty = ExistPredSet.factory();
+  public static final ExistPredSet predsTrue  = ExistPredSet.factory( predTrue );
 
 
   // from DisjointAnalysis for convenience
@@ -1271,10 +1271,39 @@ public class ReachGraph {
   }
 
 
-  // either the sese or the callsite should be null!
-  public void taintTemp( FlatSESEEnterNode sese,
-                         FlatNode          stallSite,
-                         TempDescriptor    td
+  public void taintInSetVars( FlatSESEEnterNode sese ) {
+    Iterator<TempDescriptor> isvItr = sese.getInVarSet().iterator()
+;
+    while( isvItr.hasNext() ) {
+      TempDescriptor isv = isvItr.next();
+      VariableNode   vn  = td2vn.get( isv );
+    
+      Iterator<RefEdge> reItr = vn.iteratorToReferencees();
+      while( reItr.hasNext() ) {
+        RefEdge re = reItr.next();
+
+        // these in-set taints should have empty 
+        // predicates so they never propagate
+        // out to callers
+        Taint t = Taint.factory( sese,
+                                 null,
+                                 isv,
+                                 re.getDst().getAllocSite(),
+                                 ExistPredSet.factory()
+                                 );
+      
+        re.setTaints( Canonical.add( re.getTaints(),
+                                     t 
+                                     )
+                      );
+      }
+    }
+  }
+
+  // this is useful for more general tainting
+  public void taintTemp( Taint          taint,
+                         TempDescriptor td,
+                         ExistPredSet   preds
                          ) {
     
     VariableNode vn = td2vn.get( td );
@@ -1282,26 +1311,31 @@ public class ReachGraph {
     Iterator<RefEdge> reItr = vn.iteratorToReferencees();
     while( reItr.hasNext() ) {
       RefEdge re = reItr.next();
-      
-      // these new taints should have empty 
-      // predicates so they never propagate
-      // out to callers
-      Taint t = Taint.factory( sese,
-                               stallSite,
-                               td,
-                               re.getDst().getAllocSite(),
-                               ExistPredSet.factory()
-                               );
-      
+            
       re.setTaints( Canonical.add( re.getTaints(),
-                                   t 
+                                   taint 
                                    )
                     );
     }
   }
   
   public void removeInContextTaints( FlatSESEEnterNode sese ) {
-    
+    Iterator meItr = id2hrn.entrySet().iterator();
+    while( meItr.hasNext() ) {
+      Map.Entry      me  = (Map.Entry)      meItr.next();
+      Integer        id  = (Integer)        me.getKey();
+      HeapRegionNode hrn = (HeapRegionNode) me.getValue();
+
+      Iterator<RefEdge> reItr = hrn.iteratorToReferencers();
+      while( reItr.hasNext() ) {
+        RefEdge re = reItr.next();
+
+        re.setTaints( Canonical.removeTaintsBy( re.getTaints(),
+                                                sese
+                                                )
+                      );
+      }
+    }
   }
 
 
index 130c8f6dee24c30c716c2ada0e5e0da5e0eb392e..a8dac553e3aa053eeabb42dcdb24e52dcaab8aa7 100644 (file)
@@ -108,8 +108,7 @@ public class OoOJavaAnalysis {
     // conflictGraphLockMap = new Hashtable<ConflictGraph, HashSet<SESELock>>();
 
     // 1st pass, find basic rblock relations
-    RBlockRelationAnalysis rblockRel = 
-      new RBlockRelationAnalysis(state, typeUtil, callGraph);
+    rblockRel = new RBlockRelationAnalysis(state, typeUtil, callGraph);
     
     // 2nd pass, liveness, in-set out-set (no virtual reads yet!)
     Iterator<FlatSESEEnterNode> rootItr = 
@@ -160,7 +159,8 @@ public class OoOJavaAnalysis {
     }
 
     // MORE PASSES?
-
+    
+    
   }
 
 
index 2224b4054e39b1be53430c272a859d98619039a7..56dcc005d6352bb8274edb56fbf585f3fdf82831 100644 (file)
@@ -4,8 +4,8 @@ SOURCE_FILES=$(PROGRAM).java
 
 BUILDSCRIPT=~/research/Robust/src/buildscript
 
-
-BSFLAGS= -mainclass Test -justanalyze -ooojava -disjoint -disjoint-k 2 -disjoint-write-dots final -enable-assertions
+BSFLAGS= -mainclass Test -justanalyze -ooojava -disjoint -disjoint-k 1 -enable-assertions
+DEBUGFLAGS= -disjoint-write-dots final -disjoint-debug-snap-method main 0 10 true
 
 all: $(PROGRAM).bin
 
index ace7ac5e112f84fb3e67d1aeecc22d2be12b9d13..748edf401b1dfeeb3e88082728a78230545e74ab 100644 (file)
@@ -9,34 +9,44 @@ public class Test {
   static public void main( String[] args ) {
 
     Foo a = new Foo();
-    doSomething( a );
-  }
+    Foo b = new Foo();
 
-  static void doSomething( Foo a ) {
+    if( false ) {
+      a = new Foo();
+    }
 
-    a.f = new Foo();
-    
-    rblock r1 {
-      Foo b = a.f;
-      b.f = new Foo();
+    rblock p1 {
+      a.f = new Foo();
+      a.g = new Foo();
+
+      Foo x = a.f;
     }
 
-    rblock r2 {
-      Foo c = a.f.f;
-      c.f = new Foo();
+    rblock p2 {
+      a.f = new Foo();      
+      b.f = new Foo();
+
+      rblock c1 {
+        Foo d = a;
+        d.g = new Foo();
+        Foo e = d.g;
+      }
+
+      Foo y = a.f;
     }
 
 
+    
+    //doSomething( a );
+  }
+
+  static void doSomething( Foo a ) {
+
     //Foo f = doStuff( a, c );
   }   
 
   static Foo doStuff( Foo m, Foo n ) {
 
-    m.f = new Foo();
-    n.f = new Foo();
-
-    m.g = n.f;
-
     return new Foo();
   }
 }