bug fixes for task initial heaps and making all new edges have true predicates attach...
authorjjenista <jjenista>
Thu, 25 Mar 2010 20:14:08 +0000 (20:14 +0000)
committerjjenista <jjenista>
Thu, 25 Mar 2010 20:14:08 +0000 (20:14 +0000)
Robust/src/Analysis/Disjoint/Canonical.java
Robust/src/Analysis/Disjoint/CanonicalOp.java
Robust/src/Analysis/Disjoint/DisjointAnalysis.java
Robust/src/Analysis/Disjoint/ReachGraph.java
Robust/src/Analysis/Disjoint/ReachState.java

index 7f380b58a95864845578e3135ef923e6677bf829..bd4b8ee15429a130e738e521375baaf74afb1317 100644 (file)
@@ -1278,4 +1278,68 @@ abstract public class Canonical {
     return out;
   }
 
+
+
+  public static ReachState makePredsTrue( ReachState rs ) {
+    assert rs != null;
+    assert rs.isCanonical();
+
+    // ops require two canonicals, in this case always supply
+    // the empty reach state as the second, it's never used,
+    // but makes the hashing happy
+    CanonicalOp op = 
+      new CanonicalOp( CanonicalOp.REACHSTATE_MAKEPREDSTRUE,
+                       rs, 
+                       ReachState.factory() );
+    
+    Canonical result = op2result.get( op );
+    if( result != null ) {
+      return (ReachState) result;
+    }
+    
+    // otherwise, no cached result...
+    ReachState out = new ReachState();
+
+    // just remake state with the true predicate attached
+    out.reachTuples.addAll( rs.reachTuples );
+    out.preds = ExistPredSet.factory( ExistPred.factory() );
+    
+    out = (ReachState) makeCanonical( out );
+    op2result.put( op, out );
+    return out;
+  }
+
+
+  public static ReachSet makePredsTrue( ReachSet rs ) {
+    assert rs != null;
+    assert rs.isCanonical();
+
+    // ops require two canonicals, in this case always supply
+    // the empty reach set as the second, it's never used,
+    // but makes the hashing happy
+    CanonicalOp op = 
+      new CanonicalOp( CanonicalOp.REACHSET_MAKEPREDSTRUE,
+                       rs,
+                       ReachSet.factory() );
+    
+    Canonical result = op2result.get( op );
+    if( result != null ) {
+      return (ReachSet) result;
+    }
+    
+    // otherwise, no cached result...
+    ReachSet out = ReachSet.factory();
+    Iterator<ReachState> itr = rs.iterator();
+    while( itr.hasNext() ) {
+      ReachState state = itr.next();
+      out = Canonical.add( out,
+                           Canonical.makePredsTrue( state )
+                           );
+    }
+    
+    out = (ReachSet) makeCanonical( out );
+    op2result.put( op, out );
+    return out;
+  }
+
 }
