From: yeom Date: Fri, 10 Aug 2012 01:50:41 +0000 (+0000) Subject: changes. X-Git-Url: http://plrg.eecs.uci.edu/git/?p=IRC.git;a=commitdiff_plain;h=8252b9bcfa61b6a2692c193483e950739fbe5a05 changes. --- diff --git a/Robust/src/Analysis/SSJava/LocationInference.java b/Robust/src/Analysis/SSJava/LocationInference.java index ed447903..d28772bb 100644 --- a/Robust/src/Analysis/SSJava/LocationInference.java +++ b/Robust/src/Analysis/SSJava/LocationInference.java @@ -274,7 +274,7 @@ public class LocationInference { // dependency in the call graph methodDescriptorsToVisitStack.clear(); - descriptorListToAnalyze.removeFirst(); + // descriptorListToAnalyze.removeFirst(); Set methodDescriptorToVistSet = new HashSet(); methodDescriptorToVistSet.addAll(descriptorListToAnalyze); @@ -690,7 +690,9 @@ public class LocationInference { CompositeLocation inferLoc1 = generateInferredCompositeLocation(methodInfo, tuple1); CompositeLocation inferLoc2 = generateInferredCompositeLocation(methodInfo, tuple2); - addRelation(methodLattice, methodInfo, inferLoc1, inferLoc2); + // addRelation(methodLattice, methodInfo, inferLoc1, inferLoc2); + + addFlowGraphEdge(mdCaller, argDescTuple1, argDescTuple2); } @@ -750,7 +752,8 @@ public class LocationInference { private void addRelation(SSJavaLattice methodLattice, MethodLocationInfo methodInfo, CompositeLocation srcInferLoc, CompositeLocation dstInferLoc) throws CyclicFlowException { - System.out.println("--- srcInferLoc=" + srcInferLoc + " dstInferLoc=" + dstInferLoc); + System.out.println("addRelation --- srcInferLoc=" + srcInferLoc + " dstInferLoc=" + + dstInferLoc); String srcLocalLocSymbol = srcInferLoc.get(0).getLocIdentifier(); String dstLocalLocSymbol = dstInferLoc.get(0).getLocIdentifier(); @@ -1036,42 +1039,67 @@ public class LocationInference { Location fieldLoc = new Location(desc, newLocSymbol); newInferLocation.addLocation(fieldLoc); - NTuple locTuple = flowGraph.getLocationTuple(flowNode); - for (int tidx = 1; tidx < locTuple.size(); tidx++) { - Location cur = locTuple.get(tidx); - Descriptor enclosingDesc = cur.getDescriptor(); - Descriptor curDesc = cur.getLocDescriptor(); - Location inferLocElement; - if (curDesc == null) { - // in this case, we have a newly generated location. - inferLocElement = new Location(enclosingDesc, cur.getLocIdentifier()); - } else { - String fieldLocSymbol = - getLocationInfo(enclosingDesc).getInferLocation(curDesc).get(0) - .getLocIdentifier(); - inferLocElement = new Location(enclosingDesc, fieldLocSymbol); - inferLocElement.setLocDescriptor(curDesc); - } - newInferLocation.addLocation(inferLocElement); + if (flowNode.getDescTuple().size() == 1) { + // maps local variable to location types of the common prefix + methodInfo.mapDescriptorToLocation(localVarDesc, newInferLocation.clone()); } - methodInfo.mapDescriptorToLocation(localVarDesc, newInferLocation); + // methodInfo.mapDescriptorToLocation(localVarDesc, newInferLocation); addMapLocSymbolToInferredLocation(methodInfo.getMethodDesc(), localVarDesc, newInferLocation); methodInfo.removeMaplocalVarToLocSet(localVarDesc); + // add the field/var descriptor to the set of the location symbol + int flowNodeTupleSize = flowNode.getDescTuple().size(); + Descriptor lastFlowNodeDesc = flowNode.getDescTuple().get(flowNodeTupleSize - 1); + int inferLocSize = newInferLocation.getSize(); + Location lastLoc = newInferLocation.get(inferLocSize - 1); + Descriptor enclosingDesc = lastLoc.getDescriptor(); + getLocationInfo(enclosingDesc).addMapLocSymbolToDescSet(lastLoc.getLocIdentifier(), + lastFlowNodeDesc); + + // clean up the previous location + // Location prevInferLocElement = + // inferLocation.get(inferLocation.getSize() - 1); + // Descriptor prevEnclosingDesc = prevInferLocElement.getDescriptor(); + // + // SSJavaLattice targetLattice; + // LocationInfo targetInfo; + // if (prevEnclosingDesc.equals(methodInfo.getMethodDesc())) { + // targetLattice = methodLattice; + // targetInfo = methodInfo; + // } else { + // targetLattice = getLattice(prevInferLocElement.getDescriptor()); + // targetInfo = getLocationInfo(prevInferLocElement.getDescriptor()); + // } + // + // Set> associstedDescSet = + // targetInfo.getRelatedInferLocSet(prevInferLocElement.getLocIdentifier()); + // + // if (associstedDescSet.size() == 1) { + // targetLattice.remove(prevInferLocElement.getLocIdentifier()); + // } else { + // associstedDescSet.remove(lastFlowNodeDesc); + // } + } + System.out.println("ASSIGN NEW COMPOSITE LOCATION =" + newInferLocation + " to " + + flowNode); + String newlyInsertedLocName = - newInferLocation.get(inferLocation.getSize() - 1).getLocIdentifier(); + newInferLocation.get(newInferLocation.getSize() - 1).getLocIdentifier(); + System.out.println("-- add in-flow"); for (Iterator iterator = incomingCommonPrefixSet.iterator(); iterator.hasNext();) { NTuple tuple = (NTuple) iterator.next(); + System.out.println("--in-flow tuple=" + tuple); Location loc = tuple.get(idx); String higher = locInfo.getFieldInferLocation(loc.getLocDescriptor()).getLocIdentifier(); addRelationHigherToLower(lattice, locInfo, higher, newlyInsertedLocName); } + System.out.println("-- add local in-flow"); for (Iterator iterator = localInNodeSet.iterator(); iterator.hasNext();) { FlowNode localNode = (FlowNode) iterator.next(); @@ -1093,6 +1121,7 @@ public class LocationInference { } + System.out.println("-- add out flow"); for (Iterator iterator = reachableCommonPrefixSet.iterator(); iterator.hasNext();) { NTuple tuple = (NTuple) iterator.next(); if (tuple.size() > idx) { @@ -1102,6 +1131,7 @@ public class LocationInference { } } + System.out.println("-- add local out flow"); for (Iterator iterator = localOutNodeSet.iterator(); iterator.hasNext();) { FlowNode localOutNode = (FlowNode) iterator.next(); @@ -1122,6 +1152,7 @@ public class LocationInference { } } + System.out.println("-- end of add local out flow"); return true; } @@ -1168,6 +1199,8 @@ public class LocationInference { private void addRelationHigherToLower(SSJavaLattice lattice, LocationInfo locInfo, String higher, String lower) throws CyclicFlowException { + System.out.println("---addRelationHigherToLower " + higher + " -> " + lower + + " to the lattice of " + locInfo.getDescIdentifier()); // if (higher.equals(lower) && lattice.isSharedLoc(higher)) { // return; // } @@ -1196,14 +1229,14 @@ public class LocationInference { String newSharedLoc = "SharedLoc" + (SSJavaLattice.seed++); - System.out.println("$$$ASSIGN NEW SHARED LOC=" + newSharedLoc + " to " + cycleElementSet); + System.out.println("---ASSIGN NEW SHARED LOC=" + newSharedLoc + " to " + cycleElementSet); lattice.mergeIntoSharedLocation(cycleElementSet, newSharedLoc); for (Iterator iterator = cycleElementSet.iterator(); iterator.hasNext();) { String oldLocSymbol = (String) iterator.next(); Set> inferLocSet = locInfo.getRelatedInferLocSet(oldLocSymbol); - System.out.println("$$$update related locations=" + inferLocSet); + System.out.println("---update related locations=" + inferLocSet); for (Iterator iterator2 = inferLocSet.iterator(); iterator2.hasNext();) { Pair pair = (Pair) iterator2.next(); Descriptor enclosingDesc = pair.getFirst(); @@ -1226,7 +1259,7 @@ public class LocationInference { } else { inferLoc = getLocationInfo(enclosingDesc).getInferLocation(desc); } - System.out.println("$$$New Infer Loc=" + inferLoc); + System.out.println("---New Infer Loc=" + inferLoc); } locInfo.removeRelatedInferLocSet(oldLocSymbol, newSharedLoc); @@ -1597,7 +1630,8 @@ public class LocationInference { switch (en.kind()) { case Kind.AssignmentNode: - analyzeFlowAssignmentNode(md, nametable, (AssignmentNode) en, base, implicitFlowTupleSet); + analyzeFlowAssignmentNode(md, nametable, (AssignmentNode) en, nodeSet, base, + implicitFlowTupleSet); break; case Kind.FieldAccessNode: @@ -2061,7 +2095,8 @@ public class LocationInference { } private void analyzeFlowAssignmentNode(MethodDescriptor md, SymbolTable nametable, - AssignmentNode an, NTuple base, NodeTupleSet implicitFlowTupleSet) { + AssignmentNode an, NodeTupleSet nodeSet, NTuple base, + NodeTupleSet implicitFlowTupleSet) { NodeTupleSet nodeSetRHS = new NodeTupleSet(); NodeTupleSet nodeSetLHS = new NodeTupleSet(); @@ -2135,6 +2170,9 @@ public class LocationInference { } + if (nodeSet != null) { + nodeSet.addTupleSet(nodeSetLHS); + } } public FlowGraph getFlowGraph(MethodDescriptor md) { diff --git a/Robust/src/Analysis/SSJava/LocationInfo.java b/Robust/src/Analysis/SSJava/LocationInfo.java index 048f5cf1..12f8d38b 100644 --- a/Robust/src/Analysis/SSJava/LocationInfo.java +++ b/Robust/src/Analysis/SSJava/LocationInfo.java @@ -2,7 +2,6 @@ package Analysis.SSJava; import java.util.HashMap; import java.util.HashSet; -import java.util.Iterator; import java.util.Map; import java.util.Set; @@ -30,6 +29,15 @@ public class LocationInfo { this.cd = cd; } + public Descriptor getDescIdentifier() { + if (md != null) { + return md; + } + { + return cd; + } + } + public Map> getMapLocSymbolToDescSet() { return mapLocSymbolToDescSet; } @@ -97,6 +105,7 @@ public class LocationInfo { public void removeRelatedInferLocSet(String oldLocSymbol, String newSharedLoc) { Set descSet = getDescSet(oldLocSymbol); getDescSet(newSharedLoc).addAll(descSet); + // getRelatedInferLocSet(newSharedLoc).addAll(getRelatedInferLocSet(oldLocSymbol)); mapLocSymbolToDescSet.remove(oldLocSymbol); mapLocSymbolToRelatedInferLocSet.remove(oldLocSymbol); } diff --git a/Robust/src/Analysis/SSJava/SSJavaLattice.java b/Robust/src/Analysis/SSJava/SSJavaLattice.java index c7b89709..89ca9af5 100644 --- a/Robust/src/Analysis/SSJava/SSJavaLattice.java +++ b/Robust/src/Analysis/SSJava/SSJavaLattice.java @@ -91,6 +91,7 @@ public class SSJavaLattice extends Lattice { getInBetweenElements(cur, end, elementSet); } } + System.out.println(" start=" + start + " end=" + end + " element=" + elementSet); } public void mergeIntoSharedLocation(Set cycleSet, T newLoc) { @@ -149,6 +150,34 @@ public class SSJavaLattice extends Lattice { } + public void remove(T loc) { + + Set keySet = getKeySet(); + + Set inSet = new HashSet(); + for (Iterator iterator = keySet.iterator(); iterator.hasNext();) { + T keyElement = (T) iterator.next(); + Set connectedSet = get(keyElement); + if (connectedSet.contains(loc)) { + inSet.add(loc); + connectedSet.remove(loc); + } + } + + Set outSet = get(loc); + + for (Iterator iterator = inSet.iterator(); iterator.hasNext();) { + T in = (T) iterator.next(); + for (Iterator iterator2 = outSet.iterator(); iterator2.hasNext();) { + T out = (T) iterator2.next(); + put(in, out); + } + } + + getTable().remove(loc); + + } + public void substituteLocation(T oldLoc, T newLoc) { // the new location is going to take all relations of the old location if (!getKeySet().contains(newLoc)) {