From: yeom Date: Wed, 20 Feb 2013 03:52:41 +0000 (+0000) Subject: changes. X-Git-Url: http://plrg.eecs.uci.edu/git/?p=IRC.git;a=commitdiff_plain;h=094082ca4819e86104232cd3a8010323fcac95dc changes. --- diff --git a/Robust/src/Analysis/SSJava/BuildLattice.java b/Robust/src/Analysis/SSJava/BuildLattice.java index 61a08327..2d65122a 100644 --- a/Robust/src/Analysis/SSJava/BuildLattice.java +++ b/Robust/src/Analysis/SSJava/BuildLattice.java @@ -258,7 +258,7 @@ public class BuildLattice { HNode hNode = (HNode) iterator.next(); if (!hNode.isSkeleton()) { // here we need to insert an intermediate node for the hNode - System.out.println("local node=" + hNode); + System.out.println("\n#local node=" + hNode); // 1) find the lowest node m in the lattice that is above hnode in the lattice // 2) count the number of non-shared nodes d between the hnode and the node m @@ -268,22 +268,36 @@ public class BuildLattice { if (hNode.isDirectCombinationNode()) { // this node itself is the lowest node m. it is the first node of the chain Set combineSet = hierarchyGraph.getCombineSetByCombinationNode(hNode); + + System.out.println(" # direct combine node::combineSkeletonNodeSet=" + combineSet); + SCNode = scGraph.getCombinationNode(combineSet); numNonSharedNodes = -1; } else { Set aboveSet = new HashSet(); if (hNode.isCombinationNode()) { + // the current node is a combination node Set combineSkeletonNodeSet = hierarchyGraph.getCombineSetByCombinationNode(hNode); + System.out.println(" combineSkeletonNodeSet=" + combineSkeletonNodeSet + + " combinationNode=" + scGraph.getCombinationNode(combineSkeletonNodeSet)); + scGraph.getCombinationNode(combineSkeletonNodeSet); + + System.out.println(" firstnode=" + + hierarchyGraph.getFirstNodeOfCombinationNodeChainSet(combineSkeletonNodeSet)); aboveSet.addAll(hierarchyGraph .getFirstNodeOfCombinationNodeChainSet(combineSkeletonNodeSet)); + SCNode = scGraph.getCombinationNode(combineSkeletonNodeSet); + } else { - System.out.println(" #######hierarchyGraph.getSkeleteNodeSetReachTo(" + hNode + ")=" - + hierarchyGraph.getSkeleteNodeSetReachTo(hNode)); + // the current node is not a combination node + // there is only one parent node which should be skeleton node. + System.out.println(" hierarchyGraph.getSkeleteNodeSetReachTo(" + hNode + ")=" + + hierarchyGraph.getSkeleteNodeSetReachTo(hNode)); aboveSet.addAll(hierarchyGraph.getSkeleteNodeSetReachTo(hNode)); // assert aboveSet.size() == 1; SCNode = aboveSet.iterator().next(); @@ -304,14 +318,23 @@ public class BuildLattice { // 3) convert the node m into a chain of nodes with the last node in the chain having m’s // outgoing edges. - Set outgoingElements = skeletonLattice.get(SCNode.getName()); - System.out.println(" SCNODE outgoing=" + outgoingElements); + Set outgoingSCNodeSet = scGraph.getOutgoingNodeSet(SCNode); + System.out.println(" SCNODE outgoing hnode set=" + outgoingSCNodeSet); + + Set outgoingLocNameSet = new HashSet(); + for (Iterator iterator2 = outgoingSCNodeSet.iterator(); iterator2.hasNext();) { + HNode outSCNode = (HNode) iterator2.next(); + String locName = locSummary.getLocationName(outSCNode.getName()); + System.out.println(" outSCNode=" + outSCNode + " -> locName=" + + locName); + outgoingLocNameSet.add(locName); + } // 4) If hnode is not a shared location, check if there already exists a local variable // node that has distance d below m along this chain. If such a node // does not exist, insert it. String locName = - getNewLocation(lattice, SCNode.getName(), outgoingElements, numNonSharedNodes, + getNewLocation(lattice, SCNode.getName(), outgoingLocNameSet, numNonSharedNodes, hNode.isSharedNode()); System.out.println(" locName=" + locName); locSummary.addMapHNodeNameToLocationName(hNode.getName(), locName); @@ -346,9 +369,10 @@ public class BuildLattice { if (dist == 0 && isShared) { // if the node is shared, // check if there already exists a shared node that has distance d + 1 on the chain - connectedSet = lattice.get(cur); - if (connectedSet.equals(endSet)) { + if ((cur.equals(lattice.getTopItem()) && connectedSet.containsAll(endSet)) + || connectedSet.equals(endSet)) { // need to insert a new shared location + // it is done after this if statement } else { assert connectedSet.size() == 1; String below = connectedSet.iterator().next(); @@ -358,12 +382,15 @@ public class BuildLattice { } // need to insert a new shared location + Set newChildSet = new HashSet(); + newChildSet.addAll(connectedSet); + String newLocName = "ILOC" + (LocationInference.locSeed++); - for (Iterator iterator = connectedSet.iterator(); iterator.hasNext();) { + for (Iterator iterator = newChildSet.iterator(); iterator.hasNext();) { String outNode = (String) iterator.next(); lattice.put(newLocName, outNode); } - connectedSet.clear(); + lattice.get(cur).clear(); lattice.put(cur, newLocName); System.out.println(" INSERT NEW SHARED NODE=" + newLocName + " above=" + cur @@ -376,12 +403,20 @@ public class BuildLattice { } String next; - if (connectedSet.equals(endSet)) { + + if (cur.equals(lattice.getTopItem()) || connectedSet.equals(endSet) || endSet.isEmpty()) { + + // if ( (cur.equals(lattice.getTopItem()) && connectedSet.containsAll(endSet)) + // || connectedSet.equals(endSet)) { + // need to insert a new location String newLocName = "ILOC" + (LocationInference.locSeed++); connectedSet.clear(); lattice.put(cur, newLocName); - System.out.println("NEW RELATION=" + lattice.get(cur)); + + System.out.println("#INSERT NEW RELATION cur=" + cur + " newLocName=" + newLocName + "::" + + lattice.get(cur)); + for (Iterator iterator = endSet.iterator(); iterator.hasNext();) { String endNode = (String) iterator.next(); lattice.put(newLocName, endNode); diff --git a/Robust/src/Analysis/SSJava/HierarchyGraph.java b/Robust/src/Analysis/SSJava/HierarchyGraph.java index ed82566e..4e7c4b57 100644 --- a/Robust/src/Analysis/SSJava/HierarchyGraph.java +++ b/Robust/src/Analysis/SSJava/HierarchyGraph.java @@ -17,6 +17,8 @@ public class HierarchyGraph { Descriptor desc; + boolean isSCgraph; + String name; // graph structure @@ -70,6 +72,16 @@ public class HierarchyGraph { mapNormalNodeToSCNodeReachToSet = new HashMap>(); mapCombineNodeSetToFirstNodeOfChainSet = new HashMap, Set>(); + + isSCgraph = false; + } + + public void setSCGraph(boolean in) { + isSCgraph = in; + } + + public boolean isSCGraph() { + return isSCgraph; } public Descriptor getDesc() { @@ -763,8 +775,10 @@ public class HierarchyGraph { } public HNode getCombinationNode(Set combineSet) { + assert isSCGraph(); if (!mapCombineNodeSetToCombinationNode.containsKey(combineSet)) { String name = "COMB" + (LocationInference.locSeed++); + System.out.println("-NEW COMB NODE=" + name); HNode node = new HNode(name); node.setCombinationNode(true); nodeSet.add(node); @@ -795,8 +809,36 @@ public class HierarchyGraph { HNode combinationNode = getCombinationNode(combineSet); System.out.println("--combinationNode=" + combinationNode + " combineSet=" + combineSet); - // System.out.println("--hierarchynodes=" - // + simpleHierarchyGraph.getCombinationNodeSetByCombineNodeSet(combineSet)); + System.out.println("--hierarchynodes=" + + simpleHierarchyGraph.getCombinationNodeSetByCombineNodeSet(combineSet)); + + Set simpleHNodeSet = + simpleHierarchyGraph.getCombinationNodeSetByCombineNodeSet(combineSet); + + // check whether a hnode in the simple hierarchy graph is the first node of the chain + // if all incoming combination nodes to the hnode have a different combination set from the + // hnode, it is the first node of the chain + for (Iterator iterator2 = simpleHNodeSet.iterator(); iterator2.hasNext();) { + HNode simpleHNode = (HNode) iterator2.next(); + boolean isFirstNodeOfChain = true; + Set incomingNodeSet = simpleHierarchyGraph.getIncomingNodeSet(simpleHNode); + for (Iterator iterator3 = incomingNodeSet.iterator(); iterator3.hasNext();) { + HNode inNode = (HNode) iterator3.next(); + if (inNode.isCombinationNode()) { + Set inNodeCombineSet = + simpleHierarchyGraph.getCombineSetByCombinationNode(inNode); + if (inNodeCombineSet.equals(combineSet)) { + isFirstNodeOfChain = false; + break; + } + } + } + simpleHNode.setDirectCombinationNode(isFirstNodeOfChain); + if (isFirstNodeOfChain) { + simpleHierarchyGraph.addFirstNodeOfChain(combineSet, simpleHNode); + System.out.println("IT IS THE FIRST NODE OF THE CHAIN:" + simpleHNode); + } + } // add an edge from a skeleton node to a combination node for (Iterator iterator2 = combineSet.iterator(); iterator2.hasNext();) { @@ -922,6 +964,10 @@ public class HierarchyGraph { return clone; } + public void setMapCombineNodeSetToCombinationNode(Map, HNode> in) { + mapCombineNodeSetToCombinationNode = in; + } + public Map> getMapHNodetoMergeSet() { return mapMergeNodetoMergingSet; } @@ -952,31 +998,30 @@ public class HierarchyGraph { // + tempSet); if (reachToSet.size() > 1) { // if (countSkeletonNodes(reachToSet) > 1) { - System.out.println("-node=" + node + " reachToSet=" + reachToSet); + System.out.println("\n-node=" + node + " reachToSet=" + reachToSet); System.out.println("-set combinationnode=" + node); node.setCombinationNode(true); mapCombinationNodeToCombineNodeSet.put(node, reachToSet); // check if this node is the first node of the chain - boolean isFirstNodeOfChain = false; - Set inNodeSet = getIncomingNodeSet(node); - for (Iterator iterator2 = inNodeSet.iterator(); iterator2.hasNext();) { - HNode inNode = (HNode) iterator2.next(); - if (inNode.isSkeleton()) { - isFirstNodeOfChain = true; - } else if (inNode.isCombinationNode()) { - Set inNodeReachToSet = getSkeleteNodeSetReachTo(inNode); - if (!reachToSet.equals(inNodeReachToSet)) { - isFirstNodeOfChain = true; - } - } - } - - if (isFirstNodeOfChain) { - node.setDirectCombinationNode(true); - addFirstNodeOfChain(reachToSet, node); - // System.out.println("IT IS DIRECTLY CONNECTED WITH SC NODES:" + node); - } + // boolean isFirstNodeOfChain = false; + // Set inNodeSet = getIncomingNodeSet(node); + // for (Iterator iterator2 = inNodeSet.iterator(); iterator2.hasNext();) { + // HNode inNode = (HNode) iterator2.next(); + // if (inNode.isSkeleton()) { + // isFirstNodeOfChain = true; + // } else if (inNode.isCombinationNode()) { + // Set inNodeReachToSet = getSkeleteNodeSetReachTo(inNode); + // if (!reachToSet.equals(inNodeReachToSet)) { + // isFirstNodeOfChain = true; + // } + // } + // } + // + // if (isFirstNodeOfChain) { + // node.setDirectCombinationNode(true); + // addFirstNodeOfChain(reachToSet, node); + // } } } diff --git a/Robust/src/Analysis/SSJava/LocationInference.java b/Robust/src/Analysis/SSJava/LocationInference.java index b15742f5..a19f725e 100644 --- a/Robust/src/Analysis/SSJava/LocationInference.java +++ b/Robust/src/Analysis/SSJava/LocationInference.java @@ -97,8 +97,8 @@ public class LocationInference { // map a method/class descriptor to a skeleton hierarchy graph with combination nodes private Map mapDescriptorToCombineSkeletonHierarchyGraph; - // map a descriptor to a simple lattice - private Map> mapDescriptorToSimpleLattice; + // map a descriptor to a skeleton lattice + private Map> mapDescriptorToSkeletonLattice; // map a method descriptor to the set of method invocation nodes which are // invoked by the method descriptor @@ -220,7 +220,7 @@ public class LocationInference { this.mapDescriptorToCombineSkeletonHierarchyGraph = new HashMap(); this.mapDescriptorToSimpleHierarchyGraph = new HashMap(); - this.mapDescriptorToSimpleLattice = new HashMap>(); + this.mapDescriptorToSkeletonLattice = new HashMap>(); this.mapDescToLocationSummary = new HashMap(); @@ -2549,17 +2549,17 @@ public class LocationInference { private void debug_writeLattices() { - Set keySet = mapDescriptorToSimpleLattice.keySet(); + Set keySet = mapDescriptorToSkeletonLattice.keySet(); for (Iterator iterator = keySet.iterator(); iterator.hasNext();) { Descriptor key = (Descriptor) iterator.next(); - SSJavaLattice simpleLattice = mapDescriptorToSimpleLattice.get(key); + SSJavaLattice skeletonLattice = mapDescriptorToSkeletonLattice.get(key); // HierarchyGraph simpleHierarchyGraph = getSimpleHierarchyGraph(key); HierarchyGraph scHierarchyGraph = getSkeletonCombinationHierarchyGraph(key); if (key instanceof ClassDescriptor) { - writeInferredLatticeDotFile((ClassDescriptor) key, simpleLattice, "_SIMPLE"); + writeInferredLatticeDotFile((ClassDescriptor) key, skeletonLattice, "_SKELETON"); } else if (key instanceof MethodDescriptor) { MethodDescriptor md = (MethodDescriptor) key; - writeInferredLatticeDotFile(md.getClassDesc(), md, simpleLattice, "_SIMPLE"); + writeInferredLatticeDotFile(md.getClassDesc(), md, skeletonLattice, "_SKELETON"); } LocationSummary ls = getLocationSummary(key); @@ -2603,15 +2603,16 @@ public class LocationInference { private void buildLattice(Descriptor desc) { // System.out.println("buildLattice=" + desc); - SSJavaLattice simpleLattice = buildLattice.buildLattice(desc); + SSJavaLattice skeletonLattice = buildLattice.buildLattice(desc); - addMapDescToSimpleLattice(desc, simpleLattice); + addMapDescToSkeletonLattice(desc, skeletonLattice); + // write a dot file before everything is done if (desc instanceof ClassDescriptor) { - writeInferredLatticeDotFile((ClassDescriptor) desc, null, simpleLattice, "_SC"); + writeInferredLatticeDotFile((ClassDescriptor) desc, null, skeletonLattice, "_SC"); } else { MethodDescriptor md = (MethodDescriptor) desc; - writeInferredLatticeDotFile(md.getClassDesc(), md, simpleLattice, "_SC"); + writeInferredLatticeDotFile(md.getClassDesc(), md, skeletonLattice, "_SC"); } HierarchyGraph simpleHierarchyGraph = getSimpleHierarchyGraph(desc); @@ -2619,7 +2620,7 @@ public class LocationInference { // System.out.println("\n## insertIntermediateNodesToStraightLine:" // + simpleHierarchyGraph.getName()); SSJavaLattice lattice = - buildLattice.insertIntermediateNodesToStraightLine(desc, simpleLattice); + buildLattice.insertIntermediateNodesToStraightLine(desc, skeletonLattice); if (lattice == null) { return; @@ -2631,13 +2632,13 @@ public class LocationInference { if (desc instanceof ClassDescriptor) { // field lattice cd2lattice.put((ClassDescriptor) desc, lattice); - // ssjava.writeLatticeDotFile((ClassDescriptor) desc, null, lattice); + ssjava.writeLatticeDotFile((ClassDescriptor) desc, null, lattice); } else if (desc instanceof MethodDescriptor) { // method lattice md2lattice.put((MethodDescriptor) desc, lattice); MethodDescriptor md = (MethodDescriptor) desc; ClassDescriptor cd = md.getClassDesc(); - // ssjava.writeLatticeDotFile(cd, md, lattice); + ssjava.writeLatticeDotFile(cd, md, lattice); } } @@ -2651,7 +2652,7 @@ public class LocationInference { SSJavaLattice simpleLattice = buildLattice.buildLattice(desc); - addMapDescToSimpleLattice(desc, simpleLattice); + addMapDescToSkeletonLattice(desc, simpleLattice); HierarchyGraph simpleHierarchyGraph = getSimpleHierarchyGraph(desc); System.out.println("\n## insertIntermediateNodesToStraightLine:" @@ -2749,12 +2750,12 @@ public class LocationInference { } - public void addMapDescToSimpleLattice(Descriptor desc, SSJavaLattice lattice) { - mapDescriptorToSimpleLattice.put(desc, lattice); + public void addMapDescToSkeletonLattice(Descriptor desc, SSJavaLattice lattice) { + mapDescriptorToSkeletonLattice.put(desc, lattice); } - public SSJavaLattice getSimpleLattice(Descriptor desc) { - return mapDescriptorToSimpleLattice.get(desc); + public SSJavaLattice getSkeletonLattice(Descriptor desc) { + return mapDescriptorToSkeletonLattice.get(desc); } private void simplifyHierarchyGraph() { @@ -2776,6 +2777,7 @@ public class LocationInference { System.out.println("\nSSJAVA: Inserting Combination Nodes:" + desc); HierarchyGraph skeletonGraph = getSkeletonHierarchyGraph(desc); HierarchyGraph skeletonGraphWithCombinationNode = skeletonGraph.clone(); + skeletonGraphWithCombinationNode.setSCGraph(true); skeletonGraphWithCombinationNode.setName(desc + "_SC"); HierarchyGraph simpleHierarchyGraph = getSimpleHierarchyGraph(desc); diff --git a/Robust/src/Analysis/SSJava/SSJavaAnalysis.java b/Robust/src/Analysis/SSJava/SSJavaAnalysis.java index 04aecf9a..fb9d4d5c 100644 --- a/Robust/src/Analysis/SSJava/SSJavaAnalysis.java +++ b/Robust/src/Analysis/SSJava/SSJavaAnalysis.java @@ -266,7 +266,7 @@ public class SSJavaAnalysis { linearTypeCheckMethodSet.add(md); } } - + linearTypeCheckMethodSet.addAll(sortedDescriptors); } @@ -350,6 +350,7 @@ public class SSJavaAnalysis { MethodLattice locOrder = new MethodLattice(SSJavaAnalysis.TOP, SSJavaAnalysis.BOTTOM); md2lattice.put(md, locOrder); + System.out.println("parsing method lattice=" + md); parseMethodDefaultLatticeDefinition(cd, an.getValue(), locOrder); writeLatticeDotFile(cd, md, locOrder, ""); } else if (an.getMarker().equals(TERMINATE)) {