X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=Robust%2Fsrc%2FAnalysis%2FSSJava%2FBuildLattice.java;h=2df41320b448f7dae328ff70a693ff5fdc94a8ac;hb=7701457cedb357fc5efd0170f495a22a99b18cef;hp=79c0ce9546470ffde24539f4c7a252c219328dda;hpb=2e579e40f20a086e38dff23ac2b46fdd28f6f435;p=IRC.git diff --git a/Robust/src/Analysis/SSJava/BuildLattice.java b/Robust/src/Analysis/SSJava/BuildLattice.java index 79c0ce95..2df41320 100644 --- a/Robust/src/Analysis/SSJava/BuildLattice.java +++ b/Robust/src/Analysis/SSJava/BuildLattice.java @@ -14,13 +14,8 @@ public class BuildLattice { private LocationInference infer; - private final HNode topNode; - private final HNode bottomNode; - public BuildLattice(LocationInference infer) { this.infer = infer; - topNode = new HNode(infer.ssjava.TOP); - bottomNode = new HNode(infer.ssjava.BOTTOM); } public SSJavaLattice buildLattice(Descriptor desc) { @@ -166,6 +161,7 @@ public class BuildLattice { for (Iterator iterator = nodeSet.iterator(); iterator.hasNext();) { HNode node = (HNode) iterator.next(); System.out.println("node=" + node); + if (node.isSkeleton() && (!visited.contains(node))) { visited.add(node); @@ -204,15 +200,13 @@ public class BuildLattice { visited.add(outNode); if (endCombNodeSet.size() > 0) { // follows the straight line up to another skeleton/combination node - // endCombNodeSet = removeTransitivelyReachToNode(desc, startNode, endCombNodeSet); + endCombNodeSet = removeTransitivelyReachToNode(desc, startNode, endCombNodeSet); } else if (endCombNodeSet.size() == 0) { // the outNode is (directly/transitively) connected to the bottom node // therefore, we just add a dummy bottom HNode to the endCombNodeSet. - endCombNodeSet.add(bottomNode); + endCombNodeSet.add(LocationInference.BOTTOMHNODE); } - startNode = refineStartNode(desc, startNode, endCombNodeSet); - recurDFSNormalNode(desc, lattice, startNode, endCombNodeSet, visited, mapIntermediateLoc, 1, locSummary, outNode); } @@ -226,9 +220,8 @@ public class BuildLattice { System.out.println("n=" + node); // an intermediate node 'node' may be located between "TOP" location and a skeleton node - int sizeIncomingNode = simpleGraph.getIncomingNodeSet(node).size(); + if (simpleGraph.getIncomingNodeSet(node).size() == 0) { - if (sizeIncomingNode == 0) { // this node will be directly connected to the TOP location // start adding the following nodes from this node @@ -241,7 +234,8 @@ public class BuildLattice { endCombNodeSet.add(getCombinationNodeInSCGraph(desc, endNode)); } - HNode startNode = topNode; + System.out.println("endCombNodeSet=" + endCombNodeSet); + HNode startNode = LocationInference.TOPHNODE; visited.add(startNode); if (endCombNodeSet.size() > 0) { // follows the straight line up to another skeleton/combination node @@ -263,6 +257,7 @@ public class BuildLattice { Set visited, Map mapIntermediateLoc, LocationSummary locSummary, HNode cnode) { + System.out.println("expandCombinationNode=" + cnode); // expand the combination node 'outNode' // here we need to expand the corresponding combination location in the lattice HNode combinationNodeInSCGraph = getCombinationNodeInSCGraph(desc, cnode); @@ -291,18 +286,16 @@ public class BuildLattice { // follows the straight line up to another skeleton/combination node if (endCombNodeSet.size() > 0) { System.out.println("---endCombNodeSet=" + endCombNodeSet); - // endCombNodeSet = - // removeTransitivelyReachToNode(desc, combinationNodeInSCGraph, endCombNodeSet); - - combinationNodeInSCGraph = refineStartNode(desc, combinationNodeInSCGraph, endCombNodeSet); + endCombNodeSet = + removeTransitivelyReachToNode(desc, combinationNodeInSCGraph, endCombNodeSet); recurDFS(desc, lattice, combinationNodeInSCGraph, endCombNodeSet, visited, mapIntermediateLoc, 1, locSummary, cnode); } else { - endCombNodeSet.add(bottomNode); - System.out.println("---endCombNodeSet is zero"); - System.out.println("---endNodeSetFromSimpleGraph=" + endNodeSetFromSimpleGraph); - System.out.println("---incoming=" + simpleGraph.getIncomingNodeSet(cnode)); + endCombNodeSet.add(LocationInference.BOTTOMHNODE); + // System.out.println("---endCombNodeSet is zero"); + // System.out.println("---endNodeSetFromSimpleGraph=" + endNodeSetFromSimpleGraph); + // System.out.println("---incoming=" + simpleGraph.getIncomingNodeSet(cnode)); recurDFS(desc, lattice, combinationNodeInSCGraph, endCombNodeSet, visited, mapIntermediateLoc, 1, locSummary, cnode); @@ -310,19 +303,6 @@ public class BuildLattice { } - private HNode refineStartNode(Descriptor desc, HNode startNode, Set endNodeSet) { - - HierarchyGraph scGraph = infer.getSkeletonCombinationHierarchyGraph(desc); - - HNode newStartNode = getDirectlyReachableSCNodeFromEndNode(scGraph, startNode, endNodeSet); - - System.out.println("---removeTransitivelyReachToNode2 startNode=" + startNode + " old=" - + endNodeSet + " newStartNode=" + newStartNode); - - return newStartNode; - - } - private Set removeTransitivelyReachToNode(Descriptor desc, HNode startNode, Set endNodeSet) { @@ -448,9 +428,14 @@ public class BuildLattice { Set belowSet = new HashSet(); for (Iterator iterator = endNodeSet.iterator(); iterator.hasNext();) { HNode endNode = (HNode) iterator.next(); - belowSet.add(endNode.getName()); + String locName; + if (locSummary.getMapHNodeNameToLocationName().containsKey(endNode.getName())) { + locName = locSummary.getLocationName(endNode.getName()); + } else { + locName = endNode.getName(); + } + belowSet.add(locName); } - lattice.insertNewLocationBetween(above, belowSet, newLocName); mapIntermediateLoc.put(item, newLocName); @@ -527,18 +512,32 @@ public class BuildLattice { } locSummary.addMapHNodeNameToLocationName(curNode.getName(), locName); - // System.out.println("-TripleItem=" + item); - // System.out.println("-curNode=" + curNode.getName() + " locName=" + locName); + if (curNode.isSharedNode()) { + lattice.addSharedLoc(locName); + } + System.out.println("-TripleItem=" + item); + System.out.println("-curNode=" + curNode.getName() + " S=" + curNode.isSharedNode() + + " locName=" + locName); Set outSet = graph.getOutgoingNodeSet(curNode); for (Iterator iterator2 = outSet.iterator(); iterator2.hasNext();) { HNode outNode = (HNode) iterator2.next(); + // System.out.println("recurDFS outNode=" + outNode); + // System.out.println("---cur combinationNodeInSCGraph=" + combinationNodeInSCGraph); + // System.out.println("---outNode combinationNodeInSCGraph=" + // + getCombinationNodeInSCGraph(desc, outNode)); if (!outNode.isSkeleton() && !visited.contains(outNode)) { - if (combinationNodeInSCGraph.equals(getCombinationNodeInSCGraph(desc, outNode))) { - visited.add(outNode); - recurDFS(desc, lattice, combinationNodeInSCGraph, endNodeSet, visited, - mapIntermediateLoc, idx + 1, locSummary, outNode); + if (outNode.isCombinationNode()) { + // check whether the next combination node is different from the current node + if (combinationNodeInSCGraph.equals(getCombinationNodeInSCGraph(desc, outNode))) { + visited.add(outNode); + recurDFS(desc, lattice, combinationNodeInSCGraph, endNodeSet, visited, + mapIntermediateLoc, idx + 1, locSummary, outNode); + } else { + expandCombinationNode(desc, lattice, visited, mapIntermediateLoc, locSummary, outNode); + } } + } }