From 5b08d8a1dc1163ea71c34e0cf22316d9b5e8902d Mon Sep 17 00:00:00 2001 From: yeom Date: Mon, 11 Jul 2011 22:26:43 +0000 Subject: [PATCH] fix a bug introducing redundant method entries for analysis --- .../SSJava/DefinitelyWrittenCheck.java | 32 ++++++++----------- 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/Robust/src/Analysis/SSJava/DefinitelyWrittenCheck.java b/Robust/src/Analysis/SSJava/DefinitelyWrittenCheck.java index 0689d6bc..750f97a2 100644 --- a/Robust/src/Analysis/SSJava/DefinitelyWrittenCheck.java +++ b/Robust/src/Analysis/SSJava/DefinitelyWrittenCheck.java @@ -162,16 +162,13 @@ public class DefinitelyWrittenCheck { computeReadSharedDescriptorSet(); System.out.println("Reading Shared Location=" + mapSharedLocation2DescriptorSet); - Set methodDescriptorToVistSet = new HashSet(); - methodDescriptorsToVisitStack.clear(); + methodDescriptorsToVisitStack.add(sortedDescriptors.peekFirst()); - methodDescriptorToVistSet.add(sortedDescriptors.peekFirst()); // analyze scheduled methods until there are no more to visit while (!methodDescriptorsToVisitStack.isEmpty()) { MethodDescriptor md = methodDescriptorsToVisitStack.pop(); - methodDescriptorToVistSet.remove(md); Hashtable, SharedLocState> completeSummary = sharedLocation_analyzeMethod(md, (md.equals(methodContainingSSJavaLoop))); @@ -183,18 +180,12 @@ public class DefinitelyWrittenCheck { mapMethodDescriptorToCompleteClearingSummary.put(md, completeSummary); - Set dependentsSet = getDependents(md); - if (dependentsSet.size() == 0) { - dependentsSet.add(methodContainingSSJavaLoop); - } - // results for callee changed, so enqueue dependents caller for // further analysis Iterator depsItr = getDependents(md).iterator(); while (depsItr.hasNext()) { MethodDescriptor methodNext = depsItr.next(); - if (!methodDescriptorsToVisitStack.contains(methodNext) - && !methodDescriptorToVistSet.contains(methodNext)) { + if (!methodDescriptorsToVisitStack.contains(methodNext)) { methodDescriptorsToVisitStack.add(methodNext); } } @@ -204,7 +195,9 @@ public class DefinitelyWrittenCheck { Iterator calleeIter = calleesToEnqueue.iterator(); while (calleeIter.hasNext()) { MethodDescriptor mdNext = calleeIter.next(); - methodDescriptorsToVisitStack.add(mdNext); + if (!methodDescriptorsToVisitStack.contains(mdNext)) { + methodDescriptorsToVisitStack.add(mdNext); + } } calleesToEnqueue.clear(); @@ -212,9 +205,6 @@ public class DefinitelyWrittenCheck { } - Set flatNodesToVisit = new HashSet(); - flatNodesToVisit.add(ssjavaLoopEntrance); - } private Hashtable, SharedLocState> sharedLocation_analyzeMethod( @@ -260,7 +250,7 @@ public class DefinitelyWrittenCheck { } mergeSharedLocationAnaylsis(curr, prevSet); - sharedLocation_nodeActions(fn, curr, returnNodeSet, onlyVisitSSJavaLoop); + sharedLocation_nodeActions(md, fn, curr, returnNodeSet, onlyVisitSSJavaLoop); Hashtable, SharedLocState> clearingPrev = mapFlatNodeToClearingSummary.get(fn); @@ -310,7 +300,7 @@ public class DefinitelyWrittenCheck { return completeSummary; } - private void sharedLocation_nodeActions(FlatNode fn, + private void sharedLocation_nodeActions(MethodDescriptor caller, FlatNode fn, Hashtable, SharedLocState> curr, Set returnNodeSet, boolean isSSJavaLoop) { @@ -408,6 +398,9 @@ public class DefinitelyWrittenCheck { MethodDescriptor mdPossibleCallee = (MethodDescriptor) iterator.next(); FlatMethod calleeFlatMethod = state.getMethodFlat(mdPossibleCallee); + addDependent(mdPossibleCallee, // callee + caller); // caller + calleesToEnqueue.add(mdPossibleCallee); // updates possible callee's initial summary using caller's current @@ -421,7 +414,10 @@ public class DefinitelyWrittenCheck { // if changes, update the init summary // and reschedule the callee for analysis if (!calleeInitSummary.equals(prevCalleeInitSummary)) { - methodDescriptorsToVisitStack.add(mdPossibleCallee); + + if (!methodDescriptorsToVisitStack.contains(mdPossibleCallee)) { + methodDescriptorsToVisitStack.add(mdPossibleCallee); + } mapMethodDescriptorToInitialClearingSummary.put(mdPossibleCallee, calleeInitSummary); } -- 2.34.1