get partially set up new version of disjoint analysis with OoOJava analysis checked...
authorjjenista <jjenista>
Thu, 17 Jun 2010 21:15:23 +0000 (21:15 +0000)
committerjjenista <jjenista>
Thu, 17 Jun 2010 21:15:23 +0000 (21:15 +0000)
Robust/src/Analysis/Disjoint/EffectsAnalysis.java [new file with mode: 0644]
Robust/src/Analysis/Disjoint/ReachGraph.java
Robust/src/Analysis/Disjoint/Taint.java [new file with mode: 0644]
Robust/src/Analysis/Disjoint/TaintSet.java [new file with mode: 0644]
Robust/src/Analysis/OoOJava/OoOJavaAnalysis.java [new file with mode: 0644]
Robust/src/IR/State.java
Robust/src/Main/Main.java
Robust/src/Makefile

diff --git a/Robust/src/Analysis/Disjoint/EffectsAnalysis.java b/Robust/src/Analysis/Disjoint/EffectsAnalysis.java
new file mode 100644 (file)
index 0000000..eaef2a7
--- /dev/null
@@ -0,0 +1,167 @@
+package Analysis.Disjoint;
+
+import java.io.BufferedWriter;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Set;
+
+import IR.FieldDescriptor;
+import IR.MethodDescriptor;
+import IR.TypeDescriptor;
+import IR.Flat.FlatCall;
+import IR.Flat.FlatSetElementNode;
+import IR.Flat.TempDescriptor;
+
+/////////////////////////////////////////////
+// 
+//  Effects analysis computes read/write/strong
+//  update and other sorts of effects for the
+//  scope of a method or rblock.  The effects
+//  are associated with the heap roots through
+//  which a reference to the effect target was
+//  obtained.
+//
+//  The effects analysis piggy-backs
+//  on the disjoint reachability analysis,
+//  if requested, to support OoOJava and
+//  potentially other analysis clients.
+//
+/////////////////////////////////////////////
+
+public class EffectsAnalysis {
+
+  //private Hashtable<MethodContext, MethodEffects> mapMethodContextToMethodEffects;
+  //   boolean methodeffects = false;
+
+  public EffectsAnalysis( boolean methodeffects ) {
+    //this.methodeffects = methodeffects;
+    //mapMethodContextToMethodEffects = new Hashtable<MethodContext, MethodEffects>();
+  }
+
+  /*
+  public MethodEffects getMethodEffectsByMethodContext(MethodContext mc){
+               return mapMethodContextToMethodEffects.get(mc);
+       }
+
+       public void createNewMapping(MethodContext mcNew) {
+               if(!methodeffects) return;
+               if (!mapMethodContextToMethodEffects.containsKey(mcNew)) {
+                       MethodEffects meNew = new MethodEffects();
+                       mapMethodContextToMethodEffects.put(mcNew, meNew);
+               }
+       }
+  */
+
+  /*
+       public void analyzeFlatCall(OwnershipGraph calleeOG,
+                       MethodContext calleeMC, MethodContext callerMC, FlatCall fc) {
+               if(!methodeffects) return;
+               MethodEffects me = mapMethodContextToMethodEffects.get(callerMC);
+               MethodEffects meFlatCall = mapMethodContextToMethodEffects
+                               .get(calleeMC);
+               me.analyzeFlatCall(calleeOG, fc, callerMC, meFlatCall);
+               mapMethodContextToMethodEffects.put(callerMC, me);
+       }
+  */
+
+  /*
+       public void analyzeFlatFieldNode(MethodContext mc, OwnershipGraph og,
+                       TempDescriptor srcDesc, FieldDescriptor fieldDesc) {
+               if(!methodeffects) return;
+               MethodEffects me = mapMethodContextToMethodEffects.get(mc);
+               me.analyzeFlatFieldNode(og, srcDesc, fieldDesc);
+               mapMethodContextToMethodEffects.put(mc, me);
+       }
+
+       public void analyzeFlatSetFieldNode(MethodContext mc, OwnershipGraph og,
+                       TempDescriptor dstDesc, FieldDescriptor fieldDesc) {
+               if(!methodeffects) return;
+               MethodEffects me = mapMethodContextToMethodEffects.get(mc);
+               me.analyzeFlatSetFieldNode(og, dstDesc, fieldDesc);
+               mapMethodContextToMethodEffects.put(mc, me);
+       }
+       
+       public void analyzeFlatSetElementNode(MethodContext mc, OwnershipGraph og,
+                       TempDescriptor dstDesc, FieldDescriptor fieldDesc) {
+               if(!methodeffects) return;
+               MethodEffects me = mapMethodContextToMethodEffects.get(mc);
+               me.analyzeFlatSetElementNode(og, dstDesc, fieldDesc);
+               mapMethodContextToMethodEffects.put(mc, me);
+       }
+       
+       public void analyzeFlatElementNode(MethodContext mc, OwnershipGraph og,
+                       TempDescriptor dstDesc, FieldDescriptor fieldDesc) {
+               if(!methodeffects) return;
+               MethodEffects me = mapMethodContextToMethodEffects.get(mc);
+               me.analyzeFlatElementNode(og, dstDesc, fieldDesc);
+               mapMethodContextToMethodEffects.put(mc, me);
+       }
+       
+
+       public void writeMethodEffectsResult() throws IOException {
+
+               try {
+                       BufferedWriter bw = new BufferedWriter(new FileWriter(
+                                       "MethodEffects_report.txt"));
+
+                       Set<MethodContext> mcSet = mapMethodContextToMethodEffects.keySet();
+                       Iterator<MethodContext> mcIter = mcSet.iterator();
+                       while (mcIter.hasNext()) {
+                               MethodContext mc = mcIter.next();
+                               MethodDescriptor md = (MethodDescriptor) mc.getDescriptor();
+
+                               int startIdx = 0;
+                               if (!md.isStatic()) {
+                                       startIdx = 1;
+                               }
+
+                               MethodEffects me = mapMethodContextToMethodEffects.get(mc);
+                               EffectsSet effectsSet = me.getEffects();
+
+                               bw.write("Method " + mc + " :\n");
+                               for (int i = startIdx; i < md.numParameters() + startIdx; i++) {
+
+                                       String paramName = md.getParamName(i - startIdx);
+
+                                       Set<EffectsKey> effectSet = effectsSet.getReadingSet(i);
+                                       String keyStr = "{";
+                                       if (effectSet != null) {
+                                               Iterator<EffectsKey> effectIter = effectSet.iterator();
+                                               while (effectIter.hasNext()) {
+                                                       EffectsKey key = effectIter.next();
+                                                       keyStr += " " + key;
+                                               }
+                                       }
+                                       keyStr += " }";
+                                       bw.write("  Paramter " + paramName + " ReadingSet="
+                                                       + keyStr + "\n");
+
+                                       effectSet = effectsSet.getWritingSet(new Integer(i));
+                                       keyStr = "{";
+                                       if (effectSet != null) {
+                                               Iterator<EffectsKey> effectIter = effectSet.iterator();
+                                               while (effectIter.hasNext()) {
+                                                       EffectsKey key = effectIter.next();
+                                                       keyStr += " " + key;
+                                               }
+                                       }
+
+                                       keyStr += " }";
+                                       bw.write("  Paramter " + paramName + " WritingngSet="
+                                                       + keyStr + "\n");
+
+                               }
+                               bw.write("\n");
+
+                       }
+
+                       bw.close();
+               } catch (IOException e) {
+                       System.err.println(e);
+               }
+
+       }
+  */
+}
index f8c62b2baae46316ea26300034aa1d6b387f621e..46afd6f4d682629c94e01e10a35467765236249e 100644 (file)
@@ -1652,11 +1652,12 @@ public class ReachGraph {
       ExistPredSet preds = 
         ExistPredSet.factory( pred );
       
-      Taint paramTaint = 
-        Taint.factory( index, paramCallee.toString() );
+      //Taint paramTaint = 
+      //  Taint.factory( 0, null, null,  );
 
       TaintSet paramTaints =
-        TaintSet.factory( paramTaint );
+        //TaintSet.factory( paramTaint );
+        TaintSet.factory();
 
       RefEdge reCallee = 
         new RefEdge( vnCallee,
diff --git a/Robust/src/Analysis/Disjoint/Taint.java b/Robust/src/Analysis/Disjoint/Taint.java
new file mode 100644 (file)
index 0000000..067c9e1
--- /dev/null
@@ -0,0 +1,147 @@
+package Analysis.Disjoint;
+
+import IR.*;
+import IR.Flat.*;
+import java.util.*;
+import java.io.*;
+
+///////////////////////////////////////////
+//  IMPORTANT
+//  This class is an immutable Canonical, so
+//
+//  0) construct them with a factory pattern
+//  to ensure only canonical versions escape
+//
+//  1) any operation that modifies a Canonical
+//  is a static method in the Canonical class
+//
+//  2) operations that just read this object
+//  should be defined here
+//
+//  3) every Canonical subclass hashCode should
+//  throw an error if the hash ever changes
+//
+///////////////////////////////////////////
+
+// a taint is applied to a reference edge, and
+// is used to associate an effect with a heap root
+
+public class Taint extends Canonical {
+
+  // taints can either be associated with
+  // parameters or seses (rblocks),
+  // only one set of identifying objects
+  // will be non-null
+
+  // identify a parameter index
+  protected Integer paramIndex;
+  
+  // identify an sese (rblock) + inset var
+  protected FlatSESEEnterNode sese;
+  protected TempDescriptor    insetVar;
+
+  // either type of taint also includes
+  // an allocation site
+  protected AllocSite allocSite;
+
+
+  public static Taint factory( Integer           pi,
+                               FlatSESEEnterNode s,
+                               TempDescriptor    iv,
+                               AllocSite         as ) {
+    Taint out = new Taint( pi, s, iv, as );
+    out = (Taint) Canonical.makeCanonical( out );
+    return out;
+  }
+
+  protected Taint( Integer           pi,
+                   FlatSESEEnterNode s,
+                   TempDescriptor    iv,
+                   AllocSite         as ) {    
+    assert 
+      (pi != null && s == null && iv == null) ||
+      (pi == null && s != null && iv != null);
+
+    assert as != null;
+
+    paramIndex = pi;
+    sese       = s;
+    insetVar   = iv;
+    allocSite  = as;
+  }
+
+  public Integer getParamIndex() {
+    return paramIndex;
+  }
+
+  public FlatSESEEnterNode getSESE() {
+    return sese;
+  }
+
+  public TempDescriptor getInSetVar() {
+    return insetVar;
+  }
+
+  public AllocSite getAllocSite() {
+    return allocSite;
+  }
+
+
+  public boolean equalsSpecific( Object o ) {
+    if( o == null ) {
+      return false;
+    }
+
+    if( !(o instanceof Taint) ) {
+      return false;
+    }
+
+    Taint t = (Taint) o;
+
+    boolean piMatches = true;
+    if( paramIndex == null ) {
+      piMatches = t.paramIndex == null;
+    } else {
+      piMatches = paramIndex.equals( t.paramIndex );
+    }
+
+    boolean sMatches = true;
+    if( sese == null ) {
+      sMatches = t.sese == null;
+    } else {
+      sMatches = sese.equals( t.sese );
+    }
+
+    boolean ivMatches = true;
+    if( insetVar == null ) {
+      ivMatches = t.insetVar == null;
+    } else {
+      ivMatches = insetVar.equals( t.insetVar );
+    }
+
+    return allocSite.equals( t.allocSite ) &&
+      piMatches && sMatches && ivMatches;
+  }
+
+  public int hashCodeSpecific() {
+    int hash = allocSite.hashCode();
+
+    if( paramIndex != null ) {
+      hash = hash ^ paramIndex.hashCode();
+    }
+
+    if( sese != null ) {
+      hash = hash ^ sese.hashCode();
+    }
+
+    if( insetVar != null ) {
+      hash = hash ^ insetVar.hashCode();
+    }
+
+    return hash;
+  }
+
+  public String toString() {
+    return "";
+  }
+}
diff --git a/Robust/src/Analysis/Disjoint/TaintSet.java b/Robust/src/Analysis/Disjoint/TaintSet.java
new file mode 100644 (file)
index 0000000..1b7b4be
--- /dev/null
@@ -0,0 +1,87 @@
+package Analysis.Disjoint;
+
+import IR.*;
+import IR.Flat.*;
+import java.util.*;
+import java.io.*;
+
+///////////////////////////////////////////
+//  IMPORTANT
+//  This class is an immutable Canonical, so
+//
+//  0) construct them with a factory pattern
+//  to ensure only canonical versions escape
+//
+//  1) any operation that modifies a Canonical
+//  is a static method in the Canonical class
+//
+//  2) operations that just read this object
+//  should be defined here
+//
+//  3) every Canonical subclass hashCode should
+//  throw an error if the hash ever changes
+//
+///////////////////////////////////////////
+
+// a taint set is simply the union of possible
+// taints for an abstract reference edge--in a
+// concrete heap each reference would have
+// exactly one taint
+
+public class TaintSet extends Canonical {
+
+  protected HashSet<Taint> taints;
+
+  public static TaintSet factory() {
+    TaintSet out = new TaintSet();
+    out = (TaintSet) Canonical.makeCanonical( out );
+    return out;
+  }
+
+  public static TaintSet factory( Taint t ) {
+    assert t != null;
+    assert t.isCanonical();
+    TaintSet out = new TaintSet();    
+    out.taints.add( t );
+    out = (TaintSet) Canonical.makeCanonical( out );
+    return out;
+  }
+
+  protected TaintSet() {
+    taints = new HashSet<Taint>();
+  }
+
+  public Iterator iterator() {
+    return taints.iterator();
+  }
+
+  public boolean isEmpty() {
+    return taints.isEmpty();
+  }
+
+  public boolean containsTaint( Taint t ) {
+    assert t != null;
+    return taints.contains( t );
+  }
+
+  public boolean equalsSpecific( Object o ) {
+    if( o == null ) {
+      return false;
+    }
+
+    if( !(o instanceof TaintSet) ) {
+      return false;
+    }
+
+    TaintSet ts = (TaintSet) o;
+    return taints.equals( ts.taints );
+  }
+  
+  public int hashCodeSpecific() {
+    return taints.hashCode();
+  }
+  
+  public String toString() {
+    return taints.toString();
+  }
+}
diff --git a/Robust/src/Analysis/OoOJava/OoOJavaAnalysis.java b/Robust/src/Analysis/OoOJava/OoOJavaAnalysis.java
new file mode 100644 (file)
index 0000000..95941e6
--- /dev/null
@@ -0,0 +1,61 @@
+package Analysis.OoOJava;
+
+import java.io.BufferedWriter;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.StringWriter;
+import java.util.Enumeration;
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.Map;
+import java.util.Set;
+import java.util.Stack;
+import java.util.Map.Entry;
+import Analysis.Liveness;
+import Analysis.ArrayReferencees;
+import Analysis.CallGraph.CallGraph;
+import IR.Descriptor;
+import IR.FieldDescriptor;
+import IR.MethodDescriptor;
+import IR.Operation;
+import IR.State;
+import IR.TypeDescriptor;
+import IR.TypeUtil;
+import IR.Flat.FKind;
+import IR.Flat.FlatCall;
+import IR.Flat.FlatCondBranch;
+import IR.Flat.FlatEdge;
+import IR.Flat.FlatElementNode;
+import IR.Flat.FlatFieldNode;
+import IR.Flat.FlatMethod;
+import IR.Flat.FlatNew;
+import IR.Flat.FlatNode;
+import IR.Flat.FlatOpNode;
+import IR.Flat.FlatReturnNode;
+import IR.Flat.FlatSESEEnterNode;
+import IR.Flat.FlatSESEExitNode;
+import IR.Flat.FlatSetElementNode;
+import IR.Flat.FlatSetFieldNode;
+import IR.Flat.FlatWriteDynamicVarNode;
+import IR.Flat.TempDescriptor;
+
+
+public class OoOJavaAnalysis {
+
+  // data from the compiler
+  private State             state;
+  private TypeUtil          typeUtil;
+  private CallGraph         callGraph;
+
+
+
+  public OoOJavaAnalysis( State            state,
+                          TypeUtil         tu,
+                          CallGraph        callGraph,
+                          Liveness         liveness,
+                          ArrayReferencees arrayReferencees
+                          ) {
+  }
+}
index c29b0aa87cf3d89e93a3f3491d90c6273c6f4d60..ce99bd955e590aa9ce630bf4cf681914f4f93910 100644 (file)
@@ -100,6 +100,8 @@ public class State {
 
   public boolean DISJOINTDEBUGSCHEDULING=false;
 
+  public boolean OOOJAVA=false;
+
 
   public boolean OPTIONAL=false;
   public boolean ARRAYPAD=false;
index 04fb75407b7bf94349257c164d8cce066b0d66e9..51ebbeb670fad504c8e19f893d4cc9e0ba22f1e8 100644 (file)
@@ -41,8 +41,9 @@ import Analysis.Locality.GenerateConversions;
 import Analysis.Prefetch.PrefetchAnalysis;
 import Analysis.FlatIRGraph.FlatIRGraph;
 import Analysis.OwnershipAnalysis.OwnershipAnalysis;
-//import Analysis.Disjoint.DisjointAnalysis;
 import Analysis.MLP.MLPAnalysis;
+import Analysis.Disjoint.DisjointAnalysis;
+import Analysis.OoOJava.OoOJavaAnalysis;
 import Analysis.Loops.*;
 import Analysis.Liveness;
 import Analysis.ArrayReferencees;
@@ -319,6 +320,11 @@ public class Main {
 
       } else if (option.equals("-methodeffects")) {
        state.METHODEFFECTS=true;
+
+      } else if (option.equals("-ooojava")) {
+       state.OOOJAVA  = true;
+       state.DISJOINT = true;
+
       }else if (option.equals("-help")) {
        System.out.println("-classlibrary classlibrarydirectory -- directory where classlibrary is located");
        System.out.println("-selfloop task -- this task doesn't self loop its parameters forever");
@@ -495,12 +501,20 @@ public class Main {
                              oa);
     }    
 
-    /*    if (state.DISJOINT) {
+    if (state.DISJOINT && !state.OOOJAVA) {
       CallGraph        cg = new CallGraph(state);
       Liveness         l  = new Liveness();
       ArrayReferencees ar = new ArrayReferencees(state);
-      DisjointAnalysis oa = new DisjointAnalysis(state, tu, cg, l, ar);
-      }*/
+      DisjointAnalysis da = new DisjointAnalysis(state, tu, cg, l, ar);
+    }
+
+    if (state.OOOJAVA) {
+      CallGraph        cg = new CallGraph(state);
+      Liveness         l  = new Liveness();
+      ArrayReferencees ar = new ArrayReferencees(state);
+      OoOJavaAnalysis  oa = new OoOJavaAnalysis(state, tu, cg, l, ar);
+    }
+
 
     if (state.TAGSTATE) {
       CallGraph callgraph=new CallGraph(state);
index e5185d397f65f779c3dadc2836bff1b179a0fd3a..d3fbb1b7683687b6e470e2401ca9bc6bca895d68 100644 (file)
@@ -97,6 +97,7 @@ Analysis/MLP/VSTWrapper.class                                         \
 Analysis/MLP/SVKey.class                                               \
 Analysis/MLP/VarSrcTokTable.class                                      \
 Analysis/MLP/CodePlan.class                                            \
+Analysis/OoOJava/OoOJavaAnalysis.class                                 \
 Util/GraphNode.class Util/Namer.class Util/Relation.class              \
 Util/UtilAlgorithms.class                                               \
 Interface/HTTPHeader.class Interface/HTTPResponse.class                        \