From: jjenista Date: Fri, 29 Aug 2008 23:24:00 +0000 (+0000) Subject: Prune edges by field name and type when mapping from callee to caller X-Git-Tag: buildscript^6~73 X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=9d4a4204068e8af346683f96d29322fb6f804a9a;hp=0f8fae95905ca691e13b065d163982184ffd160f;p=IRC.git Prune edges by field name and type when mapping from callee to caller --- diff --git a/Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java b/Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java index ff8e20c9..72cc326b 100644 --- a/Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java +++ b/Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java @@ -1280,31 +1280,60 @@ public class OwnershipGraph { edgeNewInCallerTemplate.applyBetaNew(); - // So now make a set of possible source heaps in the caller graph // and a set of destination heaps in the caller graph, and make // a reference edge in the caller for every possible (src,dst) pair HashSet possibleCallerSrcs = getHRNSetThatPossiblyMapToCalleeHRN(ogCallee, (HeapRegionNode) edgeCallee.getSrc(), - true, paramIndex2reachableCallerNodes); HashSet possibleCallerDsts = getHRNSetThatPossiblyMapToCalleeHRN(ogCallee, edgeCallee.getDst(), - false, paramIndex2reachableCallerNodes); + // make every possible pair of {srcSet} -> {dstSet} edges in the caller Iterator srcItr = possibleCallerSrcs.iterator(); while( srcItr.hasNext() ) { HeapRegionNode src = (HeapRegionNode) srcItr.next(); + // check that if this source node has a definite type that + // it also has the appropriate field, otherwise prune this + AllocationSite asSrc = src.getAllocationSite(); + if( asSrc != null ) { + boolean foundField = false; + Iterator fieldsSrcItr = asSrc.getType().getClassDesc().getFields(); + while( fieldsSrcItr.hasNext() ) { + FieldDescriptor fd = (FieldDescriptor) fieldsSrcItr.next(); + if( fd == edgeCallee.getFieldDesc() ) { + foundField = true; + break; + } + } + if( !foundField ) { + // prune this source node possibility + continue; + } + } + Iterator dstItr = possibleCallerDsts.iterator(); while( dstItr.hasNext() ) { HeapRegionNode dst = (HeapRegionNode) dstItr.next(); + // check if this dst node has a definite type and + // if it matches the callee edge + AllocationSite asDst = dst.getAllocationSite(); + if( asDst != null && edgeCallee.getFieldDesc() != null ) { + if( asDst.getType() == null && edgeCallee.getFieldDesc().getType() != null ) { continue; } + if( asDst.getType() != null && edgeCallee.getFieldDesc().getType() == null ) { continue; } + if( asDst.getType() != null && edgeCallee.getFieldDesc().getType() != null ) { + if( !asDst.getType().equals( edgeCallee.getFieldDesc().getType() ) ) { continue; } + } + } + + // otherwise the caller src and dst pair can match the edge, so make it ReferenceEdge edgeNewInCaller = edgeNewInCallerTemplate.copy(); edgeNewInCaller.setSrc(src); edgeNewInCaller.setDst(dst); @@ -1358,13 +1387,26 @@ public class OwnershipGraph { HashSet assignCallerRhs = getHRNSetThatPossiblyMapToCalleeHRN(ogCallee, edgeCallee.getDst(), - false, paramIndex2reachableCallerNodes); Iterator itrHrn = assignCallerRhs.iterator(); while( itrHrn.hasNext() ) { HeapRegionNode hrnCaller = itrHrn.next(); + // check if this dst node has a definite type and + // if it matches the callee edge + // check if this dst node has a definite type and + // if it matches the callee edge + AllocationSite asDst = hrnCaller.getAllocationSite(); + if( asDst != null && edgeCallee.getFieldDesc() != null ) { + if( asDst.getType() == null && edgeCallee.getFieldDesc().getType() != null ) { continue; } + if( asDst.getType() != null && edgeCallee.getFieldDesc().getType() == null ) { continue; } + if( asDst.getType() != null && edgeCallee.getFieldDesc().getType() != null ) { + if( !asDst.getType().equals( edgeCallee.getFieldDesc().getType() ) ) { continue; } + } + } + + // otherwise caller node can match callee edge, so make it ReferenceEdge edgeNewInCaller = edgeNewInCallerTemplate.copy(); edgeNewInCaller.setSrc(lnLhsCaller); edgeNewInCaller.setDst(hrnCaller); @@ -1672,7 +1714,6 @@ public class OwnershipGraph { private HashSet getHRNSetThatPossiblyMapToCalleeHRN(OwnershipGraph ogCallee, HeapRegionNode hrnCallee, - boolean mapFromSrc, Hashtable > paramIndex2reachableCallerNodes ) { @@ -1712,8 +1753,6 @@ public class OwnershipGraph { // so it maps to a whole mess of heap regions assert paramIndex2reachableCallerNodes.containsKey(paramIndexCallee); possibleCallerHRNs = paramIndex2reachableCallerNodes.get(paramIndexCallee); - - // TODO PRUNE BY TYPE/FIELD NAME!! } return possibleCallerHRNs; diff --git a/Robust/src/Tests/OwnershipAnalysisTest/test01/test01.java b/Robust/src/Tests/OwnershipAnalysisTest/test01/test01.java index a432b914..3a5396b8 100644 --- a/Robust/src/Tests/OwnershipAnalysisTest/test01/test01.java +++ b/Robust/src/Tests/OwnershipAnalysisTest/test01/test01.java @@ -1,8 +1,10 @@ -/* + public class Parameter { flag w; - int a, b; - Parameter f, g; + int a; + int b; + Parameter f; + Parameter g; Penguin p; Foo h; @@ -13,7 +15,8 @@ public class Parameter { } public class Penguin { - int x, y; + int x; + int y; Foo h; public Penguin() { x = 0; y = 0; } @@ -46,17 +49,6 @@ public class Baw { public void doTheBaw( Voo v ) { v = new Voo(); } } -*/ - - -task ObjectChainByMethodCalls( Foo a{ f } ) { - - Foo f = a.getAFoo(); - Foo g = a.newFooChain( f ); - // g -> f - - taskexit( a{ !f } ); -} public class Foo { @@ -67,7 +59,7 @@ public class Foo { public Foo x; public Foo y; public Foo z; - + public Baw b; public Foo getAFoo() { return new Foo(); @@ -339,8 +331,19 @@ task strongUpdates( Foo p0{ f } ) { taskexit( p0{ !f } ); } + + +task ObjectChainByMethodCalls( Foo a{ f } ) { + + Foo f = a.getAFoo(); + Foo g = a.newFooChain( f ); + // g -> f + + taskexit( a{ !f } ); +} */ +/* task arrayAssignments( Foo a{ f } ) { Foo f[] = new Foo[3]; @@ -355,6 +358,31 @@ task arrayAssignments( Foo a{ f } ) { taskexit( a{ !f } ); } +*/ + +public class Zool { + public Zool() {} + + public static void FooToBaw( Baw x, Foo y ) { + x.f.b = y.b; + } +} + +task showPrunedEdgesInMethodCall( Foo a{ f } ) { + + Foo b = new Foo(); + b.x = a; + b.y = new Foo(); + b.b = new Baw(); + + Baw c = new Baw(); + c.f = new Foo(); + c.f.b = new Baw(); + + Zool.FooToBaw( c, b ); + + taskexit( a{ !f } ); +} /* task methodTest( Foo p0{ f } ) {