From 48446ecf795430f413580840103ad6d78541f216 Mon Sep 17 00:00:00 2001 From: yeom Date: Mon, 12 Oct 2009 18:59:48 +0000 Subject: [PATCH] bug fix. --- Robust/src/Analysis/MLP/MLPAnalysis.java | 85 ++++++++++++++---------- 1 file changed, 49 insertions(+), 36 deletions(-) diff --git a/Robust/src/Analysis/MLP/MLPAnalysis.java b/Robust/src/Analysis/MLP/MLPAnalysis.java index e646ec6b..b41e3c49 100644 --- a/Robust/src/Analysis/MLP/MLPAnalysis.java +++ b/Robust/src/Analysis/MLP/MLPAnalysis.java @@ -816,7 +816,7 @@ public class MLPAnalysis { private void debugFunction(OwnershipAnalysis oa2, FlatMethod fm) { - String methodName="doSomeWork"; + String methodName="SomeWork"; MethodDescriptor md=fm.getMethod(); HashSet mcSet=oa2.getAllMethodContextSetByDescriptor(md); @@ -829,7 +829,7 @@ public class MLPAnalysis { if(fm.toString().indexOf(methodName)>0){ try { - og.writeGraph(methodName + "SECONDGRAPH", true, true, true, true, false); + og.writeGraph(fm.toString() + "SECONDGRAPH", true, true, true, true, false); } catch (IOException e) { System.out.println("Error writing debug capture."); System.exit(0); @@ -885,44 +885,50 @@ public class MLPAnalysis { } private void analyzeRelatedAllocationSite(MethodDescriptor callerMD, - MethodContext calleeMC, HashSet paramIndexSet) { + MethodContext calleeMC, HashSet paramIndexSet, + HashSet visitedHRN) { HashSet mcSet = ownAnalysis .getAllMethodContextSetByDescriptor(callerMD); - Iterator mcIter = mcSet.iterator(); - FlatMethod callerFM = state.getMethodFlat(callerMD); + if (mcSet != null) { - while (mcIter.hasNext()) { - MethodContext mc = mcIter.next(); + Iterator mcIter = mcSet.iterator(); - Set visited = new HashSet(); - Set flatNodesToVisit = new HashSet(); - flatNodesToVisit.add(callerFM); + FlatMethod callerFM = state.getMethodFlat(callerMD); - while (!flatNodesToVisit.isEmpty()) { - FlatNode fn = (FlatNode) flatNodesToVisit.iterator().next(); - flatNodesToVisit.remove(fn); + while (mcIter.hasNext()) { + MethodContext mc = mcIter.next(); - analyzeRelatedAllocationSite_NodeAction(fn, mc, calleeMC, paramIndexSet); + Set visited = new HashSet(); + Set flatNodesToVisit = new HashSet(); + flatNodesToVisit.add(callerFM); - flatNodesToVisit.remove(fn); - visited.add(fn); + while (!flatNodesToVisit.isEmpty()) { + FlatNode fn = (FlatNode) flatNodesToVisit.iterator().next(); + flatNodesToVisit.remove(fn); - for (int i = 0; i < fn.numNext(); i++) { - FlatNode nn = fn.getNext(i); - if (!visited.contains(nn)) { - flatNodesToVisit.add(nn); + analyzeRelatedAllocationSite_NodeAction(fn, mc, calleeMC, + paramIndexSet,visitedHRN); + + flatNodesToVisit.remove(fn); + visited.add(fn); + + for (int i = 0; i < fn.numNext(); i++) { + FlatNode nn = fn.getNext(i); + if (!visited.contains(nn)) { + flatNodesToVisit.add(nn); + } } } } - } } private void analyzeRelatedAllocationSite_NodeAction(FlatNode fn, MethodContext callerMC, - MethodContext calleeMC, HashSet paramIndexSet) { + MethodContext calleeMC, + HashSet paramIndexSet, HashSet visitedHRN) { OwnershipGraph og = ownAnalysis .getOwnvershipGraphByMethodContext(callerMC); @@ -944,15 +950,16 @@ public class MLPAnalysis { } else { base = 1; } - + for (Iterator iterator = paramIndexSet.iterator(); iterator .hasNext();) { Integer integer = (Integer) iterator.next(); - - int paramIdx=integer-base; - if(paramIdx>=0){ - // if paramIdx is less than 0, assumes that it is related with wrong method contexts. - TempDescriptor arg = fc.getArg(paramIdx ); + + int paramIdx = integer - base; + if (paramIdx >= 0) { + // if paramIdx is less than 0, assumes that it is + // related with wrong method contexts. + TempDescriptor arg = fc.getArg(paramIdx); LabelNode argLN = og.td2ln.get(arg); if (argLN != null) { Iterator iterEdge = argLN @@ -960,11 +967,14 @@ public class MLPAnalysis { while (iterEdge.hasNext()) { ReferenceEdge referenceEdge = (ReferenceEdge) iterEdge .next(); - - HeapRegionNode dstHRN=referenceEdge.getDst(); - if(dstHRN.isParameter()){ - setupRelatedAllocSiteAnalysis(og,callerMC,dstHRN); - }else{ + + HeapRegionNode dstHRN = referenceEdge.getDst(); + if (dstHRN.isParameter()) { + if(!visitedHRN.contains(dstHRN)){ + setupRelatedAllocSiteAnalysis(og, callerMC, + dstHRN, visitedHRN); + } + } else { addLiveInAllocationSite(callerMC, dstHRN .getAllocationSite()); } @@ -981,7 +991,8 @@ public class MLPAnalysis { } private void setupRelatedAllocSiteAnalysis(OwnershipGraph og, - MethodContext mc, HeapRegionNode dstHRN) { + MethodContext mc, HeapRegionNode dstHRN, + HashSet visitedHRN) { HashSet paramIndexSet = new HashSet(); @@ -1011,7 +1022,7 @@ public class MLPAnalysis { if (obj instanceof MethodDescriptor) { MethodDescriptor callerMD = (MethodDescriptor) obj; - analyzeRelatedAllocationSite(callerMD, mc, paramIndexSet); + analyzeRelatedAllocationSite(callerMD, mc, paramIndexSet,visitedHRN); } } @@ -1050,7 +1061,9 @@ public class MLPAnalysis { HeapRegionNode dstHRN = referenceEdge.getDst(); if (dstHRN.isParameter()) { - setupRelatedAllocSiteAnalysis(og,mc,dstHRN); + HashSet visitedHRN=new HashSet(); + visitedHRN.add(dstHRN); + setupRelatedAllocSiteAnalysis(og,mc,dstHRN,visitedHRN); } else { addLiveInAllocationSite(mc, dstHRN -- 2.34.1