improved debug graph capture
[IRC.git] / Robust / src / Analysis / Disjoint / ReachGraph.java
index 3f13f4901b268c0adab3040bdd5c70062f6b4f8e..9adbdad45f44a89554b5a4ba24adb7aacd4462ef 100644 (file)
@@ -290,6 +290,42 @@ public class ReachGraph {
     }
   }
 
+  // this is a common operation in many transfer functions: we want
+  // to add an edge, but if there is already such an edge we should
+  // merge the properties of the existing and the new edges
+  protected void addEdgeOrMergeWithExisting( RefEdge edgeNew ) {
+
+    RefSrcNode src = edgeNew.getSrc();
+    assert belongsToThis( src );
+
+    HeapRegionNode dst = edgeNew.getDst();
+    assert belongsToThis( dst );
+
+    // look to see if an edge with same field exists
+    // and merge with it, otherwise just add the edge
+    RefEdge edgeExisting = src.getReferenceTo( dst, 
+                                               edgeNew.getType(),
+                                               edgeNew.getField() 
+                                               );
+       
+    if( edgeExisting != null ) {
+      edgeExisting.setBeta(
+                           Canonical.unionORpreds( edgeExisting.getBeta(),
+                                                   edgeNew.getBeta()
+                                                   )
+                           );
+      edgeExisting.setPreds(
+                            Canonical.join( edgeExisting.getPreds(),
+                                            edgeNew.getPreds()
+                                            )
+                            );
+       
+    } else {                     
+      addRefEdge( src, dst, edgeNew );
+    }
+  }
+
+
 
   ////////////////////////////////////////////////////
   //
@@ -412,8 +448,8 @@ public class ReachGraph {
                                        Canonical.intersection( betaY, betaHrn ),
                                        predsTrue
                                        );
-       
-       addRefEdge( lnX, hrnHrn, edgeNew );
+
+        addEdgeOrMergeWithExisting( edgeNew );
       }
     }
 
@@ -564,27 +600,7 @@ public class ReachGraph {
                                        predsTrue
                                        );
 
-       // look to see if an edge with same field exists
-       // and merge with it, otherwise just add the edge
-       RefEdge edgeExisting = hrnX.getReferenceTo( hrnY, 
-                                                    tdNewEdge,
-                                                    f.getSymbol() );
-       
-       if( edgeExisting != null ) {
-         edgeExisting.setBeta(
-                               Canonical.unionORpreds( edgeExisting.getBeta(),
-                                                edgeNew.getBeta()
-                                                )
-                               );
-          edgeExisting.setPreds(
-                                Canonical.join( edgeExisting.getPreds(),
-                                                edgeNew.getPreds()
-                                                )
-                                );
-       
-        } else {                         
-         addRefEdge( hrnX, hrnY, edgeNew );
-       }
+        addEdgeOrMergeWithExisting( edgeNew );
       }
     }
 
@@ -776,9 +792,6 @@ public class ReachGraph {
       }
 
       String strDesc = as.toStringForDOT()+"\\nsummary";
