Bug fix, subtle errors in exist pred hashcode, and a cycle pred.hashCode to state...
authorjjenista <jjenista>
Tue, 4 Oct 2011 23:49:19 +0000 (23:49 +0000)
committerjjenista <jjenista>
Tue, 4 Oct 2011 23:49:19 +0000 (23:49 +0000)
Robust/src/Analysis/Disjoint/ExistPred.java
Robust/src/Analysis/Disjoint/HeapRegionNode.java
Robust/src/Analysis/Disjoint/ReachGraph.java
Robust/src/Analysis/Disjoint/ReachState.java
Robust/src/Analysis/Disjoint/RefEdge.java
Robust/src/Benchmarks/oooJava/barneshut/Barneshut.java

index d1aef27baa119d78dc4f601dd93b3c4dd8da98ab..87c5e8426b44b395d451a211e01e419c0aa22222 100644 (file)
@@ -48,6 +48,10 @@ public class ExistPred extends Canonical {
   // The reach state may be null--if not the predicate is
   // satisfied when the edge exists AND it has the state.
   protected Integer n_hrnID;
+
+  // the preds on this state are irrelevant, so always strip them off
+  // when we store it in this ExistPred to make sure it equals other
+  // ExistPred objects with the same ne_state, preds ignored.
   protected ReachState ne_state;
 
   // An edge existence predicate is satisfied if the elements
@@ -121,7 +125,7 @@ public class ExistPred extends Canonical {
                       ReachState state) {
     assert hrnID != null;
     this.n_hrnID  = hrnID;
-    this.ne_state = state;
+    this.ne_state = removePreds( state );
     this.predType = TYPE_NODE;
     e_tdSrc    = null;
     e_hrnSrcID = null;
@@ -186,7 +190,7 @@ public class ExistPred extends Canonical {
     this.e_hrnDstID = hrnDstID;
     this.e_type     = type;
     this.e_field    = field;
-    this.ne_state   = state;
+    this.ne_state   = removePreds( state );
     this.e_taint    = taint;
     this.predType   = TYPE_EDGE;
     n_hrnID = null;
@@ -226,6 +230,11 @@ public class ExistPred extends Canonical {
 
 
 
+  private ReachState removePreds( ReachState state ) {
+    return state == null ? null : Canonical.attach( state, ExistPredSet.factory() );
+  }
+
+
 
   // only consider the subest of the caller elements that
   // are reachable by callee when testing predicates--if THIS
@@ -435,7 +444,7 @@ public class ExistPred extends Canonical {
       if( pred.ne_state != null ) {
         return false;
       }
-    } else if( !ne_state.equals(pred.ne_state) ) {
+    } else if( !ne_state.equalsIgnorePreds(pred.ne_state) ) {
       return false;
     }
 
@@ -508,6 +517,7 @@ public class ExistPred extends Canonical {
 
 
   public int hashCodeSpecific() {
+
     if( predType == TYPE_TRUE ) {
       return 1;
     }
@@ -516,7 +526,7 @@ public class ExistPred extends Canonical {
       int hash = n_hrnID.intValue()*17;
 
       if( ne_state != null ) {
-        hash ^= ne_state.hashCode();
+        hash ^= ne_state.hashCodeNoPreds();
       }
 
       return hash;
@@ -536,17 +546,17 @@ public class ExistPred extends Canonical {
       } else {
         hash ^= e_hrnSrcID.hashCode()*11;
         if( e_srcOutCalleeContext ) {
-          hash ^= 0xf1aeb;
+          hash ^= 0x01;
         }
         if( e_srcOutCallerContext ) {
-          hash ^= 0x875d;
+          hash ^= 0x80;
         }
       }
 
       hash += e_hrnDstID.hashCode();
 
       if( ne_state != null ) {
-        hash ^= ne_state.hashCode();
+        hash ^= ne_state.hashCodeNoPreds();
       }
 
       if( e_taint != null ) {
index c38617c9aae80ec88756e9146028894b61e55a73..93621d23c0107e209248c95e37a11fe8753456c1 100644 (file)
@@ -94,7 +94,6 @@ public class HeapRegionNode extends RefSrcNode {
   // fixed point, so use this method to determine if
   // a node is "equal" to some previous visit, basically
   public boolean equalsIncludingAlphaAndPreds(HeapRegionNode hrn) {
-
     return equals(hrn) &&
            alpha.equals(hrn.alpha) &&
            preds.equals(hrn.preds);
index 2b0e935d10076a28d87f1361254908cbc7d26069..3e5a043358d8eee448c7f3d32fd2df2d36059a70 100644 (file)
@@ -3950,7 +3950,7 @@ public class ReachGraph {
 
 
 
-  static boolean dbgEquals = false;
+  static public boolean dbgEquals = false;
 
 
   // it is necessary in the equals() member functions
@@ -4176,9 +4176,7 @@ public class ReachGraph {
 
           // there is an edge in the right place with the right field,
           // but do they have the same attributes?
-          if( edgeA.getBeta().equals(edgeB.getBeta() ) &&
-              edgeA.equalsPreds(edgeB)
-              ) {
+          if( edgeA.equalsIncludingBetaPredsTaints( edgeB ) ) {
             edgeFound = true;
           }
         }
index 5cea5b85a33a41186f58370494119db1c658dbcd..36897df2e8010aad98841219184a207f22d8e8bd 100644 (file)
@@ -137,6 +137,11 @@ public class ReachState extends Canonical {
   }
 
 
+  public int hashCodeNoPreds() {
+    return reachTuples.hashCode();
+  }
+
+
   public boolean equalsIgnorePreds(Object o) {
     if( o == null ) {
       return false;
index 9dc4faa60ecf8cd10a7e2f8e913b79be5504e7ec..457e752e66cda84502a4e70fd834ff657d1f4018 100644 (file)
@@ -2,6 +2,8 @@ package Analysis.Disjoint;
 
 import IR.*;
 import IR.Flat.*;
+import java.util.*;
+
 
 public class RefEdge {
 
@@ -104,10 +106,19 @@ public class RefEdge {
       return false;
     }
 
-    // Equality of edges is only valid within a graph, so
-    // compare src and dst by reference
-    if( !(src == edge.src) ||
-        !(dst == edge.dst)   ) {
+    if( src instanceof VariableNode ) {
+      VariableNode vsrc = (VariableNode) src;
+      if( !vsrc.equals( (VariableNode) edge.src ) ) {
+        return false;
+      }
+    } else {
+      HeapRegionNode hsrc = (HeapRegionNode) src;
+      if( !hsrc.equalsIncludingAlphaAndPreds( (HeapRegionNode) edge.src ) ) {
+        return false;
+      }
+    }
+    
+    if( !dst.equalsIncludingAlphaAndPreds( edge.dst ) ) {
       return false;
     }
 
index 7bc6e6a88130f40dcd02ae4770a9f1fd31d7f1fa..04b08a70d004a18f01475fdc6231871f2e5080b3 100644 (file)
@@ -243,20 +243,35 @@ public   void ComputeCenterOfMass(ArrayIndexedGraph octree, ArrayIndexedNode roo
     long start_time = System.currentTimeMillis();
     for (int step = 0; step < local_ntimesteps; step++) { // time-step the system
       ComputeCenterAndDiameter();
-      ArrayIndexedGraph octree = new ArrayIndexedGraph(8);
+      ArrayIndexedGraph octree = disjoint AIG new ArrayIndexedGraph(8);
       ArrayIndexedNode root = octree.createNode(new OctTreeNodeData(centerx, centery, centerz)); // create the tree's root
       octree.addNode(root);
       double radius = diameter * 0.5;
     
+
+      genreach b0;
+
       for (int i = 0; i < local_nbodies; i++) {
         Insert(octree, root, body[i], radius); // grow the tree by inserting each body
         body[i].root=root;
       }
       curr = 0;
+
+
+      genreach b1;
+
+
       // summarize subtree info in each internal node (plus restructure tree and sort bodies for performance reasons)
       ComputeCenterOfMass(octree, root);
 
+
+      genreach b2;
+
+
       sese force {
+
+        genreach b3;
+
        for(int i=0; i < local_nbodies; i++){
          // compute the acceleration of each body (consumes most of the total runtime)
          // n.ComputeForce(octree, root, diameter, itolsq, step, dthf, epssq);
@@ -266,6 +281,7 @@ public   void ComputeCenterOfMass(ArrayIndexedGraph octree, ArrayIndexedNode roo
          double dt=dthf;
          double ep=epssq;   
          sese parallel{
+            genreach intoPar;
            eachbody.ComputeForce(octree, di, it, step, dt, ep);
          }
        }
@@ -277,6 +293,7 @@ public   void ComputeCenterOfMass(ArrayIndexedGraph octree, ArrayIndexedNode roo
 
     } // end of time step
 
+
     long end_time=System.currentTimeMillis();
     
     if (isFirstRun) {