From: yeom Date: Sat, 27 Oct 2012 05:25:09 +0000 (+0000) Subject: changes. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=30c0c69af4e45824aae96fb417663da1567d1b64;p=IRC.git changes. --- diff --git a/Robust/src/Analysis/SSJava/BuildLattice.java b/Robust/src/Analysis/SSJava/BuildLattice.java index 2df41320..fdf3d89d 100644 --- a/Robust/src/Analysis/SSJava/BuildLattice.java +++ b/Robust/src/Analysis/SSJava/BuildLattice.java @@ -13,9 +13,11 @@ import Util.Pair; public class BuildLattice { private LocationInference infer; + private Map mapSharedNodeToTripleItem; public BuildLattice(LocationInference infer) { this.infer = infer; + this.mapSharedNodeToTripleItem = new HashMap(); } public SSJavaLattice buildLattice(Descriptor desc) { @@ -144,6 +146,8 @@ public class BuildLattice { // perform DFS that starts from each skeleton/combination node and ends by another // skeleton/combination node + mapSharedNodeToTripleItem.clear(); + HierarchyGraph simpleGraph = infer.getSimpleHierarchyGraph(desc); HierarchyGraph scGraph = infer.getSkeletonCombinationHierarchyGraph(desc); LocationSummary locSummary = infer.getLocationSummary(desc); @@ -249,10 +253,64 @@ public class BuildLattice { } } + // add shared locations + Set sharedNodeSet = mapSharedNodeToTripleItem.keySet(); + for (Iterator iterator = sharedNodeSet.iterator(); iterator.hasNext();) { + HNode sharedNode = (HNode) iterator.next(); + TripleItem item = mapSharedNodeToTripleItem.get(sharedNode); + String nonSharedLocName = mapIntermediateLoc.get(item); + System.out.println("sharedNode=" + sharedNode + " locName=" + nonSharedLocName); + + String newLocName; + if (locSummary.getHNodeNameSetByLatticeLoationName(nonSharedLocName) != null + && !lattice.isSharedLoc(nonSharedLocName)) { + // need to generate a new shared location in the lattice, which is one level lower than the + // 'locName' location + newLocName = "ILOC" + (LocationInference.locSeed++); + + // Set aboveElementSet = getAboveElementSet(lattice, locName); + Set belowElementSet = new HashSet(); + belowElementSet.addAll(lattice.get(nonSharedLocName)); + + System.out.println("nonSharedLocName=" + nonSharedLocName + " belowElementSet=" + + belowElementSet + " newLocName=" + newLocName); + + lattice.insertNewLocationBetween(nonSharedLocName, belowElementSet, newLocName); + } else { + newLocName = nonSharedLocName; + } + + lattice.addSharedLoc(newLocName); + HierarchyGraph graph = infer.getSimpleHierarchyGraph(desc); + Set descSet = graph.getDescSetOfNode(sharedNode); + for (Iterator iterator2 = descSet.iterator(); iterator2.hasNext();) { + Descriptor d = (Descriptor) iterator2.next(); + locSummary.addMapHNodeNameToLocationName(d.getSymbol(), newLocName); + } + locSummary.addMapHNodeNameToLocationName(sharedNode.getName(), newLocName); + + } + return lattice; } + private Set getAboveElementSet(SSJavaLattice lattice, String loc) { + + Set aboveSet = new HashSet(); + + Map> latticeMap = lattice.getTable(); + Set keySet = latticeMap.keySet(); + for (Iterator iterator = keySet.iterator(); iterator.hasNext();) { + String key = (String) iterator.next(); + if (latticeMap.get(key).contains(loc)) { + aboveSet.add(key); + } + } + + return aboveSet; + } + private void expandCombinationNode(Descriptor desc, SSJavaLattice lattice, Set visited, Map mapIntermediateLoc, LocationSummary locSummary, HNode cnode) { @@ -442,22 +500,23 @@ public class BuildLattice { } String locName = mapIntermediateLoc.get(item); - HierarchyGraph graph = infer.getSimpleHierarchyGraph(desc); - Set descSet = graph.getDescSetOfNode(curNode); - for (Iterator iterator = descSet.iterator(); iterator.hasNext();) { - Descriptor d = (Descriptor) iterator.next(); - locSummary.addMapHNodeNameToLocationName(d.getSymbol(), locName); - } - locSummary.addMapHNodeNameToLocationName(curNode.getName(), locName); - if (curNode.isSharedNode()) { - lattice.addSharedLoc(locName); + // if the current node is shared location, add a shared location to the lattice later + mapSharedNodeToTripleItem.put(curNode, item); + } else { + Set descSet = graph.getDescSetOfNode(curNode); + for (Iterator iterator = descSet.iterator(); iterator.hasNext();) { + Descriptor d = (Descriptor) iterator.next(); + locSummary.addMapHNodeNameToLocationName(d.getSymbol(), locName); + } + locSummary.addMapHNodeNameToLocationName(curNode.getName(), locName); } System.out.println("-TripleItem=" + item); - System.out.println("-curNode=" + curNode.getName() + " locName=" + locName); + System.out.println("-curNode=" + curNode.getName() + " S=" + curNode.isSharedNode() + + " locName=" + locName); Set outSet = graph.getOutgoingNodeSet(curNode); for (Iterator iterator2 = outSet.iterator(); iterator2.hasNext();) { @@ -498,23 +557,33 @@ public class BuildLattice { } lattice.insertNewLocationBetween(above, belowSet, newLocName); mapIntermediateLoc.put(item, newLocName); - } } + // TODO + // Do we need to skip the combination node and assign a shared location to the next node? + // if (idx == 1 && curNode.isSharedNode()) { + // System.out.println("THE FIRST COMBINATION NODE EXPANSION IS SHARED!"); + // recurDFS(desc, lattice, combinationNodeInSCGraph, endNodeSet, visited, mapIntermediateLoc, + // idx + 1, locSummary, curNode); + // return; + // } + HierarchyGraph graph = infer.getSimpleHierarchyGraph(desc); String locName = mapIntermediateLoc.get(item); - Set descSet = graph.getDescSetOfNode(curNode); - for (Iterator iterator = descSet.iterator(); iterator.hasNext();) { - Descriptor d = (Descriptor) iterator.next(); - locSummary.addMapHNodeNameToLocationName(d.getSymbol(), locName); - } - locSummary.addMapHNodeNameToLocationName(curNode.getName(), locName); - if (curNode.isSharedNode()) { - lattice.addSharedLoc(locName); + // if the current node is shared location, add a shared location to the lattice later + mapSharedNodeToTripleItem.put(curNode, item); + } else { + Set descSet = graph.getDescSetOfNode(curNode); + for (Iterator iterator = descSet.iterator(); iterator.hasNext();) { + Descriptor d = (Descriptor) iterator.next(); + locSummary.addMapHNodeNameToLocationName(d.getSymbol(), locName); + } + locSummary.addMapHNodeNameToLocationName(curNode.getName(), locName); } + System.out.println("-TripleItem=" + item); System.out.println("-curNode=" + curNode.getName() + " S=" + curNode.isSharedNode() + " locName=" + locName); @@ -713,11 +782,21 @@ class TripleItem { public HNode higherNode; public Set lowerNodeSet; public int idx; + public boolean isShared; public TripleItem(HNode h, Set l, int i) { higherNode = h; lowerNodeSet = l; idx = i; + isShared = false; + } + + public void setShared(boolean in) { + this.isShared = in; + } + + public boolean isShared() { + return isShared; } public int hashCode() { @@ -727,6 +806,10 @@ class TripleItem { h = higherNode.hashCode(); } + if (isShared) { + h++; + } + return h + lowerNodeSet.hashCode() + idx; } @@ -735,7 +818,7 @@ class TripleItem { if (obj instanceof TripleItem) { TripleItem in = (TripleItem) obj; if ((higherNode == null || (higherNode != null && higherNode.equals(in.higherNode))) - && lowerNodeSet.equals(in.lowerNodeSet) && idx == in.idx) { + && lowerNodeSet.equals(in.lowerNodeSet) && idx == in.idx && isShared == in.isShared()) { return true; } } @@ -744,6 +827,10 @@ class TripleItem { } public String toString() { - return higherNode + "-" + idx + "->" + lowerNodeSet; + String rtr = higherNode + "-" + idx + "->" + lowerNodeSet; + if (isShared) { + rtr += " S"; + } + return rtr; } } diff --git a/Robust/src/Analysis/SSJava/FlowDownCheck.java b/Robust/src/Analysis/SSJava/FlowDownCheck.java index 8d699e9b..eb7cf77b 100644 --- a/Robust/src/Analysis/SSJava/FlowDownCheck.java +++ b/Robust/src/Analysis/SSJava/FlowDownCheck.java @@ -707,7 +707,7 @@ public class FlowDownCheck { private CompositeLocation checkLocationFromIfStatementNode(MethodDescriptor md, SymbolTable nametable, IfStatementNode isn, CompositeLocation constraint) { - System.out.println("checkLocationFromIfStatementNode=" + isn); + System.out.println("\n\ncheckLocationFromIfStatementNode=" + isn.printNode(0)); CompositeLocation condLoc = checkLocationFromExpressionNode(md, nametable, isn.getCondition(), new CompositeLocation(), constraint, false); @@ -1367,16 +1367,17 @@ public class FlowDownCheck { SymbolTable nametable, ArrayAccessNode aan, CompositeLocation constraint, boolean isLHS) { System.out.println("aan=" + aan.printNode(0) + " line#=" + aan.getNumLine()); ClassDescriptor cd = md.getClassDesc(); - + System.out.println("aan.getExpression()=" +aan.getExpression().getClass()); CompositeLocation arrayLoc = checkLocationFromExpressionNode(md, nametable, aan.getExpression(), new CompositeLocation(), constraint, isLHS); - +System.out.println("HERE?"); // addTypeLocation(aan.getExpression().getType(), arrayLoc); CompositeLocation indexLoc = checkLocationFromExpressionNode(md, nametable, aan.getIndex(), new CompositeLocation(), constraint, isLHS); // addTypeLocation(aan.getIndex().getType(), indexLoc); + System.out.println("HERE2?"); if (isLHS) { if (!CompositeLattice.isGreaterThan(indexLoc, arrayLoc, generateErrorMessage(cd, aan))) { @@ -1388,7 +1389,11 @@ public class FlowDownCheck { Set inputGLB = new HashSet(); inputGLB.add(arrayLoc); inputGLB.add(indexLoc); - return CompositeLattice.calculateGLB(inputGLB, generateErrorMessage(cd, aan)); + System.out.println("arrayLoc=" + arrayLoc + " indexLoc=" + indexLoc); + CompositeLocation comp = + CompositeLattice.calculateGLB(inputGLB, generateErrorMessage(cd, aan)); + System.out.println("---aan=" + aan.printNode(0) + " compLoc=" + comp); + return comp; } } @@ -1487,7 +1492,7 @@ public class FlowDownCheck { private CompositeLocation checkLocationFromNameNode(MethodDescriptor md, SymbolTable nametable, NameNode nn, CompositeLocation loc, CompositeLocation constraint) { - System.out.println("checkLocationFromNameNode nn=" + nn.printNode(0)); + // System.out.println("checkLocationFromNameNode nn=" + nn.printNode(0)); NameDescriptor nd = nn.getName(); if (nd.getBase() != null) { loc = @@ -1519,7 +1524,7 @@ public class FlowDownCheck { } else if (d instanceof FieldDescriptor) { // the type of field descriptor has a location! FieldDescriptor fd = (FieldDescriptor) d; - System.out.println("fd=" + fd); + // System.out.println("fd=" + fd); if (fd.isStatic()) { if (fd.isFinal()) { // if it is 'static final', the location has TOP since no one can @@ -1661,6 +1666,8 @@ public class FlowDownCheck { private CompositeLocation checkLocationFromAssignmentNode(MethodDescriptor md, SymbolTable nametable, AssignmentNode an, CompositeLocation loc, CompositeLocation constraint) { + System.out.println("\n\ncheckLocationFromAssignmentNode=" + an.printNode(0)); + ClassDescriptor cd = md.getClassDesc(); Set inputGLBSet = new HashSet(); @@ -1712,8 +1719,7 @@ public class FlowDownCheck { // generateErrorMessage(cd, an)); } - // System.out.println("src=" + srcLocation + " dest=" + destLocation + " const=" + - // constraint); + System.out.println("src=" + srcLocation + " dest=" + destLocation + " const=" + constraint); if (!CompositeLattice.isGreaterThan(srcLocation, destLocation, generateErrorMessage(cd, an))) { @@ -2257,7 +2263,7 @@ public class FlowDownCheck { } if (innerGLBInput.size() > 0) { - System.out.println("######innerGLBInput=" + innerGLBInput); + // System.out.println("######innerGLBInput=" + innerGLBInput); CompositeLocation innerGLB = CompositeLattice.calculateGLB(innerGLBInput, errMsg); for (int idx = 0; idx < innerGLB.getSize(); idx++) { glbCompLoc.addLocation(innerGLB.get(idx)); @@ -2280,7 +2286,7 @@ public class FlowDownCheck { } } - System.out.println("GLB=" + glbCompLoc + "\n"); + System.out.println("GLB=" + glbCompLoc); return glbCompLoc; } diff --git a/Robust/src/Analysis/SSJava/LocationInference.java b/Robust/src/Analysis/SSJava/LocationInference.java index 4f243735..a3bee185 100644 --- a/Robust/src/Analysis/SSJava/LocationInference.java +++ b/Robust/src/Analysis/SSJava/LocationInference.java @@ -1357,11 +1357,11 @@ public class LocationInference { Set incomingNodeSetPrefix = graph.getIncomingNodeSetByPrefix(node.getLocTuple().get(0)); - // System.out.println("---incomingNodeSetPrefix=" + incomingNodeSetPrefix); + System.out.println("---incomingNodeSetPrefix=" + incomingNodeSetPrefix); Set reachableNodeSetPrefix = graph.getReachableNodeSetByPrefix(node.getLocTuple().get(0)); - // System.out.println("---reachableNodeSetPrefix=" + reachableNodeSetPrefix); + System.out.println("---reachableNodeSetPrefix=" + reachableNodeSetPrefix); List> prefixList = new ArrayList>(); @@ -1772,6 +1772,7 @@ public class LocationInference { // // the type of argument is primitive. // return nodeLocTuple.clone(); // } + System.out.println("paramIdx=" + paramIdx + " argDescTuple=" + argDescTuple); NTuple argLocTuple = translateToLocTuple(mdCaller, argDescTuple); NTuple callerLocTuple = new NTuple(); @@ -2290,7 +2291,9 @@ public class LocationInference { // visit each node of method flow graph FlowGraph fg = getFlowGraph(md); - Set nodeSet = fg.getNodeSet(); + // Set nodeSet = fg.getNodeSet(); + + Set edgeSet = fg.getEdgeSet(); Set paramDescSet = fg.getMapParamDescToIdx().keySet(); for (Iterator iterator = paramDescSet.iterator(); iterator.hasNext();) { @@ -2301,9 +2304,12 @@ public class LocationInference { // for the method lattice, we need to look at the first element of // NTuple boolean hasGlobalAccess = false; - for (Iterator iterator = nodeSet.iterator(); iterator.hasNext();) { - FlowNode originalSrcNode = (FlowNode) iterator.next(); + // for (Iterator iterator = nodeSet.iterator(); iterator.hasNext();) { + // FlowNode originalSrcNode = (FlowNode) iterator.next(); + for (Iterator iterator = edgeSet.iterator(); iterator.hasNext();) { + FlowEdge edge = (FlowEdge) iterator.next(); + FlowNode originalSrcNode = fg.getFlowNode(edge.getInitTuple()); Set sourceNodeSet = new HashSet(); if (originalSrcNode instanceof FlowReturnNode) { FlowReturnNode rnode = (FlowReturnNode) originalSrcNode; @@ -2317,7 +2323,9 @@ public class LocationInference { sourceNodeSet.add(originalSrcNode); } - System.out.println("---sourceNodeSet=" + sourceNodeSet); + System.out.println("---sourceNodeSet=" + sourceNodeSet + " from originalSrcNode=" + + originalSrcNode); + for (Iterator iterator3 = sourceNodeSet.iterator(); iterator3.hasNext();) { FlowNode srcNode = (FlowNode) iterator3.next(); @@ -2338,81 +2346,86 @@ public class LocationInference { hasGlobalAccess = true; } - Set outEdgeSet = fg.getOutEdgeSet(originalSrcNode); - for (Iterator iterator2 = outEdgeSet.iterator(); iterator2.hasNext();) { - FlowEdge outEdge = (FlowEdge) iterator2.next(); - FlowNode originalDstNode = outEdge.getDst(); - - Set dstNodeSet = new HashSet(); - if (originalDstNode instanceof FlowReturnNode) { - FlowReturnNode rnode = (FlowReturnNode) originalDstNode; - System.out.println("\n-returnNode=" + rnode); - Set> tupleSet = rnode.getTupleSet(); - for (Iterator iterator4 = tupleSet.iterator(); iterator4.hasNext();) { - NTuple nTuple = (NTuple) iterator4.next(); - dstNodeSet.add(fg.getFlowNode(nTuple)); - } - } else { - dstNodeSet.add(originalDstNode); + // Set outEdgeSet = fg.getOutEdgeSet(originalSrcNode); + // for (Iterator iterator2 = outEdgeSet.iterator(); iterator2.hasNext();) { + // FlowEdge outEdge = (FlowEdge) iterator2.next(); + // FlowNode originalDstNode = outEdge.getDst(); + FlowNode originalDstNode = fg.getFlowNode(edge.getEndTuple()); + + Set dstNodeSet = new HashSet(); + if (originalDstNode instanceof FlowReturnNode) { + FlowReturnNode rnode = (FlowReturnNode) originalDstNode; + System.out.println("\n-returnNode=" + rnode); + Set> tupleSet = rnode.getTupleSet(); + for (Iterator iterator4 = tupleSet.iterator(); iterator4.hasNext();) { + NTuple nTuple = (NTuple) iterator4.next(); + dstNodeSet.add(fg.getFlowNode(nTuple)); } - System.out.println("---dstNodeSet=" + dstNodeSet); - for (Iterator iterator4 = dstNodeSet.iterator(); iterator4.hasNext();) { - FlowNode dstNode = (FlowNode) iterator4.next(); - - NTuple dstNodeTuple = dstNode.getDescTuple(); - Descriptor dstLocalDesc = dstNodeTuple.get(0); - - if (dstLocalDesc instanceof InterDescriptor - && ((InterDescriptor) dstLocalDesc).getMethodArgIdxPair() != null) { - if (dstNode.getCompositeLocation() == null) { - System.out.println("%%%%%%%%%%%%%SKIP=" + dstNode); - continue; - } + } else { + dstNodeSet.add(originalDstNode); + } + System.out.println("---dstNodeSet=" + dstNodeSet); + for (Iterator iterator4 = dstNodeSet.iterator(); iterator4.hasNext();) { + FlowNode dstNode = (FlowNode) iterator4.next(); + + NTuple dstNodeTuple = dstNode.getDescTuple(); + Descriptor dstLocalDesc = dstNodeTuple.get(0); + + if (dstLocalDesc instanceof InterDescriptor + && ((InterDescriptor) dstLocalDesc).getMethodArgIdxPair() != null) { + if (dstNode.getCompositeLocation() == null) { + System.out.println("%%%%%%%%%%%%%SKIP=" + dstNode); + continue; } + } - // if (outEdge.getInitTuple().equals(srcNodeTuple) - // && outEdge.getEndTuple().equals(dstNodeTuple)) { + // if (outEdge.getInitTuple().equals(srcNodeTuple) + // && outEdge.getEndTuple().equals(dstNodeTuple)) { - NTuple srcCurTuple = srcNode.getCurrentDescTuple(); - NTuple dstCurTuple = dstNode.getCurrentDescTuple(); + NTuple srcCurTuple = srcNode.getCurrentDescTuple(); + NTuple dstCurTuple = dstNode.getCurrentDescTuple(); - System.out.println("-srcCurTuple=" + srcCurTuple + " dstCurTuple=" + dstCurTuple); + System.out.println("-srcCurTuple=" + srcCurTuple + " dstCurTuple=" + dstCurTuple); - if ((srcCurTuple.size() > 1 && dstCurTuple.size() > 1) - && srcCurTuple.get(0).equals(dstCurTuple.get(0))) { + if ((srcCurTuple.size() > 1 && dstCurTuple.size() > 1) + && srcCurTuple.get(0).equals(dstCurTuple.get(0))) { - // value flows between fields - Descriptor desc = srcCurTuple.get(0); - ClassDescriptor classDesc; + // value flows between fields + Descriptor desc = srcCurTuple.get(0); + ClassDescriptor classDesc; - if (desc.equals(GLOBALDESC)) { - classDesc = md.getClassDesc(); - } else { - VarDescriptor varDesc = (VarDescriptor) srcCurTuple.get(0); - classDesc = varDesc.getType().getClassDesc(); - } - extractFlowsBetweenFields(classDesc, srcNode, dstNode, 1); + if (desc.equals(GLOBALDESC)) { + classDesc = md.getClassDesc(); + } else { + VarDescriptor varDesc = (VarDescriptor) srcCurTuple.get(0); + classDesc = varDesc.getType().getClassDesc(); + } + extractFlowsBetweenFields(classDesc, srcNode, dstNode, 1); - } else if (!srcCurTuple.get(0).equals(dstCurTuple.get(0))) { - // value flow between local var - local var or local var - field + } else if ((srcCurTuple.size() == 1 && dstCurTuple.size() == 1) + || ((srcCurTuple.size() > 1 || dstCurTuple.size() > 1) && !srcCurTuple.get(0).equals( + dstCurTuple.get(0)))) { - Descriptor srcDesc = srcCurTuple.get(0); - Descriptor dstDesc = dstCurTuple.get(0); + // value flow between a primitive local var - a primitive local var or local var - + // field - methodGraph.addEdge(srcDesc, dstDesc); + Descriptor srcDesc = srcCurTuple.get(0); + Descriptor dstDesc = dstCurTuple.get(0); - if (fg.isParamDesc(srcDesc)) { - methodGraph.setParamHNode(srcDesc); - } - if (fg.isParamDesc(dstDesc)) { - methodGraph.setParamHNode(dstDesc); - } + methodGraph.addEdge(srcDesc, dstDesc); + if (fg.isParamDesc(srcDesc)) { + methodGraph.setParamHNode(srcDesc); + } + if (fg.isParamDesc(dstDesc)) { + methodGraph.setParamHNode(dstDesc); } - // } } + // } + // } + } } @@ -3841,8 +3854,10 @@ public class LocationInference { Descriptor srcFieldDesc = srcCurTuple.get(idx); Descriptor dstFieldDesc = dstCurTuple.get(idx); - // add a new edge - getHierarchyGraph(cd).addEdge(srcFieldDesc, dstFieldDesc); + if (!srcFieldDesc.equals(dstFieldDesc)) { + // add a new edge + getHierarchyGraph(cd).addEdge(srcFieldDesc, dstFieldDesc); + } } @@ -4252,6 +4267,7 @@ public class LocationInference { } } if (size > 1) { + System.out.println("needToGenerateInterLoc=" + tupleSet + " size=" + size); return true; } else { return false; @@ -4455,12 +4471,13 @@ public class LocationInference { NTuple interTuple = null; if (needToGenerateInterLoc(nodeSetRHS)) { System.out.println("3"); - interTuple = getFlowGraph(md).createIntermediateNode().getDescTuple(); } for (Iterator> iter = nodeSetRHS.iterator(); iter.hasNext();) { NTuple fromTuple = iter.next(); + System.out.println("fromTuple=" + fromTuple + " interTuple=" + interTuple + " tupleLSH=" + + tupleLHS); addFlowGraphEdge(md, fromTuple, interTuple, tupleLHS); } @@ -4586,20 +4603,47 @@ public class LocationInference { private void analyzeFlowTertiaryNode(MethodDescriptor md, SymbolTable nametable, TertiaryNode tn, NodeTupleSet nodeSet, NodeTupleSet implicitFlowTupleSet) { + System.out.println("analyzeFlowTertiaryNode=" + tn.printNode(0)); + NodeTupleSet tertiaryTupleNode = new NodeTupleSet(); analyzeFlowExpressionNode(md, nametable, tn.getCond(), tertiaryTupleNode, null, implicitFlowTupleSet, false); + NodeTupleSet newImplicitTupleSet = new NodeTupleSet(); + newImplicitTupleSet.addTupleSet(implicitFlowTupleSet); + newImplicitTupleSet.addTupleSet(tertiaryTupleNode); + + System.out.println("$$$GGGcondTupleNode=" + tertiaryTupleNode.getGlobalLocTupleSet()); + System.out.println("-tertiaryTupleNode=" + tertiaryTupleNode); + System.out.println("-implicitFlowTupleSet=" + implicitFlowTupleSet); + System.out.println("-newImplicitTupleSet=" + newImplicitTupleSet); + + if (needToGenerateInterLoc(newImplicitTupleSet)) { + System.out.println("15"); + // need to create an intermediate node for the GLB of conditional locations & implicit flows + NTuple interTuple = getFlowGraph(md).createIntermediateNode().getDescTuple(); + for (Iterator> idxIter = newImplicitTupleSet.iterator(); idxIter.hasNext();) { + NTuple tuple = idxIter.next(); + addFlowGraphEdge(md, tuple, interTuple); + } + newImplicitTupleSet.clear(); + newImplicitTupleSet.addTuple(interTuple); + } + + newImplicitTupleSet.addGlobalFlowTupleSet(tertiaryTupleNode.getGlobalLocTupleSet()); + // add edges from tertiaryTupleNode to all nodes of conditional nodes - tertiaryTupleNode.addTupleSet(implicitFlowTupleSet); + // tertiaryTupleNode.addTupleSet(implicitFlowTupleSet); analyzeFlowExpressionNode(md, nametable, tn.getTrueExpr(), tertiaryTupleNode, null, - implicitFlowTupleSet, false); + newImplicitTupleSet, false); analyzeFlowExpressionNode(md, nametable, tn.getFalseExpr(), tertiaryTupleNode, null, - implicitFlowTupleSet, false); + newImplicitTupleSet, false); + nodeSet.addGlobalFlowTupleSet(tertiaryTupleNode.getGlobalLocTupleSet()); nodeSet.addTupleSet(tertiaryTupleNode); + System.out.println("#tertiary node set=" + nodeSet); } private void addMapCallerMethodDescToMethodInvokeNodeSet(MethodDescriptor caller, @@ -4681,16 +4725,6 @@ public class LocationInference { System.out.println("---calleeReturnSet=" + calleeReturnSet); - // when generating the global flow graph, - // we need to add ordering relations from the set of callee return loc tuple to LHS of the - // caller assignment - for (Iterator iterator = calleeReturnSet.iterator(); iterator.hasNext();) { - FlowNode calleeReturnNode = (FlowNode) iterator.next(); - NTuple calleeReturnLocTuple = - translateToLocTuple(mdCallee, calleeReturnNode.getDescTuple()); - nodeSet.addGlobalFlowTuple(calleeReturnLocTuple); - } - NodeTupleSet tupleSet = new NodeTupleSet(); if (min.getExpression() != null) { @@ -4804,7 +4838,20 @@ public class LocationInference { // propagateFlowsFromCallee(min, md, min.getMethod()); + // when generating the global flow graph, + // we need to add ordering relations from the set of callee return loc tuple to LHS of the + // caller assignment + for (Iterator iterator = calleeReturnSet.iterator(); iterator.hasNext();) { + FlowNode calleeReturnNode = (FlowNode) iterator.next(); + NTuple calleeReturnLocTuple = + translateToLocTuple(mdCallee, calleeReturnNode.getDescTuple()); + System.out.println("calleeReturnLocTuple=" + calleeReturnLocTuple); + nodeSet.addGlobalFlowTuple(translateToCallerLocTuple(min, mdCallee, mdCaller, + calleeReturnLocTuple)); + } + System.out.println("min nodeSet=" + nodeSet); + } } @@ -5189,12 +5236,13 @@ public class LocationInference { nodeSetArrayAccessExp.addTuple(flowFieldTuple); nodeSetArrayAccessExp.addTupleSet(idxNodeTupleSet); + nodeSetArrayAccessExp.addTupleSet(nodeSet); if (needToGenerateInterLoc(nodeSetArrayAccessExp)) { System.out.println("4"); System.out.println("nodeSetArrayAccessExp=" + nodeSetArrayAccessExp); - System.out.println("idxNodeTupleSet.getGlobalLocTupleSet()=" - + idxNodeTupleSet.getGlobalLocTupleSet()); + // System.out.println("idxNodeTupleSet.getGlobalLocTupleSet()=" + // + idxNodeTupleSet.getGlobalLocTupleSet()); NTuple interTuple = getFlowGraph(md).createIntermediateNode().getDescTuple(); @@ -5204,6 +5252,7 @@ public class LocationInference { NTuple higherTuple = iter.next(); addFlowGraphEdge(md, higherTuple, interTuple); } + nodeSet.clear(); flowFieldTuple = interTuple; } @@ -5380,6 +5429,8 @@ public class LocationInference { public void writeInferredLatticeDotFile(ClassDescriptor cd, HierarchyGraph simpleHierarchyGraph, SSJavaLattice locOrder, String nameSuffix) { + System.out.println("@cd=" + cd); + System.out.println("@sharedLoc=" + locOrder.getSharedLocSet()); writeInferredLatticeDotFile(cd, null, simpleHierarchyGraph, locOrder, nameSuffix); } @@ -5412,7 +5463,7 @@ public class LocationInference { String highLocId = pair.getFirst(); String lowLocId = pair.getSecond(); - + System.out.println("addedLocSet=" + addedLocSet); if (!addedLocSet.contains(highLocId)) { addedLocSet.add(highLocId); drawNode(bw, locOrder, simpleHierarchyGraph, highLocId); @@ -5452,23 +5503,17 @@ public class LocationInference { private void drawNode(BufferedWriter bw, SSJavaLattice lattice, HierarchyGraph graph, String locName) throws IOException { - HNode node = graph.getHNode(locName); - - if (node == null) { - return; - } - String prettyStr; if (lattice.isSharedLoc(locName)) { prettyStr = locName + "*"; } else { prettyStr = locName; } - - if (node.isMergeNode()) { - Set mergeSet = graph.getMapHNodetoMergeSet().get(node); - prettyStr += ":" + convertMergeSetToString(graph, mergeSet); - } + // HNode node = graph.getHNode(locName); + // if (node != null && node.isMergeNode()) { + // Set mergeSet = graph.getMapHNodetoMergeSet().get(node); + // prettyStr += ":" + convertMergeSetToString(graph, mergeSet); + // } bw.write(locName + " [label=\"" + prettyStr + "\"]" + ";\n"); } diff --git a/Robust/src/Analysis/SSJava/LocationSummary.java b/Robust/src/Analysis/SSJava/LocationSummary.java index f6aefddc..e0f953a4 100644 --- a/Robust/src/Analysis/SSJava/LocationSummary.java +++ b/Robust/src/Analysis/SSJava/LocationSummary.java @@ -1,19 +1,32 @@ package Analysis.SSJava; import java.util.HashMap; +import java.util.HashSet; import java.util.Map; +import java.util.Set; public abstract class LocationSummary { Map mapHNodeNameToLocationName; + Map> mapLocationNameToHNodeNameSet; public LocationSummary() { mapHNodeNameToLocationName = new HashMap(); + mapLocationNameToHNodeNameSet = new HashMap>(); } public void addMapHNodeNameToLocationName(String nodeName, String locName) { // System.out.println("nodeName="+nodeName+" locName="+locName); mapHNodeNameToLocationName.put(nodeName, locName); + + if (!mapLocationNameToHNodeNameSet.containsKey(locName)) { + mapLocationNameToHNodeNameSet.put(locName, new HashSet()); + } + mapLocationNameToHNodeNameSet.get(locName).add(nodeName); + } + + public Set getHNodeNameSetByLatticeLoationName(String locName) { + return mapLocationNameToHNodeNameSet.get(locName); } public String getLocationName(String nodeName) {