-      if( shadow ) {
-        strDesc += " shadow";
-      }
 
       hrnSummary = 
         createNewHeapRegionNode( idSummary,    // id or null to generate a new one 
@@ -824,9 +837,6 @@ public class ReachGraph {
       }
 
       String strDesc = as.toStringForDOT()+"\\n"+i+" oldest";
-      if( shadow ) {
-        strDesc += " shadow";
-      }
 
       hrnIth = createNewHeapRegionNode( idIth,        // id or null to generate a new one 
                                         true,        // single object?                  
@@ -1281,9 +1291,9 @@ public class ReachGraph {
 
   // used below to convert a ReachSet to its callee-context
   // equivalent with respect to allocation sites in this graph
-  protected ReachSet toCalleeContext( ReachSet        rs,
-                                      ExistPredSet    preds,
-                                      Set<ReachTuple> oocTuples
+  protected ReachSet toCalleeContext( ReachSet      rs,
+                                      ExistPredSet  preds,
+                                      Set<HrnIdOoc> oocHrnIdOoc2callee
                                       ) {
     ReachSet out = ReachSet.factory();
    
@@ -1304,7 +1314,10 @@ public class ReachGraph {
 
           // only translate this tuple if it is
           // in the out-callee-context bag
-          if( !oocTuples.contains( rt ) ) {
+          HrnIdOoc hio = new HrnIdOoc( rt.getHrnID(),
+                                       rt.isOutOfContext()
+                                       );
+          if( !oocHrnIdOoc2callee.contains( hio ) ) {
             stateNew = Canonical.add( stateNew, rt );
             continue;
           }
@@ -1508,9 +1521,10 @@ public class ReachGraph {
     } // end iterating over parameters as starting points
 
 
-    // now collect out-of-context reach tuples and 
-    // more out-of-context edges
-    Set<ReachTuple> oocTuples = new HashSet<ReachTuple>();
+    // now collect out-of-callee-context IDs and 
+    // map them to whether the ID is out of the caller
+    // context as well
+    Set<HrnIdOoc> oocHrnIdOoc2callee = new HashSet<HrnIdOoc>();
 
     Iterator<Integer> itrInContext = 
       callerNodeIDsCopiedToCallee.iterator();
@@ -1557,13 +1571,15 @@ public class ReachGraph {
           while( rtItr.hasNext() ) {
             ReachTuple rt = rtItr.next();
 
-            oocTuples.add( rt );
+            oocHrnIdOoc2callee.add( new HrnIdOoc( rt.getHrnID(),
+                                                  rt.isOutOfContext()
+                                                  )
+                                    );
           }
         }
       }
     }
 
-
     // the callee view is a new graph: DON'T MODIFY *THIS* graph
     ReachGraph rg = new ReachGraph();
 
@@ -1587,11 +1603,11 @@ public class ReachGraph {
                                   hrnCaller.getAllocSite(),
                                   toCalleeContext( hrnCaller.getInherent(),
                                                    preds,
-                                                   oocTuples 
+                                                   oocHrnIdOoc2callee 
                                                    ),
                                   toCalleeContext( hrnCaller.getAlpha(),
                                                    preds,
-                                                   oocTuples 
+                                                   oocHrnIdOoc2callee 
                                                    ),
                                   preds,
                                   hrnCaller.getDescription()
@@ -1636,7 +1652,7 @@ public class ReachGraph {
                      reArg.getField(),
                      toCalleeContext( reArg.getBeta(),
                                       preds,
-                                      oocTuples
+                                      oocHrnIdOoc2callee
                                       ),
                      preds
                      );
@@ -1682,7 +1698,7 @@ public class ReachGraph {
                      reCaller.getField(),
                      toCalleeContext( reCaller.getBeta(),
                                       preds,
-                                      oocTuples 
+                                      oocHrnIdOoc2callee 
                                       ),
                      preds
                      );
@@ -1779,11 +1795,11 @@ public class ReachGraph {
                                         null,  // alloc site, shouldn't be used
                                         toCalleeContext( oocReach,               
                                                          preds,
-                                                         oocTuples
+                                                         oocHrnIdOoc2callee
                                                          ),
                                         toCalleeContext( oocReach,
                                                          preds,
-                                                         oocTuples
+                                                         oocHrnIdOoc2callee
                                                          ),
                                         preds,
                                         "out-of-context"
@@ -1808,27 +1824,30 @@ public class ReachGraph {
                                           null,  // alloc site, shouldn't be used
                                           toCalleeContext( oocReach,
                                                            preds,
-                                                           oocTuples
+                                                           oocHrnIdOoc2callee
                                                            ),
                                           toCalleeContext( oocReach,
                                                            preds,
-                                                           oocTuples
+                                                           oocHrnIdOoc2callee
                                                            ),
                                           preds,
                                           "out-of-context"
                                           );       
+
           } else {
             // otherwise it is there, so merge reachability
             hrnCalleeAndOutContext.setAlpha( Canonical.unionORpreds( hrnCalleeAndOutContext.getAlpha(),
                                                                      toCalleeContext( oocReach,
                                                                                       preds,
-                                                                                      oocTuples
+                                                                                      oocHrnIdOoc2callee
                                                                                       )
                                                                      )
                                              );
           }
         }
 
+        assert hrnCalleeAndOutContext.reachHasOnlyOOC();
+
         rg.addRefEdge( hrnCalleeAndOutContext,
                        hrnDstCallee,
                        new RefEdge( hrnCalleeAndOutContext,
@@ -1837,7 +1856,7 @@ public class ReachGraph {
                                     reCaller.getField(),
                                     toCalleeContext( reCaller.getBeta(),
                                                      preds,
-                                                     oocTuples
+                                                     oocHrnIdOoc2callee
                                                      ),
                                     preds
                                     )
@@ -1848,13 +1867,13 @@ public class ReachGraph {
         oocEdgeExisting.setBeta( Canonical.unionORpreds( oocEdgeExisting.getBeta(),
                                                          toCalleeContext( reCaller.getBeta(),
                                                                           preds,
-                                                                          oocTuples
+                                                                          oocHrnIdOoc2callee
                                                                           )
                                                   )
                                  );         
           
         oocEdgeExisting.setPreds( Canonical.join( oocEdgeExisting.getPreds(),
-                                                  reCaller.getPreds()
+                                                  preds
                                                   )
                                   );          
 
@@ -1863,25 +1882,23 @@ public class ReachGraph {
         hrnCalleeAndOutContext.setAlpha( Canonical.unionORpreds( hrnCalleeAndOutContext.getAlpha(),
                                                                  toCalleeContext( oocReach,
                                                                                   preds,
-                                                                                  oocTuples
+                                                                                  oocHrnIdOoc2callee
                                                                                   )
                                                                  )
                                          );
         
-        
+        assert hrnCalleeAndOutContext.reachHasOnlyOOC();
       }                
     }
 
 
     if( writeDebugDOTs ) {    
-      try {
-        rg.writeGraph( "calleeview", 
-                       resolveMethodDebugDOTwriteLabels,    
-                       resolveMethodDebugDOTselectTemps,    
-                       resolveMethodDebugDOTpruneGarbage,   
-                       resolveMethodDebugDOThideSubsetReach,
-                       resolveMethodDebugDOThideEdgeTaints );
-      } catch( IOException e ) {}
+      rg.writeGraph( "calleeview", 
+                     resolveMethodDebugDOTwriteLabels,    
+                     resolveMethodDebugDOTselectTemps,    
+                     resolveMethodDebugDOTpruneGarbage,   
+                     resolveMethodDebugDOThideSubsetReach,
+                     resolveMethodDebugDOThideEdgeTaints );      
     }
 
     return rg;
@@ -1898,7 +1915,9 @@ public class ReachGraph {
   private static boolean resolveMethodDebugDOThideSubsetReach = false;
   private static boolean resolveMethodDebugDOThideEdgeTaints  = true;
 
-
+  static String debugGraphPrefix;
+  static int debugCallSiteVisitsUntilExit = 0;
+  
 
   public void 
     resolveMethodCall( FlatCall     fc,        
@@ -1908,24 +1927,23 @@ public class ReachGraph {
                        boolean      writeDebugDOTs
                        ) {
 
-
     if( writeDebugDOTs ) {
-      try {
-        rgCallee.writeGraph( "callee", 
-                       resolveMethodDebugDOTwriteLabels,    
-                       resolveMethodDebugDOTselectTemps,    
-                       resolveMethodDebugDOTpruneGarbage,   
-                       resolveMethodDebugDOThideSubsetReach,
-                       resolveMethodDebugDOThideEdgeTaints );
-
-        writeGraph( "caller00In",  
-                    resolveMethodDebugDOTwriteLabels,    
-                    resolveMethodDebugDOTselectTemps,    
-                    resolveMethodDebugDOTpruneGarbage,   
-                    resolveMethodDebugDOThideSubsetReach,
-                    resolveMethodDebugDOThideEdgeTaints,
-                    callerNodeIDsCopiedToCallee );
-      } catch( IOException e ) {}
+      debugGraphPrefix = String.format( "call%02d", debugCallSiteVisitsUntilExit );
+      
+      rgCallee.writeGraph( debugGraphPrefix+"callee", 
+                           resolveMethodDebugDOTwriteLabels,    
+                           resolveMethodDebugDOTselectTemps,    
+                           resolveMethodDebugDOTpruneGarbage,   
+                           resolveMethodDebugDOThideSubsetReach,
+                           resolveMethodDebugDOThideEdgeTaints );
+      
+      writeGraph( debugGraphPrefix+"caller00In",  
+                  resolveMethodDebugDOTwriteLabels,    
+                  resolveMethodDebugDOTselectTemps,    
+                  resolveMethodDebugDOTpruneGarbage,   
+                  resolveMethodDebugDOThideSubsetReach,
+                  resolveMethodDebugDOThideEdgeTaints,
+                  callerNodeIDsCopiedToCallee );
     }
 
 
@@ -1942,7 +1960,6 @@ public class ReachGraph {
     // 5. Global sweep it.
 
 
-
     // 1. mark what callee elements have satisfied predicates
     Hashtable<HeapRegionNode, ExistPredSet> calleeNodesSatisfied =
       new Hashtable<HeapRegionNode, ExistPredSet>();
@@ -1970,6 +1987,7 @@ public class ReachGraph {
         hrnCallee.getPreds().isSatisfiedBy( this,
                                             callerNodeIDsCopiedToCallee
                                             );
+
       if( predsIfSatis != null ) {
         calleeNodesSatisfied.put( hrnCallee, predsIfSatis );
       } else {
@@ -2018,9 +2036,15 @@ public class ReachGraph {
         if( hrnSrcCallee.isOutOfContext() ) {          
 
           assert !calleeEdges2oocCallerSrcMatches.containsKey( reCallee );
+
           Set<RefSrcNode> rsnCallers = new HashSet<RefSrcNode>();            
 
+          // is the target node in the caller?
           HeapRegionNode hrnDstCaller = this.id2hrn.get( hrnCallee.getID() );
+          if( hrnDstCaller == null ) {
+            continue;
+          }          
+
           Iterator<RefEdge> reDstItr = hrnDstCaller.iteratorToReferencers();
           while( reDstItr.hasNext() ) {
             // the edge and field (either possibly null) must match
@@ -2034,6 +2058,7 @@ public class ReachGraph {
             
             RefSrcNode rsnCaller = reCaller.getSrc();
             if( rsnCaller instanceof VariableNode ) {
+
               // a variable node matches an OOC region with null type
               if( hrnSrcCallee.getType() != null ) {
                 continue;
@@ -2071,6 +2096,7 @@ public class ReachGraph {
           reCallee.getPreds().isSatisfiedBy( this,
                                              callerNodeIDsCopiedToCallee
                                              );
+
         if( predsIfSatis != null ) {
           calleeEdgesSatisfied.put( reCallee, predsIfSatis );
 
@@ -2096,8 +2122,14 @@ public class ReachGraph {
     for( int i = 0; i < fmCallee.numParameters(); ++i ) {
 
       // parameter defined here is the symbol in the callee
-      TempDescriptor tdParam  = fmCallee.getParameter( i );
-      VariableNode   vnCallee = rgCallee.getVariableNodeFromTemp( tdParam );
+      TempDescriptor tdParam = fmCallee.getParameter( i );
+
+      if( !DisjointAnalysis.shouldAnalysisTrack( tdParam.getType() ) ) {
+        // skip primitive/immutable parameters
+        continue;
+      }
+
+      VariableNode vnCallee = rgCallee.getVariableNodeFromTemp( tdParam );
 
       Iterator<RefEdge> reItr = vnCallee.iteratorToReferencees();
       while( reItr.hasNext() ) {
@@ -2141,14 +2173,12 @@ public class ReachGraph {
 
 
     if( writeDebugDOTs ) {
-      try {
-        writeGraph( "caller20BeforeWipe", 
-                    resolveMethodDebugDOTwriteLabels,    
-                    resolveMethodDebugDOTselectTemps,    
-                    resolveMethodDebugDOTpruneGarbage,   
-                    resolveMethodDebugDOThideSubsetReach,
-                    resolveMethodDebugDOThideEdgeTaints );
-      } catch( IOException e ) {}
+      writeGraph( debugGraphPrefix+"caller20BeforeWipe", 
+                  resolveMethodDebugDOTwriteLabels,    
+                  resolveMethodDebugDOTselectTemps,    
+                  resolveMethodDebugDOTpruneGarbage,   
+                  resolveMethodDebugDOThideSubsetReach,
+                  resolveMethodDebugDOThideEdgeTaints );
     }
 
 
@@ -2167,14 +2197,12 @@ public class ReachGraph {
 
 
     if( writeDebugDOTs ) {
-      try {
-        writeGraph( "caller30BeforeAddingNodes", 
-                    resolveMethodDebugDOTwriteLabels,    
-                    resolveMethodDebugDOTselectTemps,    
-                    resolveMethodDebugDOTpruneGarbage,   
-                    resolveMethodDebugDOThideSubsetReach,
-                    resolveMethodDebugDOThideEdgeTaints );
-      } catch( IOException e ) {}
+      writeGraph( debugGraphPrefix+"caller30BeforeAddingNodes", 
+                  resolveMethodDebugDOTwriteLabels,    
+                  resolveMethodDebugDOTselectTemps,    
+                  resolveMethodDebugDOTpruneGarbage,   
+                  resolveMethodDebugDOThideSubsetReach,
+                  resolveMethodDebugDOThideEdgeTaints );
     }
 
 
@@ -2236,14 +2264,12 @@ public class ReachGraph {
 
 
     if( writeDebugDOTs ) {
-      try {
-        writeGraph( "caller31BeforeAddingEdges", 
-                    resolveMethodDebugDOTwriteLabels,    
-                    resolveMethodDebugDOTselectTemps,    
-                    resolveMethodDebugDOTpruneGarbage,   
-                    resolveMethodDebugDOThideSubsetReach,
-                    resolveMethodDebugDOThideEdgeTaints );
-      } catch( IOException e ) {}
+      writeGraph( debugGraphPrefix+"caller31BeforeAddingEdges", 
+                  resolveMethodDebugDOTwriteLabels,    
+                  resolveMethodDebugDOTselectTemps,    
+                  resolveMethodDebugDOTpruneGarbage,   
+                  resolveMethodDebugDOThideSubsetReach,
+                  resolveMethodDebugDOThideEdgeTaints );
     }
 
 
@@ -2283,7 +2309,6 @@ public class ReachGraph {
       Set<RefSrcNode> oocCallers = 
         calleeEdges2oocCallerSrcMatches.get( reCallee );
 
-      boolean oocEdges = false;
       
       if( oocCallers == null ) {
         // there are no out-of-context matches, so it's
@@ -2301,8 +2326,8 @@ public class ReachGraph {
             // shouldn't this NEVER HAPPEN?
             assert false;
           }
+
           rsnCallers.add( this.getVariableNodeFromTemp( tdArg ) );
-          oocEdges = true;
 
         } else {
           // otherwise source is in context, one region
@@ -2344,7 +2369,6 @@ public class ReachGraph {
         // that should NOT be translated to shadow nodes
         assert !oocCallers.isEmpty();
         rsnCallers.addAll( oocCallers );
-        oocEdges = true;
       }
 
       // now make all caller edges we've identified from
@@ -2411,11 +2435,14 @@ public class ReachGraph {
 
           // for reach propagation
           if( !cs.isEmpty() ) {
-            edgePlannedChanges.put( 
-                                   edgeExisting, 
-                                   Canonical.union( edgePlannedChanges.get( edgeExisting ),
-                                                    cs
-                                                    ) 
+            ChangeSet csExisting = edgePlannedChanges.get( edgeExisting );
+            if( csExisting == null ) {
+              csExisting = ChangeSet.factory();
+            }
+            edgePlannedChanges.put( edgeExisting, 
+                                    Canonical.union( csExisting,
+                                                     cs
+                                                     ) 
                                     );
           }
           
@@ -2437,14 +2464,12 @@ public class ReachGraph {
 
 
     if( writeDebugDOTs ) {
-      try {
-        writeGraph( "caller35BeforeAssignReturnValue", 
-                    resolveMethodDebugDOTwriteLabels,    
-                    resolveMethodDebugDOTselectTemps,    
-                    resolveMethodDebugDOTpruneGarbage,   
-                    resolveMethodDebugDOThideSubsetReach,
-                    resolveMethodDebugDOThideEdgeTaints );
-      } catch( IOException e ) {}
+      writeGraph( debugGraphPrefix+"caller35BeforeAssignReturnValue", 
+                  resolveMethodDebugDOTwriteLabels,    
+                  resolveMethodDebugDOTselectTemps,    
+                  resolveMethodDebugDOTpruneGarbage,   
+                  resolveMethodDebugDOThideSubsetReach,
+                  resolveMethodDebugDOThideEdgeTaints );
     }
 
 
@@ -2455,7 +2480,9 @@ public class ReachGraph {
     
     // 3.d) handle return value assignment if needed
     TempDescriptor returnTemp = fc.getReturnTemp();
-    if( returnTemp != null && !returnTemp.getType().isImmutable() ) {
+    if( returnTemp != null && 
+        DisjointAnalysis.shouldAnalysisTrack( returnTemp.getType() ) 
+        ) {
 
       VariableNode vnLhsCaller = getVariableNodeFromTemp( returnTemp );
       clearRefEdgesFrom( vnLhsCaller, null, null, true );
@@ -2497,8 +2524,6 @@ public class ReachGraph {
                                      predsTrue,                     // predicates
                                      hrnDstCallee.getDescription()  // description
                                      );                                        
-        } else {
-          assert hrnDstCaller.isWiped();
         }
 
         TypeDescriptor tdNewEdge =
@@ -2523,14 +2548,12 @@ public class ReachGraph {
 
 
     if( writeDebugDOTs ) {
-      try {
-        writeGraph( "caller38propagateReach", 
-                    resolveMethodDebugDOTwriteLabels,    
-                    resolveMethodDebugDOTselectTemps,    
-                    resolveMethodDebugDOTpruneGarbage,   
-                    resolveMethodDebugDOThideSubsetReach,
-                    resolveMethodDebugDOThideEdgeTaints );
-      } catch( IOException e ) {}
+      writeGraph( debugGraphPrefix+"caller38propagateReach", 
+                  resolveMethodDebugDOTwriteLabels,    
+                  resolveMethodDebugDOTselectTemps,    
+                  resolveMethodDebugDOTpruneGarbage,   
+                  resolveMethodDebugDOThideSubsetReach,
+                  resolveMethodDebugDOThideEdgeTaints );
     }
 
     // propagate callee reachability changes to the rest
@@ -2553,14 +2576,12 @@ public class ReachGraph {
 
 
     if( writeDebugDOTs ) {
-      try {
-        writeGraph( "caller40BeforeShadowMerge", 
-                    resolveMethodDebugDOTwriteLabels,    
-                    resolveMethodDebugDOTselectTemps,    
-                    resolveMethodDebugDOTpruneGarbage,   
-                    resolveMethodDebugDOThideSubsetReach,
-                    resolveMethodDebugDOThideEdgeTaints );
-      } catch( IOException e ) {}
+      writeGraph( debugGraphPrefix+"caller40BeforeShadowMerge", 
+                  resolveMethodDebugDOTwriteLabels,    
+                  resolveMethodDebugDOTselectTemps,    
+                  resolveMethodDebugDOTpruneGarbage,   
+                  resolveMethodDebugDOThideSubsetReach,
+                  resolveMethodDebugDOThideEdgeTaints );
     }
     
 
@@ -2654,14 +2675,12 @@ public class ReachGraph {
 
 
     if( writeDebugDOTs ) {
-      try {
-        writeGraph( "caller45BeforeUnshadow", 
-                    resolveMethodDebugDOTwriteLabels,    
-                    resolveMethodDebugDOTselectTemps,    
-                    resolveMethodDebugDOTpruneGarbage,   
-                    resolveMethodDebugDOThideSubsetReach,
-                    resolveMethodDebugDOThideEdgeTaints );
-      } catch( IOException e ) {}
+      writeGraph( debugGraphPrefix+"caller45BeforeUnshadow", 
+                  resolveMethodDebugDOTwriteLabels,    
+                  resolveMethodDebugDOTselectTemps,    
+                  resolveMethodDebugDOTpruneGarbage,   
+                  resolveMethodDebugDOThideSubsetReach,
+                  resolveMethodDebugDOThideEdgeTaints );
     }
     
     
@@ -2682,14 +2701,12 @@ public class ReachGraph {
 
 
     if( writeDebugDOTs ) {
-      try {
-        writeGraph( "caller50BeforeGlobalSweep", 
-                    resolveMethodDebugDOTwriteLabels,    
-                    resolveMethodDebugDOTselectTemps,    
-                    resolveMethodDebugDOTpruneGarbage,   
-                    resolveMethodDebugDOThideSubsetReach,
-                    resolveMethodDebugDOThideEdgeTaints );
-      } catch( IOException e ) {}
+      writeGraph( debugGraphPrefix+"caller50BeforeGlobalSweep", 
+                  resolveMethodDebugDOTwriteLabels,    
+                  resolveMethodDebugDOTselectTemps,    
+                  resolveMethodDebugDOTpruneGarbage,   
+                  resolveMethodDebugDOThideSubsetReach,
+                  resolveMethodDebugDOThideEdgeTaints );
     }
 
 
@@ -2701,14 +2718,18 @@ public class ReachGraph {
 
 
     if( writeDebugDOTs ) {
-      try {
-        writeGraph( "caller90AfterTransfer", 
-                    resolveMethodDebugDOTwriteLabels,    
-                    resolveMethodDebugDOTselectTemps,    
-                    resolveMethodDebugDOTpruneGarbage,   
-                    resolveMethodDebugDOThideSubsetReach,
-                    resolveMethodDebugDOThideEdgeTaints );
-      } catch( IOException e ) {}
+      writeGraph( debugGraphPrefix+"caller90AfterTransfer", 
+                  resolveMethodDebugDOTwriteLabels,    
+                  resolveMethodDebugDOTselectTemps,    
+                  resolveMethodDebugDOTpruneGarbage,   
+                  resolveMethodDebugDOThideSubsetReach,
+                  resolveMethodDebugDOThideEdgeTaints );
+
+      --debugCallSiteVisitsUntilExit;
+      if( debugCallSiteVisitsUntilExit <= 0 ) {
+        System.out.println( "!!! Exiting after requested visits to call site. !!!" );
+        System.exit( 0 );
+      }
     }
   } 
 
@@ -2871,10 +2892,13 @@ public class ReachGraph {
        assert rsetEmpty.equals( edge.getBetaNew() );
       }      
 
-      // calculate boldB for this flagged node, or out-of-context node
+      // make a mapping of IDs to heap regions they propagate from
       if( hrn.isFlagged() ) {
         assert !hrn.isOutOfContext();
         assert !icID2srcs.containsKey( hrn.getID() );
+
+        // in-context flagged node IDs simply propagate from the
+        // node they name
         Set<HeapRegionNode> srcs = new HashSet<HeapRegionNode>();
         srcs.add( hrn );
         icID2srcs.put( hrn.getID(), srcs );
@@ -2883,6 +2907,13 @@ public class ReachGraph {
       if( hrn.isOutOfContext() ) {
        assert !hrn.isFlagged();
 
+        // the reachability states on an out-of-context
+        // node are not really important (combinations of
+        // IDs or arity)--what matters is that the states
+        // specify which nodes this out-of-context node
+        // stands in for.  For example, if the state [17?, 19*]
+        // appears on the ooc node, it may serve as a source
+        // for node 17? and a source for node 19.
         Iterator<ReachState> stateItr = hrn.getAlpha().iterator();
         while( stateItr.hasNext() ) {
           ReachState state = stateItr.next();
@@ -3059,6 +3090,14 @@ public class ReachGraph {
             if( rtOld.isOutOfContext() ) {
               B = boldBooc.get( rtOld.getHrnID() ); 
             } else {
+
+
+              if( !id2hrn.containsKey( rtOld.getHrnID() ) ) {
+                System.out.println( "\nLooking for "+rtOld );
+                writeGraph( "dbgz" );
+              }
+
+
               assert id2hrn.containsKey( rtOld.getHrnID() );
               B = boldBic.get( rtOld.getHrnID() ); 
             }
@@ -3455,6 +3494,10 @@ public class ReachGraph {
   }
 
 
+
+  static boolean dbgEquals = false;
+
+
   // it is necessary in the equals() member functions
   // to "check both ways" when comparing the data
   // structures of two graphs.  For instance, if all
@@ -3468,18 +3511,30 @@ public class ReachGraph {
   public boolean equals( ReachGraph rg ) {
 
     if( rg == null ) {
+      if( dbgEquals ) {
+        System.out.println( "rg is null" );
+      }
       return false;
     }
     
     if( !areHeapRegionNodesEqual( rg ) ) {
+      if( dbgEquals ) {
+        System.out.println( "hrn not equal" );
+      }
       return false;
     }
 
     if( !areVariableNodesEqual( rg ) ) {
+      if( dbgEquals ) {
+        System.out.println( "vars not equal" );
+      }
       return false;
     }
 
     if( !areRefEdgesEqual( rg ) ) {
+      if( dbgEquals ) {
+        System.out.println( "edges not equal" );
+      }
       return false;
     }
 
@@ -3526,7 +3581,6 @@ public class ReachGraph {
     
     return true;
   }
-  
 
   protected boolean areVariableNodesEqual( ReachGraph rg ) {
 
@@ -3795,13 +3849,25 @@ public class ReachGraph {
   
 
 
+  // the default signature for quick-and-dirty debugging
+  public void writeGraph( String graphName ) {
+    writeGraph( graphName,
+                true, // write labels
+                true, // label select
+                true, // prune garbage
+                true, // hide subset reachability
+                true, // hide edge taints
+                null  // in-context boundary
+                );
+  }
+
   public void writeGraph( String  graphName,
                           boolean writeLabels,
                           boolean labelSelect,
                           boolean pruneGarbage,
                           boolean hideSubsetReachability,
                           boolean hideEdgeTaints
-                          ) throws java.io.IOException {
+                          ) {
     writeGraph( graphName,
                 writeLabels,
                 labelSelect,
@@ -3818,94 +3884,57 @@ public class ReachGraph {
                           boolean      hideSubsetReachability,
                           boolean      hideEdgeTaints,
                           Set<Integer> callerNodeIDsCopiedToCallee
-                          ) throws java.io.IOException {
+                          ) {
     
-    // remove all non-word characters from the graph name so
-    // the filename and identifier in dot don't cause errors
-    graphName = graphName.replaceAll( "[\\W]", "" );
-
-    BufferedWriter bw = 
-      new BufferedWriter( new FileWriter( graphName+".dot" ) );
+    try {
+      // remove all non-word characters from the graph name so
+      // the filename and identifier in dot don't cause errors
+      graphName = graphName.replaceAll( "[\\W]", "" );
 
-    bw.write( "digraph "+graphName+" {\n" );
+      BufferedWriter bw = 
+        new BufferedWriter( new FileWriter( graphName+".dot" ) );
 
+      bw.write( "digraph "+graphName+" {\n" );
 
-    // this is an optional step to form the callee-reachable
-    // "cut-out" into a DOT cluster for visualization
-    if( callerNodeIDsCopiedToCallee != null ) {
-
-      bw.write( "  subgraph cluster0 {\n" );
-      bw.write( "    color=blue;\n" );
-
-      Iterator i = id2hrn.entrySet().iterator();
-      while( i.hasNext() ) {
-        Map.Entry      me  = (Map.Entry)      i.next();
-        HeapRegionNode hrn = (HeapRegionNode) me.getValue();      
+      
+      // this is an optional step to form the callee-reachable
+      // "cut-out" into a DOT cluster for visualization
+      if( callerNodeIDsCopiedToCallee != null ) {
         
-        if( callerNodeIDsCopiedToCallee.contains( hrn.getID() ) ) {
-          bw.write( "    "+hrn.toString()+
-                    hrn.toStringDOT( hideSubsetReachability )+
-                    ";\n" );
+        bw.write( "  subgraph cluster0 {\n" );
+        bw.write( "    color=blue;\n" );
+      
+        Iterator i = id2hrn.entrySet().iterator();
+        while( i.hasNext() ) {
+          Map.Entry      me  = (Map.Entry)      i.next();
+          HeapRegionNode hrn = (HeapRegionNode) me.getValue();      
           
+          if( callerNodeIDsCopiedToCallee.contains( hrn.getID() ) ) {
+            bw.write( "    "+hrn.toString()+
+                      hrn.toStringDOT( hideSubsetReachability )+
+                      ";\n" );
+            
+          }
         }
+        
+        bw.write( "  }\n" );
       }
-
-      bw.write( "  }\n" );
-    }
-
-
-    Set<HeapRegionNode> visited = new HashSet<HeapRegionNode>();
-
-    // then visit every heap region node    
-    Iterator i = id2hrn.entrySet().iterator();
-    while( i.hasNext() ) {
-      Map.Entry      me  = (Map.Entry)      i.next();
-      HeapRegionNode hrn = (HeapRegionNode) me.getValue();      
-
-      // only visit nodes worth writing out--for instance
-      // not every node at an allocation is referenced
-      // (think of it as garbage-collected), etc.
-      if( !pruneGarbage        ||
-          hrn.isOutOfContext()
-          ) {
-
-       if( !visited.contains( hrn ) ) {
-         traverseHeapRegionNodes( hrn,
-                                   bw,
-                                   null,
-                                   visited,
-                                   hideSubsetReachability,
-                                   hideEdgeTaints,
-                                   callerNodeIDsCopiedToCallee );
-       }
-      }
-    }
-
-    bw.write( "  graphTitle[label=\""+graphName+"\",shape=box];\n" );
-  
-
-    // then visit every label node, useful for debugging
-    if( writeLabels ) {
-      i = td2vn.entrySet().iterator();
+      
+      
+      Set<HeapRegionNode> visited = new HashSet<HeapRegionNode>();
+      
+      // then visit every heap region node    
+      Iterator i = id2hrn.entrySet().iterator();
       while( i.hasNext() ) {
-        Map.Entry    me = (Map.Entry)    i.next();
-        VariableNode vn = (VariableNode) me.getValue();
-        
-        if( labelSelect ) {
-          String labelStr = vn.getTempDescriptorString();
-          if( labelStr.startsWith( "___temp" )     ||
-              labelStr.startsWith( "___dst" )      ||
-              labelStr.startsWith( "___srctmp" )   ||
-              labelStr.startsWith( "___neverused" )
-              ) {
-            continue;
-          }
-        }
+        Map.Entry      me  = (Map.Entry)      i.next();
+        HeapRegionNode hrn = (HeapRegionNode) me.getValue();      
         
-        Iterator<RefEdge> heapRegionsItr = vn.iteratorToReferencees();
-        while( heapRegionsItr.hasNext() ) {
-          RefEdge        edge = heapRegionsItr.next();
-          HeapRegionNode hrn  = edge.getDst();
+        // only visit nodes worth writing out--for instance
+        // not every node at an allocation is referenced
+        // (think of it as garbage-collected), etc.
+        if( !pruneGarbage        ||
+            hrn.isOutOfContext()
+            ) {
           
           if( !visited.contains( hrn ) ) {
             traverseHeapRegionNodes( hrn,
@@ -3916,17 +3945,59 @@ public class ReachGraph {
                                      hideEdgeTaints,
                                      callerNodeIDsCopiedToCallee );
           }
+        }
+      }
+      
+      bw.write( "  graphTitle[label=\""+graphName+"\",shape=box];\n" );
+      
+      
+      // then visit every label node, useful for debugging
+      if( writeLabels ) {
+        i = td2vn.entrySet().iterator();
+        while( i.hasNext() ) {
+          Map.Entry    me = (Map.Entry)    i.next();
+          VariableNode vn = (VariableNode) me.getValue();
           
-          bw.write( "  "+vn.toString()+
-                    " -> "+hrn.toString()+
-                    edge.toStringDOT( hideSubsetReachability, "" )+
-                    ";\n" );
+          if( labelSelect ) {
+            String labelStr = vn.getTempDescriptorString();
+            if( labelStr.startsWith( "___temp" )     ||
+                labelStr.startsWith( "___dst" )      ||
+                labelStr.startsWith( "___srctmp" )   ||
+                labelStr.startsWith( "___neverused" )
+                ) {
+              continue;
+            }
+          }
+          
+          Iterator<RefEdge> heapRegionsItr = vn.iteratorToReferencees();
+          while( heapRegionsItr.hasNext() ) {
+            RefEdge        edge = heapRegionsItr.next();
+            HeapRegionNode hrn  = edge.getDst();
+          
+            if( !visited.contains( hrn ) ) {
+              traverseHeapRegionNodes( hrn,
+                                       bw,
+                                       null,
+                                       visited,
+                                       hideSubsetReachability,
+                                       hideEdgeTaints,
+                                       callerNodeIDsCopiedToCallee );
+            }
+          
+            bw.write( "  "+vn.toString()+
+                      " -> "+hrn.toString()+
+                      edge.toStringDOT( hideSubsetReachability, "" )+
+                      ";\n" );
+          }
         }
       }
-    }
     
-    bw.write( "}\n" );
-    bw.close();
+      bw.write( "}\n" );
+      bw.close();
+
+    } catch( IOException e ) {
+      throw new Error( "Error writing out DOT graph "+graphName );
+    }
   }
 
   protected void traverseHeapRegionNodes( HeapRegionNode      hrn,
@@ -3999,292 +4070,347 @@ public class ReachGraph {
     }
   }  
   
-       public Set<HeapRegionNode> findCommonReachableNodes(HeapRegionNode hrn1,
-                       HeapRegionNode hrn2) {
 
-               Set<HeapRegionNode> reachableNodes1 = new HashSet<HeapRegionNode>();
-               Set<HeapRegionNode> reachableNodes2 = new HashSet<HeapRegionNode>();
 
-               Set<HeapRegionNode> todoNodes1 = new HashSet<HeapRegionNode>();
-               todoNodes1.add(hrn1);
 
-               Set<HeapRegionNode> todoNodes2 = new HashSet<HeapRegionNode>();
-               todoNodes2.add(hrn2);
 
-               // follow links until all reachable nodes have been found
-               while (!todoNodes1.isEmpty()) {
-                       HeapRegionNode hrn = todoNodes1.iterator().next();
-                       todoNodes1.remove(hrn);
-                       reachableNodes1.add(hrn);
+  public Set<HeapRegionNode> findCommonReachableNodes( ReachSet proofOfSharing ) {
 
-                       Iterator<RefEdge> edgeItr = hrn.iteratorToReferencees();
-                       while (edgeItr.hasNext()) {
-                               RefEdge edge = edgeItr.next();
+    Set<HeapRegionNode> exhibitProofState =
+      new HashSet<HeapRegionNode>();
 
-                               if (!reachableNodes1.contains(edge.getDst())) {
-                                       todoNodes1.add(edge.getDst());
-                               }
-                       }
-               }
+    Iterator hrnItr = id2hrn.entrySet().iterator();
+    while( hrnItr.hasNext() ) {
+      Map.Entry      me  = (Map.Entry) hrnItr.next();
+      HeapRegionNode hrn = (HeapRegionNode) me.getValue();
+      
+      ReachSet intersection =
+        Canonical.intersection( proofOfSharing,
+                                hrn.getAlpha()
+                                );
+      if( !intersection.isEmpty() ) {
+        assert !hrn.isOutOfContext();
+        exhibitProofState.add( hrn );
+      }
+    }
+    
+    return exhibitProofState;
+  }
 
-               while (!todoNodes2.isEmpty()) {
-                       HeapRegionNode hrn = todoNodes2.iterator().next();
-                       todoNodes2.remove(hrn);
-                       reachableNodes2.add(hrn);
+        
+  public Set<HeapRegionNode> mayReachSharedObjects(HeapRegionNode hrn1,
+                                                   HeapRegionNode hrn2) {
+    assert hrn1 != null;
+    assert hrn2 != null;
 
-                       Iterator<RefEdge> edgeItr = hrn.iteratorToReferencees();
-                       while (edgeItr.hasNext()) {
-                               RefEdge edge = edgeItr.next();
+    assert !hrn1.isOutOfContext();
+    assert !hrn2.isOutOfContext();
 
-                               if (!reachableNodes2.contains(edge.getDst())) {
-                                       todoNodes2.add(edge.getDst());
-                               }
-                       }
-               }
+    assert belongsToThis( hrn1 );
+    assert belongsToThis( hrn2 );
 
-               Set<HeapRegionNode> intersection =
-                  new HashSet<HeapRegionNode>( reachableNodes1 );
+    assert !hrn1.getID().equals( hrn2.getID() );
 
-               intersection.retainAll( reachableNodes2 );
 
-               return intersection;
-       }
-        
-       public Set<HeapRegionNode> mayReachSharedObjects(HeapRegionNode hrn1,
-                       HeapRegionNode hrn2) {
-               assert hrn1 != null;
-               assert hrn2 != null;
-
-               // then get the various tokens for these heap regions
-               ReachTuple h1 = ReachTuple.factory(hrn1.getID(),
-                               !hrn1.isSingleObject(), ReachTuple.ARITY_ONE, false);
-
-               int arity;
-               if(hrn1.isSingleObject){
-                       arity=ReachTuple.ARITY_ONE;
-               }else{
-                       arity=ReachTuple.ARITY_ZEROORMORE;
-               }
-               ReachTuple h1star = ReachTuple.factory(hrn1.getID(), !hrn1
-                               .isSingleObject(), arity, false);
-
-               ReachTuple h2 = ReachTuple.factory(hrn2.getID(),
-                               !hrn2.isSingleObject(), ReachTuple.ARITY_ONE, false);
-
-               if(hrn2.isSingleObject){
-                       arity=ReachTuple.ARITY_ONE;
-               }else{
-                       arity=ReachTuple.ARITY_ZEROORMORE;
-               }
-               
-               ReachTuple h2star = ReachTuple.factory(hrn2.getID(), !hrn2
-                               .isSingleObject(), arity, false);
-
-               // then get the merged beta of all out-going edges from these heap
-               // regions
-
-               ReachSet beta1 = ReachSet.factory();
-               Iterator<RefEdge> itrEdge = hrn1.iteratorToReferencees();
-               while (itrEdge.hasNext()) {
-                       RefEdge edge = itrEdge.next();
-                       beta1 = Canonical.unionORpreds(beta1, edge.getBeta());
-               }
-
-               ReachSet beta2 = ReachSet.factory();
-               itrEdge = hrn2.iteratorToReferencees();
-               while (itrEdge.hasNext()) {
-                       RefEdge edge = itrEdge.next();
-                       beta2 = Canonical.unionORpreds(beta2, edge.getBeta());
-               }
-
-               boolean aliasDetected = false;
-
-               // only do this one if they are different tokens
-               if (h1 != h2 && beta1.containsStateWithBoth(h1, h2)) {
-                       aliasDetected = true;
-               }
-//             if (beta1.containsStateWithBoth(h1plus, h2)) {
-//                     aliasDetected = true;
-//             }
-               if (beta1.containsStateWithBoth(h1star, h2)) {
-                       aliasDetected = true;
-               }
-//             if (beta1.containsStateWithBoth(h1, h2plus)) {
-//                     aliasDetected = true;
-//             }
-//             if (beta1.containsStateWithBoth(h1plus, h2plus)) {
-//                     aliasDetected = true;
-//             }
-//             if (beta1.containsStateWithBoth(h1star, h2plus)) {
-//                     aliasDetected = true;
-//             }
-               if (beta1.containsStateWithBoth(h1, h2star)) {
-                       aliasDetected = true;
-               }
-//             if (beta1.containsStateWithBoth(h1plus, h2star)) {
-//                     aliasDetected = true;
-//             }
-               if (beta1.containsStateWithBoth(h1star, h2star)) {
-                       aliasDetected = true;
-               }
-
-               if (h1 != h2 && beta2.containsStateWithBoth(h1, h2)) {
-                       aliasDetected = true;
-               }
-//             if (beta2.containsStateWithBoth(h1plus, h2)) {
-//                     aliasDetected = true;
-//             }
-               if (beta2.containsStateWithBoth(h1star, h2)) {
-                       aliasDetected = true;
-               }
-//             if (beta2.containsStateWithBoth(h1, h2plus)) {
-//                     aliasDetected = true;
-//             }
-//             if (beta2.containsStateWithBoth(h1plus, h2plus)) {
-//                     aliasDetected = true;
-//             }
-//             if (beta2.containsStateWithBoth(h1star, h2plus)) {
-//                     aliasDetected = true;
-//             }
-               if (beta2.containsStateWithBoth(h1, h2star)) {
-                       aliasDetected = true;
-               }
-//             if (beta2.containsStateWithBoth(h1plus, h2star)) {
-//                     aliasDetected = true;
-//             }
-               if (beta2.containsStateWithBoth(h1star, h2star)) {
-                       aliasDetected = true;
-               }
-
-               Set<HeapRegionNode> common = new HashSet<HeapRegionNode>();
-               if (aliasDetected) {
-                       common = findCommonReachableNodes(hrn1, hrn2);
-                       if (!(DISABLE_STRONG_UPDATES || DISABLE_GLOBAL_SWEEP)) {
-                               assert !common.isEmpty();
-                       }
-               }
-
-               return common;
-       }
+    // then get the various tokens for these heap regions
+    ReachTuple h1 = 
+      ReachTuple.factory( hrn1.getID(),
+                          !hrn1.isSingleObject(), // multi?
+                          ReachTuple.ARITY_ONE, 
+                          false );                // ooc?
+    
+    ReachTuple h1star = null;
+    if( !hrn1.isSingleObject() ) {
+      h1star = 
+        ReachTuple.factory( hrn1.getID(), 
+                            !hrn1.isSingleObject(), 
+                            ReachTuple.ARITY_ZEROORMORE,
+                            false );
+    }
+    
+    ReachTuple h2 = 
+      ReachTuple.factory( hrn2.getID(),
+                          !hrn2.isSingleObject(),
+                          ReachTuple.ARITY_ONE,
+                          false );
+
+    ReachTuple h2star = null;
+    if( !hrn2.isSingleObject() ) {    
+      h2star =
+        ReachTuple.factory( hrn2.getID(), 
+                            !hrn2.isSingleObject(),
+                            ReachTuple.ARITY_ZEROORMORE,
+                            false );
+    }
 
-       public Set<HeapRegionNode> mayReachSharedObjects(FlatMethod fm,
-                       Integer paramIndex1, Integer paramIndex2) {
+    // then get the merged beta of all out-going edges from these heap
+    // regions
 
-               // get parameter's heap regions
-               TempDescriptor paramTemp1 = fm.getParameter(paramIndex1.intValue());
-               VariableNode argVar1 = getVariableNodeFromTemp(paramTemp1);
-               RefEdge argEdge1 = argVar1.iteratorToReferencees().next();
-               HeapRegionNode hrnParam1 = argEdge1.getDst();
+    ReachSet beta1 = ReachSet.factory();
+    Iterator<RefEdge> itrEdge = hrn1.iteratorToReferencees();
+    while (itrEdge.hasNext()) {
+      RefEdge edge = itrEdge.next();
+      beta1 = Canonical.unionORpreds(beta1, edge.getBeta());
+    }
 
-               TempDescriptor paramTemp2 = fm.getParameter(paramIndex2.intValue());
-               VariableNode argVar2 = getVariableNodeFromTemp(paramTemp2);
-               RefEdge argEdge2 = argVar2.iteratorToReferencees().next();
-               HeapRegionNode hrnParam2 = argEdge2.getDst();
+    ReachSet beta2 = ReachSet.factory();
+    itrEdge = hrn2.iteratorToReferencees();
+    while (itrEdge.hasNext()) {
+      RefEdge edge = itrEdge.next();
+      beta2 = Canonical.unionORpreds(beta2, edge.getBeta());
+    }
 
-               Set<HeapRegionNode> common = new HashSet<HeapRegionNode>();
-               common.addAll(mayReachSharedObjects(hrnParam1, hrnParam2));
+    ReachSet proofOfSharing = ReachSet.factory();
 
-               return common;
-       }
+    proofOfSharing = 
+      Canonical.unionORpreds( proofOfSharing,
+                              beta1.getStatesWithBoth( h1, h2 )
+                              );
+    proofOfSharing = 
+      Canonical.unionORpreds( proofOfSharing,
+                              beta2.getStatesWithBoth( h1, h2 )
+                              );
+    
+    if( !hrn1.isSingleObject() ) {    
+      proofOfSharing = 
+        Canonical.unionORpreds( proofOfSharing,
+                                beta1.getStatesWithBoth( h1star, h2 )
+                                );
+      proofOfSharing = 
+        Canonical.unionORpreds( proofOfSharing,
+                                beta2.getStatesWithBoth( h1star, h2 )
+                                );      
+    }
 
-       public Set<HeapRegionNode> mayReachSharedObjects(FlatMethod fm,
-                       Integer paramIndex, AllocSite as) {
+    if( !hrn2.isSingleObject() ) {    
+      proofOfSharing = 
+        Canonical.unionORpreds( proofOfSharing,
+                                beta1.getStatesWithBoth( h1, h2star )
+                                );
+      proofOfSharing = 
+        Canonical.unionORpreds( proofOfSharing,
+                                beta2.getStatesWithBoth( h1, h2star )
+                                );
+    }
 
-               // get parameter's heap regions
-               TempDescriptor paramTemp = fm.getParameter(paramIndex.intValue());
-               VariableNode argVar = getVariableNodeFromTemp(paramTemp);
-               RefEdge argEdge = argVar.iteratorToReferencees().next();
-               HeapRegionNode hrnParam = argEdge.getDst();
+    if( !hrn1.isSingleObject() &&
+        !hrn2.isSingleObject()
+        ) {    
+      proofOfSharing = 
+        Canonical.unionORpreds( proofOfSharing,
+                                beta1.getStatesWithBoth( h1star, h2star )
+                                );
+      proofOfSharing = 
+        Canonical.unionORpreds( proofOfSharing,
+                                beta2.getStatesWithBoth( h1star, h2star )
+                                );
+    }
+    
+    Set<HeapRegionNode> common = new HashSet<HeapRegionNode>();
+    if( !proofOfSharing.isEmpty() ) {
+      common = findCommonReachableNodes( proofOfSharing );
+      if( !DISABLE_STRONG_UPDATES &&
+          !DISABLE_GLOBAL_SWEEP
+          ) {        
+        assert !common.isEmpty();
+      }
+    }
 
-               // get summary node
-               HeapRegionNode hrnSummary=null;
-               if(id2hrn.containsKey(as.getSummary())){
-                       // if summary node doesn't exist, ignore this case
-                       hrnSummary = id2hrn.get(as.getSummary());
-                       assert hrnSummary != null;
-               }
+    return common;
+  }
 
-               Set<HeapRegionNode> common  = new HashSet<HeapRegionNode>();
-               if(hrnSummary!=null){
-                       common.addAll( mayReachSharedObjects(hrnParam, hrnSummary) );
-               }
+  // this version of the above method checks whether there is sharing
+  // among the objects in a summary node
+  public Set<HeapRegionNode> mayReachSharedObjects(HeapRegionNode hrn) {
+    assert hrn != null;
+    assert hrn.isNewSummary();
+    assert !hrn.isOutOfContext();
+    assert belongsToThis( hrn );
 
-               // check for other nodes
-               for (int i = 0; i < as.getAllocationDepth(); ++i) {
+    ReachTuple hstar =  
+      ReachTuple.factory( hrn.getID(), 
+                          true,    // multi
+                          ReachTuple.ARITY_ZEROORMORE,
+                          false ); // ooc    
 
-                       assert id2hrn.containsKey(as.getIthOldest(i));
-                       HeapRegionNode hrnIthOldest = id2hrn.get(as.getIthOldest(i));
-                       assert hrnIthOldest != null;
+    // then get the merged beta of all out-going edges from 
+    // this heap region
 
-                       common.addAll(mayReachSharedObjects(hrnParam, hrnIthOldest));
+    ReachSet beta = ReachSet.factory();
+    Iterator<RefEdge> itrEdge = hrn.iteratorToReferencees();
+    while (itrEdge.hasNext()) {
+      RefEdge edge = itrEdge.next();
+      beta = Canonical.unionORpreds(beta, edge.getBeta());
+    }
+    
+    ReachSet proofOfSharing = ReachSet.factory();
 
-               }
+    proofOfSharing = 
+      Canonical.unionORpreds( proofOfSharing,
+                              beta.getStatesWithBoth( hstar, hstar )
+                              );
+    
+    Set<HeapRegionNode> common = new HashSet<HeapRegionNode>();
+    if( !proofOfSharing.isEmpty() ) {
+      common = findCommonReachableNodes( proofOfSharing );
+      if( !DISABLE_STRONG_UPDATES &&
+          !DISABLE_GLOBAL_SWEEP
+          ) {        
+        assert !common.isEmpty();
+      }
+    }
+    
+    return common;
+  }
 
-               return common;
-       }
 
-       public Set<HeapRegionNode> mayReachSharedObjects(AllocSite as1,
-                       AllocSite as2) {
-
-               // get summary node 1's alpha
-               Integer idSum1 = as1.getSummary();
-               HeapRegionNode hrnSum1=null;
-               if(id2hrn.containsKey(idSum1)){
-                       hrnSum1 = id2hrn.get(idSum1);
-               }
-
-               // get summary node 2's alpha
-               Integer idSum2 = as2.getSummary();
-               HeapRegionNode hrnSum2=null;
-               if(id2hrn.containsKey(idSum2)){
-                       hrnSum2 = id2hrn.get(idSum2);
-               }
+  public Set<HeapRegionNode> mayReachSharedObjects(FlatMethod fm,
+                                                   Integer paramIndex1, 
+                                                   Integer paramIndex2) {
+
+    // get parameter's heap regions
+    TempDescriptor paramTemp1 = fm.getParameter(paramIndex1.intValue());
+    assert this.hasVariable( paramTemp1 );
+    VariableNode paramVar1 = getVariableNodeFromTemp(paramTemp1);
+
+
+    if( !(paramVar1.getNumReferencees() == 1) ) {
+      System.out.println( "\n  fm="+fm+"\n  param="+paramTemp1 );
+      writeGraph( "whatup" );
+    }
+
+
+    assert paramVar1.getNumReferencees() == 1;
+    RefEdge paramEdge1 = paramVar1.iteratorToReferencees().next();
+    HeapRegionNode hrnParam1 = paramEdge1.getDst();
+
+    TempDescriptor paramTemp2 = fm.getParameter(paramIndex2.intValue());
+    assert this.hasVariable( paramTemp2 );
+    VariableNode paramVar2 = getVariableNodeFromTemp(paramTemp2);
+
+    if( !(paramVar2.getNumReferencees() == 1) ) {
+      System.out.println( "\n  fm="+fm+"\n  param="+paramTemp2 );
+      writeGraph( "whatup" );
+    }
+
+    assert paramVar2.getNumReferencees() == 1;
+    RefEdge paramEdge2 = paramVar2.iteratorToReferencees().next();
+    HeapRegionNode hrnParam2 = paramEdge2.getDst();
+
+    Set<HeapRegionNode> common = new HashSet<HeapRegionNode>();
+    common.addAll(mayReachSharedObjects(hrnParam1, hrnParam2));
+
+    return common;
+  }
+
+  public Set<HeapRegionNode> mayReachSharedObjects(FlatMethod fm,
+                                                   Integer paramIndex, 
+                                                   AllocSite as) {
+
+    // get parameter's heap regions
+    TempDescriptor paramTemp = fm.getParameter(paramIndex.intValue());
+    assert this.hasVariable( paramTemp );
+    VariableNode paramVar = getVariableNodeFromTemp(paramTemp);
+    assert paramVar.getNumReferencees() == 1;
+    RefEdge paramEdge = paramVar.iteratorToReferencees().next();
+    HeapRegionNode hrnParam = paramEdge.getDst();
+
+    // get summary node
+    HeapRegionNode hrnSummary=null;
+    if(id2hrn.containsKey(as.getSummary())){
+      // if summary node doesn't exist, ignore this case
+      hrnSummary = id2hrn.get(as.getSummary());
+      assert hrnSummary != null;
+    }
+
+    Set<HeapRegionNode> common  = new HashSet<HeapRegionNode>();
+    if(hrnSummary!=null){
+      common.addAll( mayReachSharedObjects(hrnParam, hrnSummary) );
+    }
+
+    // check for other nodes
+    for (int i = 0; i < as.getAllocationDepth(); ++i) {
+
+      assert id2hrn.containsKey(as.getIthOldest(i));
+      HeapRegionNode hrnIthOldest = id2hrn.get(as.getIthOldest(i));
+      assert hrnIthOldest != null;
+
+      common.addAll(mayReachSharedObjects(hrnParam, hrnIthOldest));
+
+    }
+
+    return common;
+  }
+
+  public Set<HeapRegionNode> mayReachSharedObjects(AllocSite as1,
+                                                   AllocSite as2) {
+
+    // get summary node 1's alpha
+    Integer idSum1 = as1.getSummary();
+    HeapRegionNode hrnSum1=null;
+    if(id2hrn.containsKey(idSum1)){
+      hrnSum1 = id2hrn.get(idSum1);
+    }
+
+    // get summary node 2's alpha
+    Integer idSum2 = as2.getSummary();
+    HeapRegionNode hrnSum2=null;
+    if(id2hrn.containsKey(idSum2)){
+      hrnSum2 = id2hrn.get(idSum2);
+    }
                
-               Set<HeapRegionNode> common = new HashSet<HeapRegionNode>();
-               if(hrnSum1!=null && hrnSum2!=null){
-                       common.addAll(mayReachSharedObjects(hrnSum1, hrnSum2));
-               }
-
-               // check sum2 against alloc1 nodes
-               if(hrnSum2!=null){
-               for (int i = 0; i < as1.getAllocationDepth(); ++i) {
-                       Integer idI1 = as1.getIthOldest(i);
-                       assert id2hrn.containsKey(idI1);
-                       HeapRegionNode hrnI1 = id2hrn.get(idI1);
-                       assert hrnI1 != null;
-                       common.addAll(mayReachSharedObjects(hrnI1, hrnSum2));
-               }
-               }
-
-               // check sum1 against alloc2 nodes
-               for (int i = 0; i < as2.getAllocationDepth(); ++i) {
-                       Integer idI2 = as2.getIthOldest(i);
-                       assert id2hrn.containsKey(idI2);
-                       HeapRegionNode hrnI2 = id2hrn.get(idI2);
-                       assert hrnI2 != null;
-
-                       if(hrnSum1!=null){
-                               common.addAll(mayReachSharedObjects(hrnSum1, hrnI2));
-                       }
-
-                       // while we're at it, do an inner loop for alloc2 vs alloc1 nodes
-                       for (int j = 0; j < as1.getAllocationDepth(); ++j) {
-                               Integer idI1 = as1.getIthOldest(j);
-
-                               // 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.equals(idI2)) {
-                                       continue;
-                               }
-
-                               HeapRegionNode hrnI1 = id2hrn.get(idI1);
-
-                               common.addAll(mayReachSharedObjects(hrnI1, hrnI2));
-                       }
-               }
-
-               return common;
-       }
-  
+    Set<HeapRegionNode> common = new HashSet<HeapRegionNode>();
+    if(hrnSum1!=null && hrnSum2!=null && hrnSum1!=hrnSum2){
+      common.addAll(mayReachSharedObjects(hrnSum1, hrnSum2));
+    }
+
+    if(hrnSum1!=null){
+      // ask if objects from this summary share among each other
+      common.addAll(mayReachSharedObjects(hrnSum1));
+    }
+
+    // check sum2 against alloc1 nodes
+    if(hrnSum2!=null){
+      for (int i = 0; i < as1.getAllocationDepth(); ++i) {
+        Integer idI1 = as1.getIthOldest(i);
+        assert id2hrn.containsKey(idI1);
+        HeapRegionNode hrnI1 = id2hrn.get(idI1);
+        assert hrnI1 != null;
+        common.addAll(mayReachSharedObjects(hrnI1, hrnSum2));
+      }
+
+      // also ask if objects from this summary share among each other
+      common.addAll(mayReachSharedObjects(hrnSum2));
+    }
+
+    // check sum1 against alloc2 nodes
+    for (int i = 0; i < as2.getAllocationDepth(); ++i) {
+      Integer idI2 = as2.getIthOldest(i);
+      assert id2hrn.containsKey(idI2);
+      HeapRegionNode hrnI2 = id2hrn.get(idI2);
+      assert hrnI2 != null;
+
+      if(hrnSum1!=null){
+        common.addAll(mayReachSharedObjects(hrnSum1, hrnI2));
+      }
+
+      // while we're at it, do an inner loop for alloc2 vs alloc1 nodes
+      for (int j = 0; j < as1.getAllocationDepth(); ++j) {
+        Integer idI1 = as1.getIthOldest(j);
+
+        // 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.equals(idI2)) {
+          continue;
+        }
+
+        HeapRegionNode hrnI1 = id2hrn.get(idI1);
+
+        common.addAll(mayReachSharedObjects(hrnI1, hrnI2));
+      }
+    }
+
+    return common;
+  }  
 }