index 73caa309e76940bfcdc705a7ccbd8e42aa9a709c..59b72f0d720231aa695dd5dc082ee0f452924901 100644 (file)
@@ -32,6 +32,9 @@ public class CanonicalOp {
   public static final int REACHSTATE_TOCALLERCONTEXT_ALLOCSITE = 0xb2b1;
   public static final int REACHSET_UNSHADOW_ALLOCSITE          = 0x1049;
   public static final int REACHSTATE_UNSHADOW_ALLOCSITE        = 0x08ef;
+  public static final int REACHSTATE_MAKEPREDSTRUE             = 0x0b9c;
+  public static final int REACHSET_MAKEPREDSTRUE               = 0xdead;
+
 
   protected int opCode;
   protected Canonical operand1;
index 8b9463783e96d9c52ff25351955ace3db01dca03..021446d5bef5c29f2a09a813ab3724a5653b8711 100644 (file)
@@ -1094,8 +1094,8 @@ public class DisjointAnalysis {
                 
         rg.writeGraph( "IHMPARTFOR"+d+"FROM"+fc,
                        true,   // write labels (variables)
-                       false,  // selectively hide intermediate temp vars
-                       false,  // prune unreachable heap regions
+                       true,   // selectively hide intermediate temp vars
+                       true,   // prune unreachable heap regions
                        false,  // hide subset reachability states
                        true ); // hide edge taints
       }
@@ -1124,7 +1124,7 @@ public class DisjointAnalysis {
       rg.writeGraph( d+"COMPLETE"+String.format( "%05d", n ),
                      true,   // write labels (variables)
                      true,   // selectively hide intermediate temp vars
-                     false,  // prune unreachable heap regions
+                     true,   // prune unreachable heap regions
                      false,  // hide subset reachability states
                      true ); // hide edge taints
       
@@ -1590,7 +1590,7 @@ private Set<FieldDescriptor> getFieldSetTobeAnalyzed(TypeDescriptor typeDesc){
        
 }
 
-private HeapRegionNode createMultiDeimensionalArrayHRN(ReachGraph rg, AllocSite alloc, HeapRegionNode srcHRN, FieldDescriptor fd, Hashtable<HeapRegionNode, HeapRegionNode> map, Hashtable<TypeDescriptor, HeapRegionNode> mapToExistingNode ){
+  private HeapRegionNode createMultiDeimensionalArrayHRN(ReachGraph rg, AllocSite alloc, HeapRegionNode srcHRN, FieldDescriptor fd, Hashtable<HeapRegionNode, HeapRegionNode> map, Hashtable<TypeDescriptor, HeapRegionNode> mapToExistingNode, ReachSet alpha ){
 
        int dimCount=fd.getType().getArrayCount();
        HeapRegionNode prevNode=null;
@@ -1617,8 +1617,8 @@ private HeapRegionNode createMultiDeimensionalArrayHRN(ReachGraph rg, AllocSite
                                                           as.getType(), // type
                                                           as, // allocation site
                                                           null, // inherent reach
-                                                          null, // current reach
-                                                          ExistPredSet.factory(), // predicates
+                                                          alpha, // current reach
+                                                          ExistPredSet.factory(rg.predTrue), // predicates
                                                           tempDesc.toString() // description
                                                           );
                    rg.id2hrn.put(as.getSummary(),hrnSummary);
@@ -1634,7 +1634,7 @@ private HeapRegionNode createMultiDeimensionalArrayHRN(ReachGraph rg, AllocSite
                                                        hrnSummary, // dest
                                                        typeDesc, // type
                                                        fd.getSymbol(), // field name
-                                                       srcHRN.getAlpha(), // beta
+                                                       alpha, // beta
                                                        ExistPredSet.factory(rg.predTrue) // predicates
                                                        );
                    
@@ -1647,7 +1647,7 @@ private HeapRegionNode createMultiDeimensionalArrayHRN(ReachGraph rg, AllocSite
                                                        hrnSummary, // dest
                                                        typeDesc, // type
                                                        arrayElementFieldName, // field name
-                                                       srcHRN.getAlpha(), // beta
+                                                       alpha, // beta
                                                        ExistPredSet.factory(rg.predTrue) // predicates
                                                        );
                    
@@ -1675,8 +1675,8 @@ private HeapRegionNode createMultiDeimensionalArrayHRN(ReachGraph rg, AllocSite
                                                           typeDesc, // type
                                                           as, // allocation site
                                                           null, // inherent reach
-                                                          null, // current reach
-                                                          ExistPredSet.factory(), // predicates
+                                                          alpha, // current reach
+                                                          ExistPredSet.factory(rg.predTrue), // predicates
                                                           tempDesc.toString() // description
                                                           );
                    rg.id2hrn.put(as.getSummary(),hrnSummary);
@@ -1685,7 +1685,7 @@ private HeapRegionNode createMultiDeimensionalArrayHRN(ReachGraph rg, AllocSite
                                        hrnSummary, // dest
                                        typeDesc, // type
                                        arrayElementFieldName, // field name
-                                       null, // beta
+                                        alpha, // beta
                                        ExistPredSet.factory(rg.predTrue) // predicates
                                        );
                    rg.addRefEdge(prevNode, hrnSummary, edgeToSummary);
@@ -1697,7 +1697,7 @@ private HeapRegionNode createMultiDeimensionalArrayHRN(ReachGraph rg, AllocSite
                                        hrnSummary, // dest
                                        typeDesc, // type
                                        arrayElementFieldName, // field name
-                                       null, // beta
+                                       alpha, // beta
                                        ExistPredSet.factory(rg.predTrue) // predicates
                                        );
                    rg.addRefEdge(prevNode, hrnSummary, edgeToSummary);
@@ -1787,7 +1787,7 @@ private ReachGraph createInitialTaskReachGraph(FlatMethod fm) {
                    
                    HeapRegionNode      hrnSummary;
                    if(allocType.isArray() && allocType.getArrayCount()>0){
-                       hrnSummary=createMultiDeimensionalArrayHRN(rg,allocSite,srcHRN,fd,mapToFirstDimensionArrayNode,mapTypeToExistingSummaryNode);
+                      hrnSummary=createMultiDeimensionalArrayHRN(rg,allocSite,srcHRN,fd,mapToFirstDimensionArrayNode,mapTypeToExistingSummaryNode,hrnNewest.getAlpha());
                    }else{                  
                        hrnSummary = 
                                        rg.createNewHeapRegionNode(allocSite.getSummary(), // id or null to generate a new one
@@ -1798,8 +1798,8 @@ private ReachGraph createInitialTaskReachGraph(FlatMethod fm) {
                                                                   allocSite.getType(), // type
                                                                   allocSite, // allocation site
                                                                   null, // inherent reach
-                                                                  srcHRN.getAlpha(), // current reach
-                                                                  ExistPredSet.factory(), // predicates
+                                                                  hrnNewest.getAlpha(), // current reach
+                                                                  ExistPredSet.factory(rg.predTrue), // predicates
                                                                   strDesc // description
                                                                   );
                                    rg.id2hrn.put(allocSite.getSummary(),hrnSummary);
@@ -1809,7 +1809,7 @@ private ReachGraph createInitialTaskReachGraph(FlatMethod fm) {
                                                        hrnSummary, // dest
                                                        type, // type
                                                        fd.getSymbol(), // field name
-                                                       srcHRN.getAlpha(), // beta
+                                                       hrnNewest.getAlpha(), // beta
                                                        ExistPredSet.factory(rg.predTrue) // predicates
                                                        );
                    
@@ -2043,7 +2043,7 @@ getFlaggedAllocationSitesReachableFromTaskPRIVATE(TaskDescriptor td) {
       rg.writeGraph( graphName,
                      true,  // write labels (variables)
                      true,  // selectively hide intermediate temp vars
-                     false, // prune unreachable heap regions
+                     true,  // prune unreachable heap regions
                      false, // hide subset reachability states
                      true );// hide edge taints
     }
index d1259c1487c46d1555c8c370b5ed5c5f678b987b..f67efa9173c410542c4494f0f90329a0b885c842 100644 (file)
@@ -123,15 +123,17 @@ public class ReachGraph {
     if( inherent == null ) {
       if( markForAnalysis ) {
        inherent = 
-          ReachSet.factory(
-                           ReachState.factory(
-                                              ReachTuple.factory( id,
-                                                                  !isSingleObject,
-                                                                  ReachTuple.ARITY_ONE,
-                                                                  false // out-of-context
-                                                                  )
-                                              )
-                           );
+          Canonical.makePredsTrue(
+                                  ReachSet.factory(
+                                                   ReachState.factory(
+                                                                      ReachTuple.factory( id,
+                                                                                          !isSingleObject,
+                                                                                          ReachTuple.ARITY_ONE,
+                                                                                          false // out-of-context
+                                                                                          )
+                                                                      )
+                                                   )
+                                  );
       } else {
        inherent = rsetWithEmptyState;
       }
@@ -592,15 +594,18 @@ public class ReachGraph {
                            hrnY.getType()
                            );  
 
-       RefEdge edgeNew = new RefEdge( hrnX,
-                                       hrnY,
-                                       tdNewEdge,
-                                       f.getSymbol(),
-                                       Canonical.pruneBy( edgeY.getBeta(),
-                                                          hrnX.getAlpha() 
-                                                          ),
-                                       predsTrue
-                                       );
+       RefEdge edgeNew = 
+          new RefEdge( hrnX,
+                       hrnY,
+                       tdNewEdge,
+                       f.getSymbol(),
+                       Canonical.makePredsTrue(
+                                               Canonical.pruneBy( edgeY.getBeta(),
+                                                                  hrnX.getAlpha() 
+                                                                  )
+                                               ),
+                       predsTrue
+                       );
 
         addEdgeOrMergeWithExisting( edgeNew );
       }
@@ -1895,7 +1900,8 @@ public class ReachGraph {
 
 
     if( writeDebugDOTs ) {    
-      rg.writeGraph( "calleeview", 
+      debugGraphPrefix = String.format( "call%02d", debugCallSiteVisits );
+      rg.writeGraph( debugGraphPrefix+"calleeview", 
                      resolveMethodDebugDOTwriteLabels,    
                      resolveMethodDebugDOTselectTemps,    
                      resolveMethodDebugDOTpruneGarbage,   
@@ -1913,7 +1919,7 @@ public class ReachGraph {
   // useful since many graphs writes in the method call debug code
   private static boolean resolveMethodDebugDOTwriteLabels     = true;
   private static boolean resolveMethodDebugDOTselectTemps     = true;
-  private static boolean resolveMethodDebugDOTpruneGarbage    = false;
+  private static boolean resolveMethodDebugDOTpruneGarbage    = true;
   private static boolean resolveMethodDebugDOThideSubsetReach = false;
   private static boolean resolveMethodDebugDOThideEdgeTaints  = true;
 
index a1052a6f8fda15d156d5a5ab0c91dd0d8fc1085a..aacd7aacafeb5b4e5eb4dce190a61633d99165c9 100644 (file)
@@ -152,7 +152,8 @@ public class ReachState extends Canonical {
 
 
   public String toString() {
-    return reachTuples.toString();
+    //return reachTuples.toString();
+    return reachTuples+":"+preds;
   }
 
   public String toStringPreds() {