Some initial implementation of reachability for ownership analysis.
authorjjenista <jjenista>
Tue, 24 Jun 2008 18:51:27 +0000 (18:51 +0000)
committerjjenista <jjenista>
Tue, 24 Jun 2008 18:51:27 +0000 (18:51 +0000)
Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java
Robust/src/Analysis/OwnershipAnalysis/ReachabilitySet.java [new file with mode: 0644]
Robust/src/Analysis/OwnershipAnalysis/TokenTuple.java [new file with mode: 0644]
Robust/src/Analysis/OwnershipAnalysis/TokenTupleSet.java [new file with mode: 0644]
Robust/src/Makefile

index e5061e12cc51f93660211997fc5b1393b3f734c3..e58dff7fabaea1ad09a1fdaa027205a7e8bd6784 100644 (file)
@@ -24,6 +24,10 @@ public class OwnershipGraph {
 
     public HashSet<AllocationSite> allocationSites;
 
+    // CHANGE!  Map HRN ID's to token sets (sets of IDs!)
+    public Hashtable< HeapRegionNode,     HashSet< HashSet<HeapRegionNode> > > alpha;
+  //public Hashtable< touple< HRN, HRN >, HashSet< HashSet<HeapRegionNode> > > beta;
+
 
     public OwnershipGraph( int allocationDepth ) {
        this.allocationDepth = allocationDepth;
@@ -34,6 +38,8 @@ public class OwnershipGraph {
        paramIndex2id = new Hashtable<Integer,        Integer       >();
 
        allocationSites = new HashSet <AllocationSite>();
+
+       alpha = new Hashtable< HeapRegionNode,     HashSet< HashSet<HeapRegionNode> > >();
     }
 
 
@@ -644,6 +650,7 @@ public class OwnershipGraph {
        mergeReferenceEdges ( og );
        mergeId2paramIndex  ( og );
        mergeAllocationSites( og );
+       mergeTokenSets      ( og );
     }
 
     protected void mergeOwnershipNodes( OwnershipGraph og ) {
@@ -811,6 +818,39 @@ public class OwnershipGraph {
     }
 
 
+    
+    protected void mergeTokenSets( OwnershipGraph og ) {
+       //      alpha = new Hashtable< HeapRegionNode,     HashSet< HashSet<HeapRegionNode> > >();
+
+       // if a key is in one or the other token set,
+       // add it to the merged token set.
+       // if a key is in both graphs, the merged
+       // token set should have that key and the union
+       // of values as the merged value.
+
+       /*
+       Set      alphaB = og.alpha.entrySet();
+       Iterator iB     = alphaB.iterator();
+       while( iB.hasNext() ) {
+           Map.Entry      meB     = (Map.Entry) iB.next();
+           HeapRegionNode hrnKeyB = (HeapRegionNode) meB.getKey();
+           HashSet< HashSet<HeapRegionNode> > > tokenSetsB = 
+               (HashSet< HashSet<HeapRegionNode> > >) meB.getValue();
+
+           if( !alpha.containsKey( hrnKeyB ) ) {
+               alpha.put( hrnKeyB, tokenSetsB );
+           } else {
+               
+           }
+       }
+       */
+    }
+
+
+
+
+
+
     // it is necessary in the equals() member functions
     // to "check both ways" when comparing the data
     // structures of two graphs.  For instance, if all
diff --git a/Robust/src/Analysis/OwnershipAnalysis/ReachabilitySet.java b/Robust/src/Analysis/OwnershipAnalysis/ReachabilitySet.java
new file mode 100644 (file)
index 0000000..46c4c8f
--- /dev/null
@@ -0,0 +1,15 @@
+package Analysis.OwnershipAnalysis;
+
+import IR.*;
+import IR.Flat.*;
+import java.util.*;
+import java.io.*;
+
+
+public class ReachabilitySet {
+
+    public HashSet<TokenTupleSet> possibleReachabilities;
+
+    
+
+}
\ No newline at end of file
diff --git a/Robust/src/Analysis/OwnershipAnalysis/TokenTuple.java b/Robust/src/Analysis/OwnershipAnalysis/TokenTuple.java
new file mode 100644 (file)
index 0000000..2185f27
--- /dev/null
@@ -0,0 +1,54 @@
+package Analysis.OwnershipAnalysis;
+
+import IR.*;
+import IR.Flat.*;
+import java.util.*;
+import java.io.*;
+
+
+// a token touple is a pair that indicates a
+// heap region node and an arity
+public class TokenTuple
+{
+    private Integer token;
+    private boolean isNewSummary;
+
+    // only summary tokens should have ARITY_MANY?
+    public static final int ARITY_ONE  = 1;
+    public static final int ARITY_MANY = 2;
+    private int arity;
+
+    public TokenTuple( HeapRegionNode hrn ) {
+       token        = hrn.getID();
+       isNewSummary = hrn.isNewSummary();
+       arity        = ARITY_ONE;
+    }
+
+    public TokenTuple( Integer token,
+                      boolean isNewSummary,
+                      int     arity ) {
+       this.token        = token;
+       this.isNewSummary = isNewSummary;
+       this.arity        = arity;
+    }
+
+    public Integer getToken() { return token; }
+    public int     getArity() {        return arity; }
+
+    public void increaseArity() {
+       if( isNewSummary ) {
+           arity = ARITY_MANY;
+       }
+    }
+
+    public boolean equals( TokenTuple tt ) {
+       return token.equals( tt.getToken() ) &&
+              arity ==      tt.getArity();
+    }
+
+    public TokenTuple copy() {
+       return new TokenTuple( token,
+                              isNewSummary,
+                              arity );
+    }
+}
diff --git a/Robust/src/Analysis/OwnershipAnalysis/TokenTupleSet.java b/Robust/src/Analysis/OwnershipAnalysis/TokenTupleSet.java
new file mode 100644 (file)
index 0000000..e07b615
--- /dev/null
@@ -0,0 +1,31 @@
+package Analysis.OwnershipAnalysis;
+
+import IR.*;
+import IR.Flat.*;
+import java.util.*;
+import java.io.*;
+
+
+public class TokenTupleSet {
+
+    public HashSet<TokenTuple> tokenTuples;
+
+    public TokenTupleSet() {
+       tokenTuples = new HashSet<TokenTuple>();
+    }
+
+    public TokenTupleSet( TokenTuple tt ) {
+       this();
+       tokenTuples.add( tt );
+    }
+
+    public TokenTupleSet( TokenTupleSet tts ) {
+       tokenTuples = (HashSet<TokenTuple>) tts.tokenTuples.clone(); //COPY?!
+    }
+
+    public TokenTupleSet union( TokenTupleSet ttsIn ) {
+       TokenTupleSet ttsOut = new TokenTupleSet( this );
+       ttsOut.tokenTuples.addAll( ttsIn.tokenTuples );
+       return ttsOut;
+    }
+}
index 3aeaeddd8f4319170b6385e938a3b356682d6453..6efe1c0fafea1547085812c7763ef89cb360fcf6 100644 (file)
@@ -80,6 +80,9 @@ Analysis/OwnershipAnalysis/LabelNode.class                              \
 Analysis/OwnershipAnalysis/HeapRegionNode.class                         \
 Analysis/OwnershipAnalysis/ReferenceEdgeProperties.class                \
 Analysis/OwnershipAnalysis/AllocationSite.class                         \
+Analysis/OwnershipAnalysis/TokenTuple.class                             \
+Analysis/OwnershipAnalysis/TokenTupleSet.class                          \
+Analysis/OwnershipAnalysis/ReachabilitySet.class                        \
 Util/GraphNode.class Util/Namer.class Util/Relation.class              \
 Interface/HTTPHeader.class Interface/HTTPResponse.class                        \
 Interface/HTTPServices.class Interface/HashStrings.class               \