From: yeom Date: Sat, 20 Oct 2012 06:26:37 +0000 (+0000) Subject: changes on global composite assignment translation and pcloc generation X-Git-Url: http://plrg.eecs.uci.edu/git/?p=IRC.git;a=commitdiff_plain;h=7701457cedb357fc5efd0170f495a22a99b18cef changes on global composite assignment translation and pcloc generation --- diff --git a/Robust/src/Analysis/SSJava/BuildLattice.java b/Robust/src/Analysis/SSJava/BuildLattice.java index de569443..2df41320 100644 --- a/Robust/src/Analysis/SSJava/BuildLattice.java +++ b/Robust/src/Analysis/SSJava/BuildLattice.java @@ -257,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); @@ -292,9 +293,9 @@ public class BuildLattice { mapIntermediateLoc, 1, locSummary, cnode); } else { endCombNodeSet.add(LocationInference.BOTTOMHNODE); - System.out.println("---endCombNodeSet is zero"); - System.out.println("---endNodeSetFromSimpleGraph=" + endNodeSetFromSimpleGraph); - System.out.println("---incoming=" + simpleGraph.getIncomingNodeSet(cnode)); + // 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); @@ -511,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); + } } + } } diff --git a/Robust/src/Analysis/SSJava/FlowDownCheck.java b/Robust/src/Analysis/SSJava/FlowDownCheck.java index 825a7479..8f5ae45e 100644 --- a/Robust/src/Analysis/SSJava/FlowDownCheck.java +++ b/Robust/src/Analysis/SSJava/FlowDownCheck.java @@ -354,14 +354,19 @@ public class FlowDownCheck { if (!md.getReturnType().isVoid() && !ssjava.getMethodContainingSSJavaLoop().equals(md)) { MethodLattice methodLattice = ssjava.getMethodLattice(md); String thisLocId = methodLattice.getThisLoc(); - if ((!md.isStatic()) && thisLocId == null) { - throw new Error("Method '" + md + "' does not have the definition of 'this' location at " - + md.getClassDesc().getSourceFileName()); + if ((!md.isStatic())) { + + if (thisLocId == null) { + throw new Error("Method '" + md + "' does not have the definition of 'this' location at " + + md.getClassDesc().getSourceFileName()); + } + + CompositeLocation thisLoc = new CompositeLocation(new Location(md, thisLocId)); + paramList.add(0, thisLoc); + md2ReturnLocGen.put(md, new ReturnLocGenerator(md2ReturnLoc.get(md), md, paramList, md + + " of " + cd.getSourceFileName())); } - CompositeLocation thisLoc = new CompositeLocation(new Location(md, thisLocId)); - paramList.add(0, thisLoc); - md2ReturnLocGen.put(md, new ReturnLocGenerator(md2ReturnLoc.get(md), md, paramList, md - + " of " + cd.getSourceFileName())); + } // fourth, check declarations inside of method @@ -696,15 +701,14 @@ public class FlowDownCheck { private CompositeLocation checkLocationFromIfStatementNode(MethodDescriptor md, SymbolTable nametable, IfStatementNode isn, CompositeLocation constraint) { + System.out.println("checkLocationFromIfStatementNode="+isn); CompositeLocation condLoc = 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); + System.out.println("-######old constraint="+constraint); constraint = generateNewConstraint(constraint, condLoc); - System.out.println("---new constraints=" + constraint); + System.out.println("-######new constraint="+constraint); checkLocationFromBlockNode(md, nametable, isn.getTrueBlock(), constraint); if (isn.getFalseBlock() != null) { @@ -1016,7 +1020,10 @@ public class FlowDownCheck { for (int idx = 0; idx < callerArgList.size(); idx++) { CompositeLocation argLocation = callerArgList.get(idx); - // need to check that param is higher than PCLOC + // if the PC location is lower than an argument location + // then, need to check that the callee's the initial location for the PC is also lower + // than the corresponding parameter location + if (!argLocation.get(0).isTop() && CompositeLattice.compare(argLocation, constraint, true, generateErrorMessage(cd, min)) == ComparisonResult.GREATER) { @@ -1024,10 +1031,23 @@ public class FlowDownCheck { CompositeLocation paramLocation = calleeParamList.get(idx); int paramCompareResult = - CompositeLattice.compare(calleePCLOC, paramLocation, true, + CompositeLattice.compare(paramLocation, calleePCLOC, true, generateErrorMessage(cd, min)); - - if (paramCompareResult == ComparisonResult.GREATER) { + // CompositeLattice.compare(calleePCLOC, paramLocation, true, + // generateErrorMessage(cd, min)); + + System.out.println("-CHECKPCLOC:"); + System.out.println("---ARG LOC=" + + argLocation + + " callerPCLOC=" + + constraint + + " result=" + + CompositeLattice.compare(argLocation, constraint, true, + generateErrorMessage(cd, min))); + System.out.println("---PARAM LOC=" + paramLocation + " calleePCLOC=" + calleePCLOC + + " paramCompareResult=" + paramCompareResult); + + if (paramCompareResult != ComparisonResult.GREATER) { throw new Error( "The program counter location " + constraint @@ -1206,11 +1226,8 @@ public class FlowDownCheck { MethodLattice calleeLattice = ssjava.getMethodLattice(calleemd); - // System.out.println("checkCalleeConstraints=" + calleemd + " calleeLattice.getThisLoc()=" - // + calleeLattice.getThisLoc()); - - CompositeLocation calleeThisLoc = - new CompositeLocation(new Location(calleemd, calleeLattice.getThisLoc())); + System.out.println("checkCalleeConstraints=" + calleemd + " calleeLattice.getThisLoc()=" + + calleeLattice.getThisLoc()); List callerArgList = new ArrayList(); List calleeParamList = new ArrayList(); @@ -1234,8 +1251,11 @@ public class FlowDownCheck { // setup callee params set // first, add callee's this location - if (!calleemd.isStatic()) + if (!calleemd.isStatic()) { + CompositeLocation calleeThisLoc = + new CompositeLocation(new Location(calleemd, calleeLattice.getThisLoc())); calleeParamList.add(calleeThisLoc); + } // second, add callee's parameters for (int i = 0; i < calleemd.numParameters(); i++) { VarDescriptor calleevd = (VarDescriptor) calleemd.getParameter(i); @@ -1517,6 +1537,7 @@ public class FlowDownCheck { } } + return loc; } @@ -1524,6 +1545,7 @@ public class FlowDownCheck { SymbolTable nametable, FieldAccessNode fan, CompositeLocation loc, CompositeLocation constraint) { + ExpressionNode left = fan.getExpression(); TypeDescriptor ltd = left.getType(); @@ -1565,6 +1587,7 @@ public class FlowDownCheck { inputGLB.add(loc); loc = CompositeLattice.calculateGLB(inputGLB, generateErrorMessage(md.getClassDesc(), fan)); + return loc; } @@ -1608,6 +1631,8 @@ public class FlowDownCheck { private CompositeLocation checkLocationFromAssignmentNode(MethodDescriptor md, SymbolTable nametable, AssignmentNode an, CompositeLocation loc, CompositeLocation constraint) { + + ClassDescriptor cd = md.getClassDesc(); Set inputGLBSet = new HashSet(); @@ -1635,6 +1660,7 @@ public class FlowDownCheck { checkLocationFromExpressionNode(md, nametable, an.getSrc(), new CompositeLocation(), constraint, false); + if (an.getOperation().getOp() >= 2 && an.getOperation().getOp() <= 12) { // if assignment contains OP+EQ operator, need to merge location types // of LHS & RHS into the RHS diff --git a/Robust/src/Analysis/SSJava/FlowGraph.java b/Robust/src/Analysis/SSJava/FlowGraph.java index d5de5598..77ec3d14 100644 --- a/Robust/src/Analysis/SSJava/FlowGraph.java +++ b/Robust/src/Analysis/SSJava/FlowGraph.java @@ -231,6 +231,10 @@ public class FlowGraph { FlowNode fromNode = getFlowNode(fromDescTuple); FlowNode toNode = getFlowNode(toDescTuple); + if (toNode.getDescTuple().get(0).equals(LocationInference.LITERALDESC)) { + return; + } + // System.out.println("create an edge from " + fromNode + " to " + toNode); int fromTupleSize = fromDescTuple.size(); diff --git a/Robust/src/Analysis/SSJava/LocationInference.java b/Robust/src/Analysis/SSJava/LocationInference.java index 6594444c..f09b930d 100644 --- a/Robust/src/Analysis/SSJava/LocationInference.java +++ b/Robust/src/Analysis/SSJava/LocationInference.java @@ -236,6 +236,8 @@ public class LocationInference { assignCompositeLocation(); + updateFlowGraph(); + // calculate RETURNLOC,PCLOC calculateExtraLocations(); @@ -273,6 +275,21 @@ public class LocationInference { } + private void updateFlowGraph() { + + LinkedList methodDescList = + (LinkedList) toanalyze_methodDescList.clone(); + + while (!methodDescList.isEmpty()) { + MethodDescriptor md = methodDescList.removeLast(); + if (state.SSJAVADEBUG) { + System.out.println(); + System.out.println("SSJAVA: Updating a flow graph: " + md); + propagateFlowsFromCalleesWithNoCompositeLocation(md); + } + } + } + public Map, NTuple> getMapCallerArgToCalleeParam( MethodInvokeNode min) { @@ -468,6 +485,8 @@ public class LocationInference { Map callerMapLocToCompLoc = callerGraph.getMapLocationToInferCompositeLocation(); + Map> mapIdxToArgTuple = mapMethodInvokeNodeToArgIdxMap.get(min); + FlowGraph calleeFlowGraph = getFlowGraph(mdCallee); GlobalFlowGraph calleeGlobalGraph = getSubGlobalFlowGraph(mdCallee); @@ -476,8 +495,11 @@ public class LocationInference { baseLocTuple = translateToLocTuple(mdCaller, mapMethodInvokeNodeToBaseTuple.get(min)); } - // System.out.println("\n-translate caller infer composite loc to callee=" + mdCallee - // + " baseLocTuple=" + baseLocTuple); + System.out.println("\n-#translate caller=" + mdCaller + " infer composite loc to callee=" + + mdCallee + " baseLocTuple=" + baseLocTuple); + // System.out.println("-mapIdxToArgTuple=" + mapIdxToArgTuple); + // System.out.println("-callerMapLocToCompLoc=" + callerMapLocToCompLoc); + Set keySet = callerMapLocToCompLoc.keySet(); for (Iterator iterator = keySet.iterator(); iterator.hasNext();) { Location key = (Location) iterator.next(); @@ -487,14 +509,18 @@ public class LocationInference { CompositeLocation newCalleeCompLoc; if (baseLocTuple != null && callerCompLoc.getTuple().startsWith(baseLocTuple)) { - // System.out.println("---need to translate callerCompLoc=" + callerCompLoc + // System.out.println("-----need to translate callerCompLoc=" + callerCompLoc // + " with baseTuple=" + baseLocTuple); newCalleeCompLoc = translateCompositeLocationToCallee(callerCompLoc, baseLocTuple, mdCallee); calleeGlobalGraph.addMapLocationToInferCompositeLocation(key, newCalleeCompLoc); - // System.out.println("---callee loc=" + key + " newCalleeCompLoc=" + newCalleeCompLoc); + System.out.println("---key=" + key + " callerCompLoc=" + callerCompLoc + + " newCalleeCompLoc=" + newCalleeCompLoc); + System.out.println("-----baseLoctuple=" + baseLocTuple); + System.out.println("-----caller=" + mdCaller + " callee=" + mdCallee); } else { + System.out.println("2"); // check if it is the global access Location compLocFirstElement = callerCompLoc.getTuple().get(0); if (compLocFirstElement.getDescriptor().equals(mdCallee) @@ -508,6 +534,33 @@ public class LocationInference { newCalleeCompLoc.addLocation(callerCompLoc.get(i)); } calleeGlobalGraph.addMapLocationToInferCompositeLocation(key, newCalleeCompLoc); + System.out.println("---key=" + key + " callerCompLoc=" + callerCompLoc + + " newCalleeCompLoc=" + newCalleeCompLoc); + System.out.println("-----caller=" + mdCaller + " callee=" + mdCallee); + + } else { + int paramIdx = getParamIdx(callerCompLoc, mapIdxToArgTuple); + if (paramIdx == -1) { + continue; + } + NTuple argTuple = mapIdxToArgTuple.get(paramIdx); + + FlowNode paramFlowNode = calleeFlowGraph.getParamFlowNode(paramIdx); + System.out.println("-----paramIdx=" + paramIdx + " paramFlowNode=" + paramFlowNode); + NTuple paramLocTuple = + translateToLocTuple(mdCallee, paramFlowNode.getDescTuple()); + newCalleeCompLoc = new CompositeLocation(); + for (int i = 0; i < paramLocTuple.size(); i++) { + newCalleeCompLoc.addLocation(paramLocTuple.get(i)); + } + for (int i = argTuple.size(); i < callerCompLoc.getSize(); i++) { + newCalleeCompLoc.addLocation(callerCompLoc.get(i)); + } + calleeGlobalGraph.addMapLocationToInferCompositeLocation(key, newCalleeCompLoc); + System.out.println("---key=" + key + " callerCompLoc=" + callerCompLoc + + " newCalleeCompLoc=" + newCalleeCompLoc); + System.out.println("------argTuple=" + argTuple); + System.out.println("-----caller=" + mdCaller + " callee=" + mdCallee); } @@ -523,7 +576,6 @@ public class LocationInference { // need to assign a proper composite location to the corresponding callee parameter // System.out.println("---translate arg composite location to callee param. min=" // + min.printNode(0)); - Map> mapIdxToArgTuple = mapMethodInvokeNodeToArgIdxMap.get(min); Set idxSet = mapIdxToArgTuple.keySet(); for (Iterator iterator = idxSet.iterator(); iterator.hasNext();) { Integer idx = (Integer) iterator.next(); @@ -577,6 +629,24 @@ public class LocationInference { } + private int getParamIdx(CompositeLocation compLoc, + Map> mapIdxToArgTuple) { + + // if the composite location is started with the argument descriptor + // return the argument's index. o.t. return -1 + + Set keySet = mapIdxToArgTuple.keySet(); + for (Iterator iterator = keySet.iterator(); iterator.hasNext();) { + Integer key = (Integer) iterator.next(); + NTuple argTuple = mapIdxToArgTuple.get(key); + if (translateToDescTuple(compLoc.getTuple()).startsWith(argTuple)) { + return key.intValue(); + } + } + + return -1; + } + private boolean isPrimitiveType(NTuple argTuple) { Descriptor lastDesc = argTuple.get(argTuple.size() - 1); @@ -585,9 +655,11 @@ public class LocationInference { return ((FieldDescriptor) lastDesc).getType().isPrimitive(); } else if (lastDesc instanceof VarDescriptor) { return ((VarDescriptor) lastDesc).getType().isPrimitive(); + } else if (lastDesc instanceof InterDescriptor) { + return true; } - return true; + return false; } private CompositeLocation translateCompositeLocationToCallee(CompositeLocation callerCompLoc, @@ -2382,7 +2454,7 @@ public class LocationInference { private void calculatePCLOC(MethodDescriptor md) { - System.out.println("#calcualtePCLOC"); + System.out.println("#CalculatePCLOC"); MethodSummary methodSummary = getMethodSummary(md); FlowGraph fg = getFlowGraph(md); Map mapParamToLoc = methodSummary.getMapParamIdxToInferLoc(); @@ -2401,19 +2473,34 @@ public class LocationInference { NTuple paramDescTuple = paramFlowNode.getCurrentDescTuple(); NTuple paramLocTuple = translateToLocTuple(md, paramDescTuple); - if (fg.getIncomingNodeSetByPrefix(prefix).size() > 0) { + Set inNodeToParamSet = fg.getIncomingNodeSetByPrefix(prefix); + if (inNodeToParamSet.size() > 0) { // parameter has in-value flows - paramLocTupleHavingInFlowSet.add(paramLocTuple); + + for (Iterator iterator = inNodeToParamSet.iterator(); iterator.hasNext();) { + FlowNode inNode = (FlowNode) iterator.next(); + Set outEdgeSet = fg.getOutEdgeSet(inNode); + for (Iterator iterator2 = outEdgeSet.iterator(); iterator2.hasNext();) { + FlowEdge flowEdge = (FlowEdge) iterator2.next(); + if (flowEdge.getEndTuple().startsWith(prefix)) { + NTuple paramLocTupleWithIncomingFlow = + translateToLocTuple(md, flowEdge.getEndTuple()); + paramLocTupleHavingInFlowSet.add(paramLocTupleWithIncomingFlow); + } + } + } + + // paramLocTupleHavingInFlowSet.add(paramLocTuple); } else { // paramNodeNOThavingInFlowSet.add(fg.getFlowNode(paramDescTuple)); paramDescNOTHavingInFlowSet.add(prefix); } } - System.out.println("paramNodeNOThavingInFlowSet=" + paramDescNOTHavingInFlowSet); + System.out.println("paramLocTupleHavingInFlowSet=" + paramLocTupleHavingInFlowSet); if (paramLocTupleHavingInFlowSet.size() > 0 - && !coversAllParamters(md, fg, paramLocTupleHavingInFlowSet)) { + /* && !coversAllParamters(md, fg, paramLocTupleHavingInFlowSet) */) { // Here, generates a location in the method lattice that is higher than the // paramLocTupleHavingInFlowSet @@ -2623,10 +2710,21 @@ public class LocationInference { Set> paramLocTupleStartedWithThis = new HashSet>(); - for (Iterator iterator = paramLocTupleHavingInFlowSet.iterator(); iterator.hasNext();) { + next: for (Iterator iterator = paramLocTupleHavingInFlowSet.iterator(); iterator.hasNext();) { NTuple paramLocTuple = (NTuple) iterator.next(); - if (!paramLocTuple.get(0).getLocDescriptor().equals(thisVarDesc)) { + Descriptor paramLocalDesc = paramLocTuple.get(0).getLocDescriptor(); + if (!paramLocalDesc.equals(thisVarDesc)) { + + Set inNodeSet = getFlowGraph(md).getIncomingNodeSetByPrefix(paramLocalDesc); + for (Iterator iterator2 = inNodeSet.iterator(); iterator2.hasNext();) { + FlowNode flowNode = (FlowNode) iterator2.next(); + if (flowNode.getDescTuple().startsWith(thisVarDesc)) { + System.out.println("paramLocTuple=" + paramLocTuple + " is lower than THIS"); + continue next; + } + } hasParamNotStartedWithThisRef = true; + } else if (paramLocTuple.size() > 1) { paramLocTupleStartedWithThis.add(paramLocTuple); if (minSize == 0 || minSize > paramLocTuple.size()) { @@ -3025,27 +3123,56 @@ public class LocationInference { // parameters Set localReachSet = calleeFlowGraph.getLocalReachFlowNodeSetFrom(paramNode1); - // System.out.println("-param1=" + paramNode1 + " is higher than param2=" + paramNode2); + System.out.println("-param1=" + paramNode1 + " is higher than param2=" + paramNode2); // System.out.println("-- localReachSet from param1=" + localReachSet); + NTuple paramDescTuple1 = paramNode1.getCurrentDescTuple(); + NTuple paramDescTuple2 = paramNode2.getCurrentDescTuple(); + + System.out.println("-param1CurTuple=" + paramDescTuple1 + " param2CurTuple=" + + paramDescTuple2); + if (paramDescTuple1.get(0).equals(paramDescTuple2.get(0))) { + // if two parameters share the same prefix + // it already has been assigned to a composite location + // so we don't need to add an additional ordering relation caused by these two + // paramters. + continue; + } + if (arg1Tuple.size() > 0 && arg2Tuple.size() > 0 && localReachSet.contains(paramNode2)) { // need to propagate an ordering relation s.t. arg1 is higher // than arg2 + // add a new flow between the corresponding arguments. + callerFlowGraph.addValueFlowEdge(arg1Tuple, arg2Tuple); + System.out.println("arg1=" + arg1Tuple + " arg2=" + arg2Tuple); + // System.out // .println("-arg1Tuple=" + arg1Tuple + " is higher than arg2Tuple=" + arg2Tuple); - // otherwise, flows between method/field locations... - callerFlowGraph.addValueFlowEdge(arg1Tuple, arg2Tuple); - // System.out.println("arg1=" + arg1Tuple + " arg2=" + arg2Tuple); - } System.out.println(); } } } - // System.out.println("##\n"); + + // if a parameter has a composite location and the first element of the parameter location + // matches the callee's 'this' + // we have a more specific constraint: the caller's corresponding argument is higher than the + // parameter location which is translated into the caller + + for (int idx = 0; idx < numParam; idx++) { + FlowNode paramNode = calleeFlowGraph.getParamFlowNode(idx); + CompositeLocation compLoc = paramNode.getCompositeLocation(); + if (compLoc != null) { + System.out.println("$$$COMPLOC CASE=" + compLoc); + NTuple argTuple = getNodeTupleByArgIdx(min, idx); + NTuple translatedParamTuple = translateCompositeLocationToCaller(min, compLoc); + System.out.println("add a flow edge= " + argTuple + "->" + translatedParamTuple); + callerFlowGraph.addValueFlowEdge(argTuple, translatedParamTuple); + } + } } @@ -3244,7 +3371,7 @@ public class LocationInference { tuple.add(baseTuple.get(i)); } - for (int i = 1; i < compLocForParam1.getSize(); i++) { + for (int i = baseTuple.size(); i < compLocForParam1.getSize(); i++) { Location loc = compLocForParam1.get(i); tuple.add(loc.getLocDescriptor()); } @@ -3784,8 +3911,8 @@ public class LocationInference { addValueFlowsFromCalleeSubGlobalFlowGraph(md, subGlobalFlowGraph); subGlobalFlowGraph.writeGraph("_SUBGLOBAL"); - System.out.println("-propagate Flows From Callees With No CompositeLocation"); - propagateFlowsFromCalleesWithNoCompositeLocation(md); + // System.out.println("-propagate Flows From Callees With No CompositeLocation"); + // propagateFlowsFromCalleesWithNoCompositeLocation(md); } } @@ -4022,6 +4149,7 @@ public class LocationInference { if (needToGenerateInterLoc(newImplicitTupleSet)) { // 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(); @@ -4087,7 +4215,7 @@ public class LocationInference { System.out.println("---currentFlowTupleSet=" + currentFlowTupleSet); if (needToGenerateInterLoc(currentFlowTupleSet)) { - System.out.println("---needToGenerateInterLoc"); + System.out.println("8"); FlowNode meetNode = fg.createIntermediateNode(); for (Iterator iterator = currentFlowTupleSet.iterator(); iterator.hasNext();) { NTuple currentFlowTuple = (NTuple) iterator.next(); @@ -4149,6 +4277,7 @@ public class LocationInference { if (needToGenerateInterLoc(newImplicitTupleSet)) { // 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();) { @@ -4208,6 +4337,7 @@ public class LocationInference { if (needToGenerateInterLoc(newImplicitTupleSet)) { // 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();) { @@ -4253,7 +4383,7 @@ public class LocationInference { private void analyzeFlowIfStatementNode(MethodDescriptor md, SymbolTable nametable, IfStatementNode isn, NodeTupleSet implicitFlowTupleSet) { - // System.out.println("analyzeFlowIfStatementNode=" + isn.printNode(0)); + System.out.println("analyzeFlowIfStatementNode=" + isn.printNode(0)); NodeTupleSet condTupleNode = new NodeTupleSet(); analyzeFlowExpressionNode(md, nametable, isn.getCondition(), condTupleNode, null, @@ -4264,9 +4394,9 @@ public class LocationInference { newImplicitTupleSet.addTupleSet(implicitFlowTupleSet); newImplicitTupleSet.addTupleSet(condTupleNode); - // System.out.println("condTupleNode=" + condTupleNode); - // System.out.println("implicitFlowTupleSet=" + implicitFlowTupleSet); - // System.out.println("newImplicitTupleSet=" + newImplicitTupleSet); + // System.out.println("-condTupleNode=" + condTupleNode); + // System.out.println("-implicitFlowTupleSet=" + implicitFlowTupleSet); + // System.out.println("-newImplicitTupleSet=" + newImplicitTupleSet); if (needToGenerateInterLoc(newImplicitTupleSet)) { @@ -4307,6 +4437,7 @@ public class LocationInference { // creates edges from RHS to LHS NTuple interTuple = null; if (needToGenerateInterLoc(nodeSetRHS)) { + interTuple = getFlowGraph(md).createIntermediateNode().getDescTuple(); } @@ -4478,8 +4609,6 @@ public class LocationInference { private void analyzeFlowMethodInvokeNode(MethodDescriptor md, SymbolTable nametable, MethodInvokeNode min, NodeTupleSet nodeSet, NodeTupleSet implicitFlowTupleSet) { - System.out.println("analyzeFlowMethodInvokeNode=" + min.printNode(0)); - mapMethodInvokeNodeToArgIdxMap.put(min, new HashMap>()); if (nodeSet == null) { @@ -4541,7 +4670,6 @@ public class LocationInference { } } - // analyze parameter flows if (min.numArgs() > 0) { @@ -4578,6 +4706,19 @@ public class LocationInference { addArgIdxMap(min, idx, argTuple); FlowNode paramNode = calleeFlowGraph.getParamFlowNode(idx); + + // check whether a param node in the callee graph has incoming flows + // if it has incoming flows, the corresponding arg should be lower than the current PC + // Descriptor prefix = paramNode.getDescTuple().get(0); + // if (calleeFlowGraph.getIncomingNodeSetByPrefix(prefix).size() > 0) { + // for (Iterator> iterator = implicitFlowTupleSet.iterator(); iterator + // .hasNext();) { + // NTuple pcTuple = iterator.next(); + // System.out.println("add edge pcTuple =" + pcTuple + " -> " + argTuple); + // addFlowGraphEdge(md, pcTuple, argTuple); + // } + // } + if (hasInFlowTo(calleeFlowGraph, paramNode, calleeReturnSet) || calleeMethodDesc.getModifiers().isNative()) { addParamNodeFlowingToReturnValue(calleeMethodDesc, paramNode); @@ -4599,7 +4740,7 @@ public class LocationInference { // Set reachableSet = fg.getReachFlowNodeSetFrom(inNode); Set reachableSet = fg.getReachableSetFrom(inNode.getDescTuple()); - System.out.println("inNode=" + inNode + " reachalbeSet=" + reachableSet); + // System.out.println("inNode=" + inNode + " reachalbeSet=" + reachableSet); for (Iterator iterator = reachableSet.iterator(); iterator.hasNext();) { FlowNode fn = (FlowNode) iterator.next(); @@ -4745,8 +4886,6 @@ public class LocationInference { private NTuple analyzeFlowNameNode(MethodDescriptor md, SymbolTable nametable, NameNode nn, NodeTupleSet nodeSet, NTuple base, NodeTupleSet implicitFlowTupleSet) { - System.out.println("analyzeFlowNameNode=" + nn.printNode(0)); - if (base == null) { base = new NTuple(); }