set up to count graph elements over every final graph for every analyzed method
authorjjenista <jjenista>
Wed, 25 Jan 2012 20:42:03 +0000 (20:42 +0000)
committerjjenista <jjenista>
Wed, 25 Jan 2012 20:42:03 +0000 (20:42 +0000)
Robust/src/Analysis/Disjoint/AllocSite.java
Robust/src/Analysis/Disjoint/DisjointAnalysis.java
Robust/src/Analysis/Disjoint/GraphElementCount.java [new file with mode: 0644]
Robust/src/Analysis/Disjoint/HeapRegionNode.java
Robust/src/Analysis/Disjoint/ReachGraph.java
Robust/src/Benchmarks/oooJava/master-makefile
Robust/src/Tests/disjoint/strong-up-change-node-count/makefile

index fbf6711236bc38edc5d2093428a2f6016b547ddc..86d30d9e8b366457febf327f1ac8618194150b66 100644 (file)
@@ -266,13 +266,25 @@ public class AllocSite extends Canonical implements Alloc {
   }
 
   public String toStringForDOT() {
+    String s = "";
     if( disjointId != null ) {
-      return "disjoint "+disjointId+"\\n"+toString()+
-             "\\n"+getType().toPrettyString();
-    } else {
-      return toString()+
-             "\\n"+getType().toPrettyString();
+      s += "disjoint "+disjointId+"\\n";
     }
+    s += toString()+"\\n";
+
+    // jjenista -- too lazy to make this a compiler option right now
+    // But here's the rub: getting the source file and line number of
+    // each allocation site in the graph is awesome except it blows up
+    // the size of the image dramatically: only turn it on when you
+    // need it.!
+
+    //String filename = DisjointAnalysis.fn2filename.get( flatNew );
+    //if( filename != null ) {
+    //  s += DisjointAnalysis.fn2filename.get( flatNew )+":"+
+    //    flatNew.getNumLine()+"\\n";
+    //}
+
+    return s + getType().toPrettyString();
   }
 
   public String toStringWithIDs() {
index 689b53303f4e83a801603192792c006ee80ab3bd..f5f1ead57174f9255332ddeea30cc6ad16320faa 100644 (file)
@@ -587,6 +587,10 @@ public class DisjointAnalysis implements HeapAnalysis {
 
   Accessible accessible;
 
+
+  // for debugging, which source file is this allocation in?
+  public static Hashtable<FlatNode, String> fn2filename;
+
   
   // we construct an entry method of flat nodes complete
   // with a new allocation site to model the command line
@@ -736,6 +740,8 @@ public class DisjointAnalysis implements HeapAnalysis {
 
     fc2enclosing = new Hashtable<FlatCall, Descriptor>();
 
+    fn2filename = new Hashtable<FlatNode, String>();
+
     if( summarizePerClass ) {
       mapTypeToAllocSite = new Hashtable<TypeDescriptor, AllocSite>();
       typesToFlag = new HashSet<TypeDescriptor>();
@@ -931,16 +937,11 @@ public class DisjointAnalysis implements HeapAnalysis {
         " methods and "+totalNodeVisits+" nodes.";
     }
     if( state.DISJOINT_COUNT_GRAPH_ELEMENTS ) {
-      treport += "\n"+getPartial( mdSourceEntry ).countGraphElements()+"\n";
-      getPartial( mdSourceEntry ).writeGraph( "countElementsGraph", 
-                                              true,
-                                              true,
-                                              true,
-                                              false,
-                                              true,
-                                              true,
-                                              true );
-      getPartial( mdSourceEntry ).writeNodes( "countElementsNodeListing.txt" );
+      GraphElementCount gec = new GraphElementCount();
+      for( Descriptor d : descriptorsToAnalyze ) {
+        getPartial( d ).countGraphElements( gec );
+      }
+      treport += "\n"+gec+"\n";
     }
     String justtime = String.format("%.2f", dt);
     System.out.println(treport);
@@ -1746,6 +1747,9 @@ public class DisjointAnalysis implements HeapAnalysis {
 
     case FKind.FlatNew:
       FlatNew fnn = (FlatNew) fn;
+
+      recordFilename( fn, fmContaining );
+
       lhs = fnn.getDst();
       if( shouldAnalysisTrack(lhs.getType() ) ) {
         AllocSite as = getAllocSiteFromFlatNewPRIVATE(fnn);
@@ -3353,6 +3357,21 @@ public class DisjointAnalysis implements HeapAnalysis {
     return rgAtExit.canPointTo( x, arrayElementFieldName, x.getType().dereference() );
   }
 
+
+  
+  private void recordFilename( FlatNode fn, FlatMethod fmContaining ) {
+    ClassDescriptor cd = fmContaining.getMethod().getClassDesc();
+    String filename = "UNKNOWNFILE";
+    if( cd != null ) {
+      String s = cd.getSourceFileName();
+      if( s != null ) {
+        filename = s;
+      }
+    }
+    fn2filename.put( fn, filename );
+  }
+
+
   
   // to evaluate convergence behavior
   private static long totalMethodVisits = 0;
diff --git a/Robust/src/Analysis/Disjoint/GraphElementCount.java b/Robust/src/Analysis/Disjoint/GraphElementCount.java
new file mode 100644 (file)
index 0000000..bfc6b38
--- /dev/null
@@ -0,0 +1,61 @@
+package Analysis.Disjoint;
+
+import IR.*;
+import IR.Flat.*;
+import java.util.*;
+
+
+public class GraphElementCount {
+
+  public long numNodes;           
+  public long numEdges;           
+  public long numNodeStates;      
+  public long numEdgeStates;      
+  public long numNodeStateNonzero;
+  public long numEdgeStateNonzero;
+
+  public GraphElementCount() {
+    numNodes = 0;           
+    numEdges = 0;           
+    numNodeStates = 0;      
+    numEdgeStates = 0;      
+    numNodeStateNonzero = 0;
+    numEdgeStateNonzero = 0;
+  }
+
+  public void nodeInc( long amount ) {
+    numNodes += amount;
+  }
+
+  public void edgeInc( long amount ) {
+    numEdges += amount;
+  }
+
+  public void nodeStateInc( long amount ) {
+    numNodeStates += amount;
+  }
+
+  public void edgeStateInc( long amount ) {
+    numEdgeStates += amount;
+  }
+
+  public void nodeStateNonzeroInc( long amount ) {
+    numNodeStateNonzero += amount;
+  }
+
+  public void edgeStateNonzeroInc( long amount ) {
+    numEdgeStateNonzero += amount;
+  }
+
+  public String toString() {
+    return 
+      "################################################\n"+
+      "Nodes                = "+numNodes+"\n"+
+      "Edges                = "+numEdges+"\n"+
+      "Node states          = "+numNodeStates+"\n"+
+      "Edge states          = "+numEdgeStates+"\n"+
+      "Node non-zero tuples = "+numNodeStateNonzero+"\n"+
+      "Edge non-zero tuples = "+numEdgeStateNonzero+"\n"+
+      "################################################\n";
+  }
+}
index 93621d23c0107e209248c95e37a11fe8753456c1..4790a4a609054120579c8d63a5cfa852f1c9c5b7 100644 (file)
@@ -145,6 +145,9 @@ public class HeapRegionNode extends RefSrcNode {
     return isOutOfContext;
   }
 
+  public boolean isShadow() {
+    return id < 0;
+  }
 
   public Iterator<RefEdge> iteratorToReferencers() {
     return referencers.iterator();
index 26f812f1d599ef1bb7af07d893ef8552240f3c52..6e5522d5ca2a549f329b19db91d4c6b6c74bbea1 100644 (file)
@@ -5411,18 +5411,20 @@ public class ReachGraph {
   }
 
 
-  public String countGraphElements() {
-    long numNodes = 0;
-    long numEdges = 0;
-    long numNodeStates = 0;
-    long numEdgeStates = 0;
-    long numNodeStateNonzero = 0;
-    long numEdgeStateNonzero = 0;
+  public void countGraphElements( GraphElementCount c ) {
 
     for( HeapRegionNode node : id2hrn.values() ) {
-      numNodes++;
-      numNodeStates       += node.getAlpha().numStates();
-      numNodeStateNonzero += node.getAlpha().numNonzeroTuples();
+
+      if( node.isShadow() || node.isWiped() ) {
+        // do not count nodes that are not functionally part of the
+        // abstraction (they are in the graph for implementation
+        // convenience when needed next)
+        continue;
+      }
+      
+      c.nodeInc( 1 );
+      c.nodeStateInc( node.getAlpha().numStates() );
+      c.nodeStateNonzeroInc( node.getAlpha().numNonzeroTuples() );
 
       // all edges in the graph point TO a heap node, so scanning
       // all referencers of all nodes gets every edge
@@ -5430,21 +5432,11 @@ public class ReachGraph {
       while( refItr.hasNext() ) {
         RefEdge edge = refItr.next();
 
-        numEdges++;
-        numEdgeStates       += edge.getBeta().numStates();
-        numEdgeStateNonzero += edge.getBeta().numNonzeroTuples();
+        c.edgeInc( 1 );
+        c.edgeStateInc( edge.getBeta().numStates() );
+        c.edgeStateNonzeroInc( edge.getBeta().numNonzeroTuples() );
       }
     }
-
-    return 
-      "################################################\n"+
-      "Nodes                = "+numNodes+"\n"+
-      "Edges                = "+numEdges+"\n"+
-      "Node states          = "+numNodeStates+"\n"+
-      "Edge states          = "+numEdgeStates+"\n"+
-      "Node non-zero tuples = "+numNodeStateNonzero+"\n"+
-      "Edge non-zero tuples = "+numEdgeStateNonzero+"\n"+
-      "################################################\n";
   }
 
 
@@ -5460,6 +5452,9 @@ public class ReachGraph {
         // allocation site ID, full type, assigned heap node IDs
         bw.write( as.toStringVerbose()+"\n"+
                   "  "+as.toStringJustIDs()+"\n" );
+        bw.write( "  on "+
+                  DisjointAnalysis.fn2filename.get( as.getFlatNew() )+":"+
+                  as.getFlatNew().getNumLine()+"\n" );
 
         // which of the nodes are actually in this graph?
         for( int i = 0; i < allocationDepth; ++i ) {
index 4a029fbe2fb833004767cef65bb0c0806acdd3e5..e44d26f8552bc9ecddb8d41fba9aedf447abd07d 100644 (file)
@@ -77,10 +77,10 @@ DISJOINT= -disjoint -disjoint-k 1 -enable-assertions $(DRELEASEMODE) #-disjoint-
 # EX: (skip first 10 visits, capture the next 3, then halt)
 # -disjoint-debug-snap-method Remove 10 3 true
 
-DISJOINTDEBUG= -disjoint -disjoint-k 1 -enable-assertions $(DRELEASEMODE) \
+DISJOINTDEBUG= -disjoint -disjoint-k 1 -enable-assertions $(DRELEASEMODE) -printlinenum \
        -justanalyze \
-       -disjoint-count-graph-elements \
-       -disjoint-disable-strong-update
+       -disjoint-count-graph-elements
+#      -disjoint-disable-strong-update
 #      -disjoint-disable-global-sweep
 
 #      -disjoint-summarize-per-class
index 5f08b1a49cd1f672ce664adca4febca63cc44afe..21155ba41c8a975193d50c3f92830582fa4eb80b 100644 (file)
@@ -3,7 +3,7 @@ PROGRAM=test
 SOURCE_FILES=$(PROGRAM).java
 
 BUILDSCRIPT=~/research/Robust/src/buildscript
-BSFLAGS= -joptimize \
+BSFLAGS= -joptimize -printlinenum \
        -mainclass Test \
        -justanalyze -disjoint -disjoint-k 1 -disjoint-write-dots final \
        -disjoint-alias-file aliases.txt normal -enable-assertions \