From: yeom Date: Fri, 19 Oct 2012 01:40:14 +0000 (+0000) Subject: changes. X-Git-Url: http://plrg.eecs.uci.edu/git/?p=IRC.git;a=commitdiff_plain;h=d77839806b116bae81d35232998b6c1ac3ddf23d changes. --- diff --git a/Robust/src/Analysis/SSJava/BuildLattice.java b/Robust/src/Analysis/SSJava/BuildLattice.java index 22e514d4..de569443 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); @@ -208,7 +204,7 @@ public class BuildLattice { } 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); } recurDFSNormalNode(desc, lattice, startNode, endCombNodeSet, visited, @@ -225,30 +221,26 @@ public class BuildLattice { // an intermediate node 'node' may be located between "TOP" location and a skeleton node if (simpleGraph.getIncomingNodeSet(node).size() == 0) { + // this node will be directly connected to the TOP location // start adding the following nodes from this node - // Set endNodeSetFromSimpleGraph = - // simpleGraph.getDirectlyReachableSkeletonCombinationNodeFrom(node, null); + Set endNodeSetFromSimpleGraph = + simpleGraph.getDirectlyReachableSkeletonCombinationNodeFrom(node, null); - Set endNodeSet = simpleGraph.getReachableSCNodeSet(node); - - Set endCombNormalNodeSet = new HashSet(); - for (Iterator iterator3 = endNodeSet.iterator(); iterator3.hasNext();) { + Set endCombNodeSet = new HashSet(); + for (Iterator iterator3 = endNodeSetFromSimpleGraph.iterator(); iterator3.hasNext();) { HNode endNode = (HNode) iterator3.next(); - if (endNode.isSkeleton() || endNode.isCombinationNode()) { - endCombNormalNodeSet.add(getCombinationNodeInSCGraph(desc, endNode)); - } else { - endCombNormalNodeSet.addAll(simpleGraph.getSCNodeReachToSet(endNode)); - } + endCombNodeSet.add(getCombinationNodeInSCGraph(desc, endNode)); } - HNode startNode = topNode; + System.out.println("endCombNodeSet=" + endCombNodeSet); + HNode startNode = LocationInference.TOPHNODE; visited.add(startNode); - if (endCombNormalNodeSet.size() > 0) { + if (endCombNodeSet.size() > 0) { // follows the straight line up to another skeleton/combination node // endCombNodeSet = removeTransitivelyReachToNode(desc, node, endCombNodeSet); - recurDFSNormalNode(desc, lattice, startNode, endCombNormalNodeSet, visited, + recurDFSNormalNode(desc, lattice, startNode, endCombNodeSet, visited, mapIntermediateLoc, 1, locSummary, node); } @@ -299,7 +291,7 @@ public class BuildLattice { recurDFS(desc, lattice, combinationNodeInSCGraph, endCombNodeSet, visited, mapIntermediateLoc, 1, locSummary, cnode); } else { - endCombNodeSet.add(bottomNode); + endCombNodeSet.add(LocationInference.BOTTOMHNODE); System.out.println("---endCombNodeSet is zero"); System.out.println("---endNodeSetFromSimpleGraph=" + endNodeSetFromSimpleGraph); System.out.println("---incoming=" + simpleGraph.getIncomingNodeSet(cnode)); diff --git a/Robust/src/Analysis/SSJava/FlowDownCheck.java b/Robust/src/Analysis/SSJava/FlowDownCheck.java index 8886dccd..825a7479 100644 --- a/Robust/src/Analysis/SSJava/FlowDownCheck.java +++ b/Robust/src/Analysis/SSJava/FlowDownCheck.java @@ -700,8 +700,11 @@ public class FlowDownCheck { checkLocationFromExpressionNode(md, nametable, isn.getCondition(), new CompositeLocation(), constraint, false); + System.out.println("checkLocationFromIfStatementNode=" + isn.getCondition().printNode(0)); + System.out.println("---old constraints=" + constraint); // addLocationType(isn.getCondition().getType(), condLoc); constraint = generateNewConstraint(constraint, condLoc); + System.out.println("---new constraints=" + constraint); checkLocationFromBlockNode(md, nametable, isn.getTrueBlock(), constraint); if (isn.getFalseBlock() != null) { @@ -1203,8 +1206,8 @@ public class FlowDownCheck { MethodLattice calleeLattice = ssjava.getMethodLattice(calleemd); - System.out.println("checkCalleeConstraints=" + calleemd + " calleeLattice.getThisLoc()=" - + calleeLattice.getThisLoc()); + // System.out.println("checkCalleeConstraints=" + calleemd + " calleeLattice.getThisLoc()=" + // + calleeLattice.getThisLoc()); CompositeLocation calleeThisLoc = new CompositeLocation(new Location(calleemd, calleeLattice.getThisLoc())); @@ -1315,7 +1318,7 @@ public class FlowDownCheck { private CompositeLocation checkLocationFromArrayAccessNode(MethodDescriptor md, SymbolTable nametable, ArrayAccessNode aan, CompositeLocation constraint, boolean isLHS) { - System.out.println("aan=" + aan.printNode(0) + " line#=" + aan.getNumLine()); + // System.out.println("aan=" + aan.printNode(0) + " line#=" + aan.getNumLine()); ClassDescriptor cd = md.getClassDesc(); CompositeLocation arrayLoc = @@ -2092,7 +2095,7 @@ public class FlowDownCheck { public static CompositeLocation calculateGLB(Set inputSet, String errMsg) { - // System.out.println("Calculating GLB=" + inputSet); + System.out.println("Calculating GLB=" + inputSet); CompositeLocation glbCompLoc = new CompositeLocation(); // calculate GLB of the first(priority) element @@ -2223,7 +2226,7 @@ public class FlowDownCheck { } } - // System.out.println("GLB=" + glbCompLoc); + System.out.println("GLB=" + glbCompLoc + "\n"); return glbCompLoc; } diff --git a/Robust/src/Analysis/SSJava/FlowGraph.java b/Robust/src/Analysis/SSJava/FlowGraph.java index 8ea9fe54..d5de5598 100644 --- a/Robust/src/Analysis/SSJava/FlowGraph.java +++ b/Robust/src/Analysis/SSJava/FlowGraph.java @@ -469,7 +469,7 @@ public class FlowGraph { Location interLoc = new Location(md, localDesc.getSymbol()); interLoc.setLocDescriptor(localDesc); locTuple.add(interLoc); - } else if (localDesc.getSymbol().equals(LocationInference.TOPLOC)) { + } else if (localDesc.getSymbol().equals(SSJavaAnalysis.TOP)) { Location topLoc = new Location(md, Location.TOP); topLoc.setLocDescriptor(LocationInference.TOPDESC); locTuple.add(topLoc); diff --git a/Robust/src/Analysis/SSJava/HierarchyGraph.java b/Robust/src/Analysis/SSJava/HierarchyGraph.java index d1ee9fb2..720be2dc 100644 --- a/Robust/src/Analysis/SSJava/HierarchyGraph.java +++ b/Robust/src/Analysis/SSJava/HierarchyGraph.java @@ -149,10 +149,10 @@ public class HierarchyGraph { return; } + System.out.println("--- CYCLIC VALUE FLOW: " + srcHNode + " -> " + dstHNode); HNode newMergeNode = mergeNodes(possibleCycleSet, false); newMergeNode.setSharedNode(true); - System.out.println("### INTRODUCE A NEW MERGE NODE: " + newMergeNode); - System.out.println("### CYCLIC VALUE FLOW: " + srcHNode + " -> " + dstHNode + "\n"); + } else { getIncomingNodeSet(dstHNode).add(srcHNode); getOutgoingNodeSet(srcHNode).add(dstHNode); @@ -191,6 +191,10 @@ public class HierarchyGraph { newNode.setSkeleton(true); } + if (d.equals(LocationInference.TOPDESC)) { + newNode.setSkeleton(true); + } + String symbol = d.getSymbol(); if (symbol.startsWith(LocationInference.PCLOC) || symbol.startsWith(LocationInference.RLOC)) { newNode.setSkeleton(true); @@ -424,16 +428,22 @@ public class HierarchyGraph { // if the input set contains a skeleton node, need to set a new merge node as skeleton also boolean hasSkeleton = false; + boolean hasShared = false; for (Iterator iterator = set.iterator(); iterator.hasNext();) { HNode inNode = (HNode) iterator.next(); if (inNode.isSkeleton()) { hasSkeleton = true; - break; + } + if (inNode.isSharedNode()) { + hasShared = true; } } - System.out.println("--Set merging node=" + newMergeNode + " as a skeleton=" + set - + " hasSkeleton=" + hasSkeleton + " CUR DESC=" + desc); + // System.out.println("-----Set merging node=" + newMergeNode + " as a skeleton=" + set + // + " hasSkeleton=" + hasSkeleton + " CUR DESC=" + desc); newMergeNode.setSkeleton(hasSkeleton); + newMergeNode.setSharedNode(hasShared); + + System.out.println("-----MERGING NODE=" + set + " new node=" + newMergeNode); for (Iterator iterator = set.iterator(); iterator.hasNext();) { HNode node = (HNode) iterator.next(); @@ -477,14 +487,14 @@ public class HierarchyGraph { HNode mergedNode = (HNode) iterator.next(); addMapHNodeToCurrentHNode(mergedNode, newMergeNode); } - System.out.println("###mergedSkeletonNode=" + mergedSkeletonNode); - System.out.println("###MERGING NODE=" + set + " new node=" + newMergeNode); for (Iterator iterator = set.iterator(); iterator.hasNext();) { HNode hNode = (HNode) iterator.next(); System.out.println("old=" + hNode + "----->newNode=" + getCurrentHNode(hNode)); } + System.out.println(); + return newMergeNode; } @@ -492,8 +502,8 @@ public class HierarchyGraph { if (curNode.isMergeNode()) { Set mergingSet = getMergingSet(curNode); mergingSet.add(curNode); - System.out.println("addMapHNodeToCurrentHNode curNode=" + curNode + " meringSet=" - + mergingSet); + System.out.println("-------addMapHNodeToCurrentHNode curNode=" + curNode + " meringSet=" + + mergingSet + " newNode=" + newNode); for (Iterator iterator = mergingSet.iterator(); iterator.hasNext();) { HNode mergingNode = (HNode) iterator.next(); mapHNodeToCurrentHNode.put(mergingNode, newNode); diff --git a/Robust/src/Analysis/SSJava/LocationInference.java b/Robust/src/Analysis/SSJava/LocationInference.java index f90d87d9..6594444c 100644 --- a/Robust/src/Analysis/SSJava/LocationInference.java +++ b/Robust/src/Analysis/SSJava/LocationInference.java @@ -120,8 +120,6 @@ public class LocationInference { public static final String GLOBALLOC = "GLOBALLOC"; - public static final String TOPLOC = "TOPLOC"; - public static final String INTERLOC = "INTERLOC"; public static final String PCLOC = "_PCLOC_"; @@ -130,12 +128,18 @@ public class LocationInference { public static final Descriptor GLOBALDESC = new NameDescriptor(GLOBALLOC); - public static final Descriptor TOPDESC = new NameDescriptor(TOPLOC); + public static final Descriptor TOPDESC = new NameDescriptor(SSJavaAnalysis.TOP); + + public static final Descriptor BOTTOMDESC = new NameDescriptor(SSJavaAnalysis.BOTTOM); public static final Descriptor RETURNLOC = new NameDescriptor(RLOC); public static final Descriptor LITERALDESC = new NameDescriptor("LITERAL"); + public static final HNode TOPHNODE = new HNode(TOPDESC); + + public static final HNode BOTTOMHNODE = new HNode(BOTTOMDESC); + public static String newline = System.getProperty("line.separator"); LocationInfo curMethodInfo; @@ -356,10 +360,9 @@ public class LocationInference { String locName; if (!enclosingDesc.equals(GLOBALDESC)) { LocationSummary locSummary = getLocationSummary(enclosingDesc); - HierarchyGraph hierarchyGraph = getSimpleHierarchyGraph(enclosingDesc); - if (hierarchyGraph != null) { - - HNode curNode = hierarchyGraph.getCurrentHNode(nodeIdentifier); + HierarchyGraph scGraph = getSkeletonCombinationHierarchyGraph(enclosingDesc); + if (scGraph != null) { + HNode curNode = scGraph.getCurrentHNode(nodeIdentifier); if (curNode != null) { nodeIdentifier = curNode.getName(); } @@ -1286,7 +1289,8 @@ public class LocationInference { // inferred composite location for (int paramIdx = 0; paramIdx < flowGraph.getNumParameters(); paramIdx++) { FlowNode flowNode = flowGraph.getParamFlowNode(paramIdx); - CompositeLocation inferredCompLoc = flowNode.getCompositeLocation(); + CompositeLocation inferredCompLoc = + updateCompositeLocation(flowNode.getCompositeLocation()); // NTuple descTuple = flowNode.getDescTuple(); // // CompositeLocation assignedCompLoc = flowNode.getCompositeLocation(); @@ -1299,8 +1303,8 @@ public class LocationInference { // loc.setLocDescriptor(locDesc); // inferredCompLoc = new CompositeLocation(loc); // } - System.out.println("-paramIdx=" + paramIdx + " infer=" + inferredCompLoc); - System.out.println("-flowNode inferLoc=" + flowNode.getCompositeLocation()); + System.out.println("-paramIdx=" + paramIdx + " infer=" + inferredCompLoc + " original=" + + flowNode.getCompositeLocation()); Descriptor localVarDesc = flowNode.getDescTuple().get(0); methodSummary.addMapVarNameToInferCompLoc(localVarDesc, inferredCompLoc); @@ -1514,10 +1518,10 @@ public class LocationInference { Set keySet = mapDescriptorToHierarchyGraph.keySet(); for (Iterator iterator = keySet.iterator(); iterator.hasNext();) { Descriptor desc = (Descriptor) iterator.next(); + System.out.println("SSJAVA: remove redundant edges: " + desc); HierarchyGraph simpleHierarchyGraph = getHierarchyGraph(desc).clone(); simpleHierarchyGraph.setName(desc + "_SIMPLE"); simpleHierarchyGraph.removeRedundantEdges(); - // simpleHierarchyGraph.simplifyHierarchyGraph(); mapDescriptorToSimpleHierarchyGraph.put(desc, simpleHierarchyGraph); } } @@ -1543,6 +1547,7 @@ public class LocationInference { Set keySet = mapDescriptorToHierarchyGraph.keySet(); for (Iterator iterator = keySet.iterator(); iterator.hasNext();) { Descriptor desc = (Descriptor) iterator.next(); + System.out.println("SSJAVA: Constructing Skeleton Hierarchy Graph: " + desc); HierarchyGraph simpleGraph = getSimpleHierarchyGraph(desc); HierarchyGraph skeletonGraph = simpleGraph.generateSkeletonGraph(); skeletonGraph.setMapDescToHNode(simpleGraph.getMapDescToHNode()); @@ -1689,6 +1694,29 @@ public class LocationInference { } } + Set keySet = mapDescriptorToHierarchyGraph.keySet(); + for (Iterator iterator = keySet.iterator(); iterator.hasNext();) { + Descriptor key = (Descriptor) iterator.next(); + HierarchyGraph graph = getHierarchyGraph(key); + + Set nodeToBeConnected = new HashSet(); + for (Iterator iterator2 = graph.getNodeSet().iterator(); iterator2.hasNext();) { + HNode node = (HNode) iterator2.next(); + if (!node.isSkeleton() && !node.isCombinationNode()) { + if (graph.getIncomingNodeSet(node).size() == 0) { + nodeToBeConnected.add(node); + } + } + } + + for (Iterator iterator2 = nodeToBeConnected.iterator(); iterator2.hasNext();) { + HNode node = (HNode) iterator2.next(); + System.out.println("NEED TO BE CONNECTED TO TOP=" + node); + graph.addEdge(graph.getHNode(TOPDESC), node); + } + + } + } private HierarchyGraph getHierarchyGraph(Descriptor d) { @@ -1925,7 +1953,8 @@ public class LocationInference { if (desc instanceof MethodDescriptor) { System.out.println("#EXTRA LOC DECLARATION GEN=" + desc); - MethodSummary methodSummary = getMethodSummary((MethodDescriptor) desc); + MethodDescriptor md = (MethodDescriptor) desc; + MethodSummary methodSummary = getMethodSummary(md); if (!ssjava.getMethodContainingSSJavaLoop().equals(desc)) { TypeDescriptor returnType = ((MethodDescriptor) desc).getReturnType(); @@ -1939,7 +1968,9 @@ public class LocationInference { } } - rtr += "\n@THISLOC(\"" + methodSummary.getThisLocName() + "\")"; + if (!md.isStatic()) { + rtr += "\n@THISLOC(\"" + methodSummary.getThisLocName() + "\")"; + } rtr += "\n@GLOBALLOC(\"" + methodSummary.getGlobalLocName() + "\")"; } @@ -4624,8 +4655,24 @@ public class LocationInference { nodeSet.addTupleSet(expNodeTupleSet); } else { - nodeSet.addTupleSet(expNodeTupleSet); - nodeSet.addTupleSet(idxNodeTupleSet); + + NodeTupleSet nodeSetArrayAccessExp = new NodeTupleSet(); + + nodeSetArrayAccessExp.addTupleSet(expNodeTupleSet); + nodeSetArrayAccessExp.addTupleSet(idxNodeTupleSet); + + if (needToGenerateInterLoc(nodeSetArrayAccessExp)) { + NTuple interTuple = getFlowGraph(md).createIntermediateNode().getDescTuple(); + + for (Iterator> iter = nodeSetArrayAccessExp.iterator(); iter.hasNext();) { + NTuple higherTuple = iter.next(); + addFlowGraphEdge(md, higherTuple, interTuple); + } + nodeSetArrayAccessExp.clear(); + nodeSetArrayAccessExp.addTuple(interTuple); + } + + nodeSet.addTupleSet(nodeSetArrayAccessExp); } }