update the way this analysis visits every method reachable from program entry
authorjjenista <jjenista>
Mon, 25 Apr 2011 23:23:43 +0000 (23:23 +0000)
committerjjenista <jjenista>
Mon, 25 Apr 2011 23:23:43 +0000 (23:23 +0000)
Robust/src/Analysis/ArrayReferencees.java
Robust/src/Main/Main.java

index 0aa28df6e35d8a110424395d0a112a0b2c5ac301..cea2ec575c0b24614d6ca42f5ee1f9e95950867a 100644 (file)
 
 package Analysis;
 
-import IR.State;
-import IR.Descriptor;
-import IR.ClassDescriptor;
-import IR.MethodDescriptor;
-import IR.TaskDescriptor;
-import IR.TypeDescriptor;
+import IR.*;
+import Analysis.CallGraph.*;
 import IR.Flat.TempDescriptor;
 import IR.Flat.FlatMethod;
 import IR.Flat.FlatNode;
@@ -35,8 +31,8 @@ public class ArrayReferencees {
   ////////////////////////////////
   // public interface
   ////////////////////////////////
-  public ArrayReferencees( State state ) {
-    init( state );
+  public ArrayReferencees( State state, TypeUtil typeUtil, CallGraph callGraph ) {
+    init( state, typeUtil, callGraph );
   }
 
   public boolean doesNotCreateNewReaching( FlatSetElementNode fsen ) {
@@ -48,7 +44,9 @@ public class ArrayReferencees {
 
 
 
-  protected State state;
+  protected State     state;
+  protected TypeUtil  typeUtil;
+  protected CallGraph callGraph;
 
   // maintain the relation at every program point
   protected Hashtable<FlatNode, InArrayRelation> fn2rel;
@@ -60,27 +58,29 @@ public class ArrayReferencees {
 
   protected ArrayReferencees() {}
 
-  protected void init( State state ) {
-    this.state = state;
+  protected void init( State     state, 
+                       TypeUtil  typeUtil, 
+                       CallGraph callGraph ) {
+    this.state     = state;
+    this.typeUtil  = typeUtil;
+    this.callGraph = callGraph;
     fn2rel = new Hashtable<FlatNode, InArrayRelation>();
     noNewReaching = new HashSet<FlatSetElementNode>();
     buildRelation();
   }
 
   protected void buildRelation() {
-    // just analyze every method of every class that the
-    // compiler has code for, fix if this is too costly
-    Iterator classItr = state.getClassSymbolTable().getDescriptorsIterator();
-    while( classItr.hasNext() ) {
-      ClassDescriptor cd = (ClassDescriptor)classItr.next();
-
-      Iterator methodItr = cd.getMethods();
-      while( methodItr.hasNext() ) {
-       MethodDescriptor md = (MethodDescriptor)methodItr.next();
-
-       FlatMethod fm = state.getMethodFlat( md );
-       analyzeMethod( fm );
-      }
+
+    // analyze all methods transitively reachable from main
+    MethodDescriptor mdSourceEntry = typeUtil.getMain();
+    FlatMethod       fmMain        = state.getMethodFlat( mdSourceEntry );
+    
+    Set<MethodDescriptor> descriptorsToAnalyze = callGraph.getAllMethods( mdSourceEntry );
+    descriptorsToAnalyze.add( mdSourceEntry );
+    
+    for( MethodDescriptor md: descriptorsToAnalyze ) {
+      FlatMethod fm =  state.getMethodFlat( md );
+      analyzeMethod( fm );
     }
   }  
 
index 56dce135a8419d57de4dfdc7bab3c39834761bf2..6d6a192e37c4bb702e19c06079272ca9d9d5e80d 100644 (file)
@@ -518,7 +518,7 @@ public class Main {
     
     if (state.OWNERSHIP) {
       Liveness liveness = new Liveness();
-      ArrayReferencees ar = new ArrayReferencees(state);
+      ArrayReferencees ar = new ArrayReferencees(state, tu, callgraph);
       OwnershipAnalysis oa = new OwnershipAnalysis(state,
                                                    tu,
                                                    callgraph,
@@ -533,13 +533,13 @@ public class Main {
 
     if (state.DISJOINT && !state.OOOJAVA) {
       Liveness         l  = new Liveness();
-      ArrayReferencees ar = new ArrayReferencees(state);
+      ArrayReferencees ar = new ArrayReferencees(state, tu, callgraph);
       DisjointAnalysis da = new DisjointAnalysis(state, tu, callgraph, l, ar, null, null);
     }
 
     if (state.OOOJAVA) {
       Liveness         l   = new Liveness();
-      ArrayReferencees ar  = new ArrayReferencees(state);
+      ArrayReferencees ar  = new ArrayReferencees(state, tu, callgraph);
       oooa = new OoOJavaAnalysis(state, tu, callgraph, l, ar);
     }
 
@@ -575,7 +575,7 @@ public class Main {
       if (state.SCHEDULING) {
        // Use ownership analysis to get alias information
        Liveness liveness = new Liveness();
-        ArrayReferencees ar = new ArrayReferencees(state);
+        ArrayReferencees ar = new ArrayReferencees(state, tu, callgraph);
        OwnershipAnalysis oa = null;/*new OwnershipAnalysis(state,
                                                     tu,
                                                     callGraph,