fix bug in alias reporting for Java programs
authorjjenista <jjenista>
Thu, 5 Mar 2009 18:24:29 +0000 (18:24 +0000)
committerjjenista <jjenista>
Thu, 5 Mar 2009 18:24:29 +0000 (18:24 +0000)
Robust/src/Analysis/OwnershipAnalysis/OwnershipAnalysis.java
Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java

index c555150d17d9d0884392621080689d3bc724718b..7d6670a85ccdae719df0b6e6bfdf77084b23c49d 100644 (file)
@@ -388,7 +388,7 @@ public class OwnershipAnalysis {
 
     if( writeDOTs && !writeAllDOTs ) {
       writeFinalContextGraphs();      
-    }
+    }  
 
     if( aliasFile != null ) {
       if( state.TASK ) {
@@ -953,16 +953,40 @@ public class OwnershipAnalysis {
   }
 
 
-  private HashSet<AllocationSite> getFlaggedAllocationSites(Descriptor d) {
+  private HashSet<AllocationSite> getFlaggedAllocationSites(Descriptor dIn) {
     
-    HashSet<AllocationSite> out = new HashSet<AllocationSite>();
-
-    HashSet<AllocationSite> asSet = getAllocationSiteSet(d);
-    Iterator asItr = asSet.iterator();
-    while( asItr.hasNext() ) {
-      AllocationSite as = (AllocationSite) asItr.next();
-      if( as.getDisjointId() != null ) {
-       out.add(as);
+    HashSet<AllocationSite> out     = new HashSet<AllocationSite>();
+    HashSet<Descriptor>     toVisit = new HashSet<Descriptor>();
+    HashSet<Descriptor>     visited = new HashSet<Descriptor>();
+
+    toVisit.add(dIn);
+
+    while( !toVisit.isEmpty() ) {
+      Descriptor d = toVisit.iterator().next();
+      toVisit.remove(d);
+      visited.add(d);
+
+      HashSet<AllocationSite> asSet = getAllocationSiteSet(d);
+      Iterator asItr = asSet.iterator();
+      while( asItr.hasNext() ) {
+       AllocationSite as = (AllocationSite) asItr.next();
+       if( as.getDisjointId() != null ) {
+         out.add(as);
+       }
+      }
+
+      // enqueue callees of this method to be searched for
+      // allocation sites also
+      Set callees = callGraph.getCalleeSet(d);
+      if( callees != null ) {
+       Iterator methItr = callees.iterator();
+       while( methItr.hasNext() ) {
+         MethodDescriptor md = (MethodDescriptor) methItr.next();
+
+         if( !visited.contains(md) ) {
+           toVisit.add(md);
+         }
+       }
       }
     }
     
index c94ade99a1e26f8e49e08922c29dda6425ad9634..5eb1c843cd49e0f2a6d9b910843084f1ab50363d 100644 (file)
@@ -232,7 +232,8 @@ public class OwnershipGraph {
 
        if( n.getAlpha().contains(c.getSetToMatch() ) ) {
          ReachabilitySet withChange = 
-           n.getAlpha().remove( c.getSetToMatch() ).union( c.getSetToAdd() );
+           //n.getAlpha().remove( c.getSetToMatch() ).union( c.getSetToAdd() );
+           n.getAlpha().union( c.getSetToAdd() );
          
          n.setAlphaNew( n.getAlphaNew().union(withChange) );
          nodesWithNewAlpha.add(n);
@@ -311,7 +312,8 @@ public class OwnershipGraph {
        ChangeTuple c = itrC.next();
        if( edgeE.getBeta().contains(c.getSetToMatch() ) ) {
          ReachabilitySet withChange = 
-           edgeE.getBeta().remove( c.getSetToMatch() ).union( c.getSetToAdd() );
+           //edgeE.getBeta().remove( c.getSetToMatch() ).union( c.getSetToAdd() );
+           edgeE.getBeta().union( c.getSetToAdd() );
 
          edgeE.setBetaNew(edgeE.getBetaNew().union(withChange) );
          edgesWithNewBeta.add(edgeE);
@@ -2188,7 +2190,7 @@ public class OwnershipGraph {
        ReferenceEdge edge = itrRes.next();
 
        if( (edge.getBeta().containsWithZeroes( tts ) ||
-            edge.getBeta().containsSuperSet  ( tts )   
+            edge.getBeta().containsSuperSet  ( tts )      
            ) && 
            !edge.getBetaNew().contains( tts )                 ) {
 
@@ -2887,7 +2889,7 @@ public class OwnershipGraph {
 
        // if these are the same site, don't look for the same token, no alias.
        // different tokens of the same site could alias together though
-       if( idI1 == idI2 ) {
+       if( idI1.equals( idI2 ) ) {
          continue;
        }