From: jjenista Date: Wed, 17 Mar 2010 18:27:58 +0000 (+0000) Subject: was accidentally dropping param var to node edges when constructing callee initial... X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=bcfe0fb3c5afa48741d72bdb8e1ddcbe8a4b8371;p=IRC.git was accidentally dropping param var to node edges when constructing callee initial heaps --- diff --git a/Robust/src/Analysis/Disjoint/ReachGraph.java b/Robust/src/Analysis/Disjoint/ReachGraph.java index f2dcff2a..edab79cb 100644 --- a/Robust/src/Analysis/Disjoint/ReachGraph.java +++ b/Robust/src/Analysis/Disjoint/ReachGraph.java @@ -1475,26 +1475,36 @@ public class ReachGraph { boolean writeDebugDOTs ) { + // first traverse this context to find nodes and edges // that will be callee-reachable Set reachableCallerNodes = new HashSet(); + // caller edges between callee-reachable nodes Set reachableCallerEdges = new HashSet(); + // caller edges from arg vars, and the matching param index + // because these become a special edge in callee + Hashtable reachableCallerArgEdges2paramIndex = + new Hashtable(); + + // caller edges from local vars or callee-unreachable nodes + // (out-of-context sources) to callee-reachable nodes Set oocCallerEdges = new HashSet(); + for( int i = 0; i < fmCallee.numParameters(); ++i ) { TempDescriptor tdArg = fc.getArgMatchingParamIndex( fmCallee, i ); - VariableNode vnCaller = this.getVariableNodeFromTemp( tdArg ); + VariableNode vnArgCaller = this.getVariableNodeFromTemp( tdArg ); Set toVisitInCaller = new HashSet(); Set visitedInCaller = new HashSet(); - toVisitInCaller.add( vnCaller ); + toVisitInCaller.add( vnArgCaller ); while( !toVisitInCaller.isEmpty() ) { RefSrcNode rsnCaller = toVisitInCaller.iterator().next(); @@ -1512,7 +1522,11 @@ public class ReachGraph { if( reCaller.getSrc() instanceof HeapRegionNode ) { reachableCallerEdges.add( reCaller ); } else { - oocCallerEdges.add( reCaller ); + if( rsnCaller.equals( vnArgCaller ) ) { + reachableCallerArgEdges2paramIndex.put( reCaller, i ); + } else { + oocCallerEdges.add( reCaller ); + } } if( !visitedInCaller.contains( hrnCaller ) ) { @@ -1616,6 +1630,58 @@ public class ReachGraph { ); } + // add param edges to callee graph + Iterator argEdges = + reachableCallerArgEdges2paramIndex.entrySet().iterator(); + while( argEdges.hasNext() ) { + Map.Entry me = (Map.Entry) argEdges.next(); + RefEdge reArg = (RefEdge) me.getKey(); + Integer index = (Integer) me.getValue(); + + TempDescriptor arg = fmCallee.getParameter( index ); + + VariableNode vnCallee = + rg.getVariableNodeFromTemp( arg ); + + HeapRegionNode hrnDstCaller = reArg.getDst(); + HeapRegionNode hrnDstCallee = rg.id2hrn.get( hrnDstCaller.getID() ); + assert hrnDstCallee != null; + + ExistPred pred = + ExistPred.factory( arg, + null, + hrnDstCallee.getID(), + reArg.getType(), + reArg.getField(), + null, + false ); // out-of-context + + ExistPredSet preds = + ExistPredSet.factory( pred ); + + RefEdge reCallee = + new RefEdge( vnCallee, + hrnDstCallee, + reArg.getType(), + reArg.getField(), + toCalleeContext( oocTuples, + reArg.getBeta(), // in state + null, // node pred + arg, // edge pred + null, // edge pred + hrnDstCallee.getID(), // edge pred + reArg.getType(), // edge pred + reArg.getField(), // edge pred + false ), // ooc pred + preds + ); + + rg.addRefEdge( vnCallee, + hrnDstCallee, + reCallee + ); + } + // add in-context edges to callee graph Iterator reItr = reachableCallerEdges.iterator(); while( reItr.hasNext() ) { @@ -2453,30 +2519,6 @@ public class ReachGraph { // propagate callee reachability changes to the rest // of the caller graph edges - - - /* - if( !cts.isEmpty() ) { - Iterator incidentEdgeItr = hrn.iteratorToReferencers(); - while( incidentEdgeItr.hasNext() ) { - RefEdge incidentEdge = incidentEdgeItr.next(); - - edgesForPropagation.add( incidentEdge ); - - if( edgePlannedChanges.get( incidentEdge ) == null ) { - edgePlannedChanges.put( incidentEdge, cts ); - } else { - edgePlannedChanges.put( - incidentEdge, - Canonical.union( edgePlannedChanges.get( incidentEdge ), - cts - ) - ); - } - } - } - */ - HashSet edgesUpdated = new HashSet(); propagateTokensOverEdges( edgesForPropagation, // source edges diff --git a/Robust/src/Tests/disjoint/predicateTest3/test.java b/Robust/src/Tests/disjoint/predicateTest3/test.java index c54db3ce..7bbce921 100644 --- a/Robust/src/Tests/disjoint/predicateTest3/test.java +++ b/Robust/src/Tests/disjoint/predicateTest3/test.java @@ -7,15 +7,16 @@ public class Test { static public void main( String[] args ) { - Foo top = disjoint inMain new Foo(); - Foo bot = new Foo(); + Foo top = disjoint topMain new Foo(); + Foo bot = disjoint botMain new Foo(); top.f = bot; + addSomething( bot ); } public static void addSomething( Foo x ) { - x.f = new Foo(); + x.f = disjoint added new Foo(); } public static Foo getAFoo() {