run ooojava and rcrpointer that print out effects and annotate them with the source...
authorjjenista <jjenista>
Thu, 28 Apr 2011 18:02:42 +0000 (18:02 +0000)
committerjjenista <jjenista>
Thu, 28 Apr 2011 18:02:42 +0000 (18:02 +0000)
Robust/src/Analysis/Disjoint/Effect.java
Robust/src/Analysis/Disjoint/EffectsAnalysis.java
Robust/src/Analysis/Disjoint/ProcessStateMachines.java
Robust/src/Analysis/Pointer/Pointer.java
Robust/src/Benchmarks/oooJava/master-makefile

index baa3cef6884a8cfc7a85b4d9514c17708cd659cb..0565b6f092e18863aa88dd35137252647f21d78b 100644 (file)
@@ -1,7 +1,9 @@
 package Analysis.Disjoint;
 
 package Analysis.Disjoint;
 
-import IR.FieldDescriptor;
-import IR.Flat.TempDescriptor;
+import java.util.*;
+
+import IR.*;
+import IR.Flat.*;
 
 public class Effect {
 
 
 public class Effect {
 
@@ -19,10 +21,70 @@ public class Effect {
   // identify a field
   protected FieldDescriptor field;
 
   // identify a field
   protected FieldDescriptor field;
 
-  public Effect(Alloc affectedAS, int type, FieldDescriptor field) {
+  // for debugging purposes, keep the compilation
+  // unit and line number of this effect--only if state
+  // is non-null later
+  protected int             lineNumber;
+  protected ClassDescriptor compilationUnit;
+  protected static Hashtable<FlatNode, ClassDescriptor> fn2cd =
+    new Hashtable<FlatNode, ClassDescriptor>();
+
+
+  public Effect(Alloc affectedAS, int type, FieldDescriptor field, FlatNode currentProgramPoint) {
     this.affectedAllocSite = affectedAS;
     this.type = type;
     this.field = field;
     this.affectedAllocSite = affectedAS;
     this.type = type;
     this.field = field;
+
+
+    // NOTE: this line number+compilation unit is collected for debugging,
+    // so we don't want to spend time on this unless OOODEBUG or some new
+    // option controls it.  Disjoint and Pointer analysis use this currently.
+    lineNumber      = -1;
+    compilationUnit = null;
+
+    // find the class the current program point belongs to
+    if( currentProgramPoint == null ) {
+      return;
+    }
+    Set<FlatNode> visited = new HashSet<FlatNode>();
+    Set<FlatNode> toVisit = new HashSet<FlatNode>();
+    toVisit.add( currentProgramPoint );
+    
+    while( !toVisit.isEmpty() ) {
+      FlatNode fn = toVisit.iterator().next();
+      toVisit.remove( fn );
+      visited.add( fn );
+
+      // when we find a flat method, remember every node we visited
+      // belongs to that compilation unit
+      if( fn instanceof FlatMethod ) {
+        MethodDescriptor md = ((FlatMethod)fn).getMethod();
+        if( md != null ) {
+          ClassDescriptor cd = md.getClassDesc();
+          if( cd != null ) {
+            fn2cd.put( fn, cd );
+          }
+        }
+      }
+
+      if( fn2cd.containsKey( fn ) ) {
+        compilationUnit = fn2cd.get( fn );
+
+        for( FlatNode fnKnown: visited ) {
+          fn2cd.put( fnKnown, compilationUnit );
+        }
+        
+        lineNumber = currentProgramPoint.getNumLine();
+        break;
+      }
+
+      for( int i = 0; i < fn.numPrev(); ++i ) {
+        FlatNode prev = fn.getPrev( i );
+        if( !visited.contains( prev ) ) {
+          toVisit.add( prev );
+        }
+      }
+    }
   }
 
   public static boolean isWrite(int effect) {
   }
 
   public static boolean isWrite(int effect) {
@@ -115,6 +177,11 @@ public class Effect {
     } else {
       s += ", " + field.toStringBrief();
     }
     } else {
       s += ", " + field.toStringBrief();
     }
+
+    if( compilationUnit != null ) {
+      s += ", "+compilationUnit.getSymbol()+":"+lineNumber;
+    }
+    
     return s + ")";
   }
 
     return s + ")";
   }
 
index fbf21ea6709aa9024bf523b1c218c0a412888ad4..90d2b8e342d2ed42cec4465e0597965a70d615ca 100644 (file)
@@ -136,7 +136,7 @@ public class EffectsAnalysis {
       RefEdge edge          = iterator.next();
       TaintSet taintSet      = edge.getTaints();
       AllocSite affectedAlloc = edge.getDst().getAllocSite();
       RefEdge edge          = iterator.next();
       TaintSet taintSet      = edge.getTaints();
       AllocSite affectedAlloc = edge.getDst().getAllocSite();
-      Effect effect        = new Effect(affectedAlloc, Effect.read, fld);
+      Effect    effect        = new Effect(affectedAlloc, Effect.read, fld, currentProgramPoint);
 
       for (Iterator<Taint> taintSetIter = taintSet.iterator(); taintSetIter.hasNext(); ) {
         Taint taint = taintSetIter.next();
 
       for (Iterator<Taint> taintSetIter = taintSet.iterator(); taintSetIter.hasNext(); ) {
         Taint taint = taintSetIter.next();
@@ -146,10 +146,10 @@ public class EffectsAnalysis {
   }
 
   public void analyzeFlatFieldNode(Set<Edge> sources, FieldDescriptor fld, FlatNode currentProgramPoint) {
   }
 
   public void analyzeFlatFieldNode(Set<Edge> sources, FieldDescriptor fld, FlatNode currentProgramPoint) {
-    for (Edge edge : sources) {
-      TaintSet taintSet      = edge.getTaints();
-      Alloc affectedAlloc = edge.getDst().getAllocSite();
-      Effect effect        = new Effect(affectedAlloc, Effect.read, fld);
+    for (Edge edge:sources) {
+      TaintSet  taintSet      = edge.getTaints();
+      Alloc     affectedAlloc = edge.getDst().getAllocSite();
+      Effect    effect        = new Effect(affectedAlloc, Effect.read, fld, currentProgramPoint);
 
       if (taintSet!=null)
         for (Taint taint : taintSet.getTaints()) {
 
       if (taintSet!=null)
         for (Taint taint : taintSet.getTaints()) {
@@ -169,11 +169,11 @@ public class EffectsAnalysis {
       RefEdge edge          = iterator.next();
       TaintSet taintSet      = edge.getTaints();
       AllocSite affectedAlloc = edge.getDst().getAllocSite();
       RefEdge edge          = iterator.next();
       TaintSet taintSet      = edge.getTaints();
       AllocSite affectedAlloc = edge.getDst().getAllocSite();
-      Effect effect        = new Effect(affectedAlloc, Effect.write, fld);
-      Effect effectSU      = null;
+      Effect    effect        = new Effect(affectedAlloc, Effect.write, fld, currentProgramPoint);
+      Effect    effectSU      = null;
 
       if (strongUpdate) {
 
       if (strongUpdate) {
-        effectSU = new Effect(affectedAlloc, Effect.strongupdate, fld);
+        effectSU = new Effect(affectedAlloc, Effect.strongupdate, fld, currentProgramPoint);
       }
 
       for (Iterator<Taint> taintSetIter = taintSet.iterator(); taintSetIter.hasNext(); ) {
       }
 
       for (Iterator<Taint> taintSetIter = taintSet.iterator(); taintSetIter.hasNext(); ) {
@@ -192,7 +192,7 @@ public class EffectsAnalysis {
     for (Edge edge : dstedges) {
       TaintSet taintSet = edge.getTaints();
       Alloc affectedAlloc = edge.getDst().getAllocSite();
     for (Edge edge : dstedges) {
       TaintSet taintSet = edge.getTaints();
       Alloc affectedAlloc = edge.getDst().getAllocSite();
-      Effect effect = new Effect(affectedAlloc, Effect.write, fld);
+      Effect effect = new Effect(affectedAlloc, Effect.write, fld, currentProgramPoint);
       if (taintSet!=null)
         for (Taint taint : taintSet.getTaints()) {
           add(taint, effect, currentProgramPoint);
       if (taintSet!=null)
         for (Taint taint : taintSet.getTaints()) {
           add(taint, effect, currentProgramPoint);
index 4c0ef14e94a75c5ba11c05486273eb3718bbab0f..0c29cdd184ac4a1e4cb46ca967e8ecbd5b36ff8e 100644 (file)
@@ -324,11 +324,11 @@ public class ProcessStateMachines {
       if( (effectType & Effect.read)  != 0 &&
           (effectType & Effect.write) != 0
           ) {
       if( (effectType & Effect.read)  != 0 &&
           (effectType & Effect.write) != 0
           ) {
-        allocAndFieldRW.add(new Effect(af.getFirst(),
-                                       Effect.read,
-                                       af.getSecond()
-                                       )
-                            );
+        allocAndFieldRW.add( new Effect( af.getFirst(),
+                                         Effect.read,
+                                         af.getSecond(),
+                                         null )
+                             );
       }
     }
 
       }
     }
 
index d5454e64d84276bdd026020a4342d30c77c99cf4..c38ae5a1059b3c3384756cb5f4be3151086041cc 100644 (file)
@@ -216,10 +216,14 @@ nextdelta:
 
     State.logEvent("Done With Pointer Analysis");
 
 
     State.logEvent("Done With Pointer Analysis");
 
-
     if (OoOJava) {
       effectsAnalysis.buildStateMachines.writeStateMachines();
       State.logEvent("Done Writing State Machines");
     if (OoOJava) {
       effectsAnalysis.buildStateMachines.writeStateMachines();
       State.logEvent("Done Writing State Machines");
+
+      if( state.OOODEBUG ) {
+        effectsAnalysis.writeEffects("effects.txt");
+        State.logEvent("Done Writing Effects");
+      }
     }
   }
 
     }
   }
 
index a9c6aa23722c853074fbcc879216b5a99f867c24..456c855e041253ce3e1db73cc7351459a3b55f03 100644 (file)
@@ -33,7 +33,7 @@ USECOREPROF= #-coreprof $(COREPROFOVERFLOW) \
 
 
 USEOOO= -ooojava $(NUM_OOO_WORKERS) 2 -squeue #-ooodebug-disable-task-mem-pool
 
 
 USEOOO= -ooojava $(NUM_OOO_WORKERS) 2 -squeue #-ooodebug-disable-task-mem-pool
-USERCR= -ooojava $(NUM_RCR_WORKERS) 2 -rcr -squeue 
+USERCR= -ooojava $(NUM_RCR_WORKERS) 2 -rcr -squeue -ooodebug
 OOODEBUG= -ooodebug -printlinenum
 RCRDEBUG= -rcr_debug -printlinenum
 RCRDEBUGV= -rcr_debug_verbose -printlinenum
 OOODEBUG= -ooodebug -printlinenum
 RCRDEBUG= -rcr_debug -printlinenum
 RCRDEBUGV= -rcr_debug_verbose -printlinenum