From: jjenista Date: Thu, 5 Mar 2009 18:24:29 +0000 (+0000) Subject: fix bug in alias reporting for Java programs X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=b962aeb29c4425047004e92df65254cd78b74436;p=IRC.git fix bug in alias reporting for Java programs --- diff --git a/Robust/src/Analysis/OwnershipAnalysis/OwnershipAnalysis.java b/Robust/src/Analysis/OwnershipAnalysis/OwnershipAnalysis.java index c555150d..7d6670a8 100644 --- a/Robust/src/Analysis/OwnershipAnalysis/OwnershipAnalysis.java +++ b/Robust/src/Analysis/OwnershipAnalysis/OwnershipAnalysis.java @@ -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 getFlaggedAllocationSites(Descriptor d) { + private HashSet getFlaggedAllocationSites(Descriptor dIn) { - HashSet out = new HashSet(); - - HashSet asSet = getAllocationSiteSet(d); - Iterator asItr = asSet.iterator(); - while( asItr.hasNext() ) { - AllocationSite as = (AllocationSite) asItr.next(); - if( as.getDisjointId() != null ) { - out.add(as); + HashSet out = new HashSet(); + HashSet toVisit = new HashSet(); + HashSet visited = new HashSet(); + + toVisit.add(dIn); + + while( !toVisit.isEmpty() ) { + Descriptor d = toVisit.iterator().next(); + toVisit.remove(d); + visited.add(d); + + HashSet 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); + } + } } } diff --git a/Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java b/Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java index c94ade99..5eb1c843 100644 --- a/Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java +++ b/Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java @@ -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; }