From da0fa968b5637a83e1e8878fc1ab3df8e413344a Mon Sep 17 00:00:00 2001 From: yeom Date: Tue, 9 Oct 2012 00:01:24 +0000 Subject: [PATCH] changes: now it generates simple lattice without having intermediate nodes for the mp3decoder benchmark. --- Robust/src/Analysis/SSJava/BuildLattice.java | 29 ++- .../src/Analysis/SSJava/GlobalFlowGraph.java | 91 ++++++- .../src/Analysis/SSJava/GlobalFlowNode.java | 3 - .../Analysis/SSJava/LocationInference.java | 232 +++++++++++++----- Robust/src/Analysis/SSJava/SSJavaLattice.java | 2 + 5 files changed, 282 insertions(+), 75 deletions(-) diff --git a/Robust/src/Analysis/SSJava/BuildLattice.java b/Robust/src/Analysis/SSJava/BuildLattice.java index 264699c3..52a2bf9c 100644 --- a/Robust/src/Analysis/SSJava/BuildLattice.java +++ b/Robust/src/Analysis/SSJava/BuildLattice.java @@ -118,6 +118,8 @@ public class BuildLattice { Set nodeSet = simpleGraph.getNodeSet(); Map mapIntermediateLoc = new HashMap(); + + for (Iterator iterator = nodeSet.iterator(); iterator.hasNext();) { HNode node = (HNode) iterator.next(); if (node.isSkeleton() && (!visited.contains(node))) { @@ -205,19 +207,22 @@ public class BuildLattice { } } else if (!node.isSkeleton() && !node.isCombinationNode() && !node.isMergeNode() && !visited.contains(node)) { - // an intermediate node 'node' is located between "TOP" location and a skeleton node + // an intermediate node 'node' may be located between "TOP" location and a skeleton node + // but there is no such a case. + + // Set outNodeSet = simpleGraph.getOutgoingNodeSet(node); + // Set belowSkeletonLocNameSet = new HashSet(); + // for (Iterator iterator2 = outNodeSet.iterator(); iterator2.hasNext();) { + // HNode outNode = (HNode) iterator2.next(); + // if (outNode.isSkeleton()) { + // belowSkeletonLocNameSet.add(scGraph.getCurrentHNode(outNode).getName()); + // } + // } + // String newLocName = "ILOC" + (seed++); + // lattice.insertNewLocationBetween(lattice.getTopItem(), belowSkeletonLocNameSet, + // newLocName); + // locSummary.addMapHNodeNameToLocationName(node.getName(), newLocName); - Set outNodeSet = simpleGraph.getOutgoingNodeSet(node); - Set belowSkeletonLocNameSet = new HashSet(); - for (Iterator iterator2 = outNodeSet.iterator(); iterator2.hasNext();) { - HNode outNode = (HNode) iterator2.next(); - if (outNode.isSkeleton()) { - belowSkeletonLocNameSet.add(scGraph.getCurrentHNode(outNode).getName()); - } - } - String newLocName = "ILOC" + (seed++); - lattice.insertNewLocationBetween(lattice.getTopItem(), belowSkeletonLocNameSet, newLocName); - locSummary.addMapHNodeNameToLocationName(node.getName(), newLocName); } } diff --git a/Robust/src/Analysis/SSJava/GlobalFlowGraph.java b/Robust/src/Analysis/SSJava/GlobalFlowGraph.java index 35fbd006..ac901bed 100644 --- a/Robust/src/Analysis/SSJava/GlobalFlowGraph.java +++ b/Robust/src/Analysis/SSJava/GlobalFlowGraph.java @@ -19,6 +19,7 @@ public class GlobalFlowGraph { Map, GlobalFlowNode> mapLocTupleToNode; Map> mapFlowNodeToOutNodeSet; + Map> mapFlowNodeToInNodeSet; Map mapLocationToInferCompositeLocation; @@ -26,6 +27,8 @@ public class GlobalFlowGraph { this.md = md; this.mapLocTupleToNode = new HashMap, GlobalFlowNode>(); this.mapFlowNodeToOutNodeSet = new HashMap>(); + this.mapFlowNodeToInNodeSet = new HashMap>(); + this.mapLocationToInferCompositeLocation = new HashMap(); } @@ -59,7 +62,7 @@ public class GlobalFlowGraph { CompositeLocation oldCompLoc = mapLocationToInferCompositeLocation.get(loc); if (newCompLoc.getSize() == oldCompLoc.getSize()) { - for (int i = 0; i < oldCompLoc.getSize(); i++) { + for (int i = 0; i < oldCompLoc.getSize() - 1; i++) { Location oldLocElement = oldCompLoc.get(i); Location newLocElement = newCompLoc.get(i); @@ -96,10 +99,22 @@ public class GlobalFlowGraph { } mapFlowNodeToOutNodeSet.get(fromNode).add(toNode); + if (!mapFlowNodeToInNodeSet.containsKey(toNode)) { + mapFlowNodeToInNodeSet.put(toNode, new HashSet()); + } + mapFlowNodeToInNodeSet.get(toNode).add(fromNode); + System.out.println("create a global edge from " + fromNode + " to " + toNode); } + public Set getInNodeSet(GlobalFlowNode node) { + if (!mapFlowNodeToInNodeSet.containsKey(node)) { + mapFlowNodeToInNodeSet.put(node, new HashSet()); + } + return mapFlowNodeToInNodeSet.get(node); + } + public Set getNodeSet() { Set nodeSet = new HashSet(); nodeSet.addAll(mapLocTupleToNode.values()); @@ -202,6 +217,80 @@ public class GlobalFlowGraph { } + public Set getIncomingNodeSetByPrefix(Location prefix) { + + Set incomingNodeSet = new HashSet(); + + for (Iterator iterator = getNodeSet().iterator(); iterator.hasNext();) { + GlobalFlowNode curNode = (GlobalFlowNode) iterator.next(); + Set outNodeSet = getOutNodeSet(curNode); + + for (Iterator iterator2 = outNodeSet.iterator(); iterator2.hasNext();) { + GlobalFlowNode outNode = (GlobalFlowNode) iterator2.next(); + + if (outNode.getLocTuple().startsWith(prefix)) { + incomingNodeSet.add(curNode); + recurIncomingNodeSetByPrefix(prefix, curNode, incomingNodeSet); + } + + } + } + + return incomingNodeSet; + + } + + private void recurIncomingNodeSetByPrefix(Location prefix, GlobalFlowNode node, + Set visited) { + + Set inNodeSet = getInNodeSet(node); + + for (Iterator iterator = inNodeSet.iterator(); iterator.hasNext();) { + GlobalFlowNode curNode = (GlobalFlowNode) iterator.next(); + + if (!curNode.getLocTuple().startsWith(prefix) && !visited.contains(curNode)) { + visited.add(curNode); + recurIncomingNodeSetByPrefix(prefix, curNode, visited); + } + } + + } + + public Set getReachableNodeSetByPrefix(Location prefix) { + + Set reachableNodeSet = new HashSet(); + + for (Iterator iterator = getNodeSet().iterator(); iterator.hasNext();) { + GlobalFlowNode curNode = (GlobalFlowNode) iterator.next(); + + if (curNode.getLocTuple().startsWith(prefix)) { + Set outNodeSet = getOutNodeSet(curNode); + for (Iterator iterator2 = outNodeSet.iterator(); iterator2.hasNext();) { + GlobalFlowNode outNode = (GlobalFlowNode) iterator2.next(); + if (!outNode.getLocTuple().startsWith(prefix) && !reachableNodeSet.contains(outNode)) { + reachableNodeSet.add(outNode); + recurReachableNodeSetByPrefix(prefix, outNode, reachableNodeSet); + } + + } + } + } + + return reachableNodeSet; + } + + private void recurReachableNodeSetByPrefix(Location prefix, GlobalFlowNode node, + Set reachableNodeSet) { + Set outNodeSet = getOutNodeSet(node); + for (Iterator iterator = outNodeSet.iterator(); iterator.hasNext();) { + GlobalFlowNode outNode = (GlobalFlowNode) iterator.next(); + if (!outNode.getLocTuple().startsWith(prefix) && !reachableNodeSet.contains(outNode)) { + reachableNodeSet.add(outNode); + recurReachableNodeSetByPrefix(prefix, outNode, reachableNodeSet); + } + } + } + public Set getReachableNodeSetFrom(GlobalFlowNode node) { Set reachableNodeSet = new HashSet(); diff --git a/Robust/src/Analysis/SSJava/GlobalFlowNode.java b/Robust/src/Analysis/SSJava/GlobalFlowNode.java index 3f5c72d1..03f96b28 100644 --- a/Robust/src/Analysis/SSJava/GlobalFlowNode.java +++ b/Robust/src/Analysis/SSJava/GlobalFlowNode.java @@ -9,9 +9,6 @@ public class GlobalFlowNode { public GlobalFlowNode(NTuple in) { locTuple = in; - if (in.size() == 0) { - throw new Error(); - } } public int hashCode() { diff --git a/Robust/src/Analysis/SSJava/LocationInference.java b/Robust/src/Analysis/SSJava/LocationInference.java index 0967c58b..26bd8c29 100644 --- a/Robust/src/Analysis/SSJava/LocationInference.java +++ b/Robust/src/Analysis/SSJava/LocationInference.java @@ -224,8 +224,6 @@ public class LocationInference { // constructGlobalFlowGraph(); - System.exit(0); - constructHierarchyGraph(); debug_writeHierarchyDotFiles(); @@ -307,6 +305,7 @@ public class LocationInference { FlowGraph callerFlowGraph = getFlowGraph(mdCaller); Map callerMapLocToCompLoc = callerGlobalFlowGraph.getMapLocationToInferCompositeLocation(); + System.out.println("---callerMapLocToCompLoc=" + callerMapLocToCompLoc); Set methodLocSet = callerMapLocToCompLoc.keySet(); for (Iterator iterator = methodLocSet.iterator(); iterator.hasNext();) { Location methodLoc = (Location) iterator.next(); @@ -399,29 +398,40 @@ public class LocationInference { NTuple baseLocTuple = translateToLocTuple(mdCaller, mapMethodInvokeNodeToBaseTuple.get(min)); - System.out.println("-translate caller infer composite loc to callee=" + mdCallee); + System.out.println("\n-translate caller infer composite loc to callee=" + mdCallee + + " baseLocTuple=" + baseLocTuple); Set keySet = callerMapLocToCompLoc.keySet(); for (Iterator iterator = keySet.iterator(); iterator.hasNext();) { Location key = (Location) iterator.next(); CompositeLocation callerCompLoc = callerMapLocToCompLoc.get(key); - if (!key.getDescriptor().equals(mdCaller) - && callerCompLoc.getTuple().startsWith(baseLocTuple)) { + if (!key.getDescriptor().equals(mdCaller)) { + System.out.println("--- caller key=" + key + " callerCompLoc=" + callerCompLoc); + + // && callerCompLoc.getTuple().startsWith(baseLocTuple)) { // need to translate to the callee side - // System.out.println("need to translate callerCompLoc=" + callerCompLoc + - // " with baseTuple=" - // + baseLocTuple); + // TODO - CompositeLocation newCalleeCompLoc = - translateCompositeLocationToCallee(callerCompLoc, baseLocTuple, mdCallee); - calleeGlobalGraph.addMapLocationToInferCompositeLocation(key, newCalleeCompLoc); - System.out.println("---callee loc=" + key + " newCalleeCompLoc=" + newCalleeCompLoc); + CompositeLocation newCalleeCompLoc; + if (callerCompLoc.getTuple().startsWith(baseLocTuple)) { + 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); + } else { + // newCalleeCompLoc = callerCompLoc.clone(); + } + } } // If the location of an argument has a composite location // need to assign a proper composite location to the corresponding callee parameter - System.out.println("-translate arg composite location to callee param:"); + System.out.println("\n-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();) { @@ -432,37 +442,44 @@ public class LocationInference { } NTuple argTuple = mapIdxToArgTuple.get(idx); + if (argTuple.size() > 0) { + // check if an arg tuple has been already assigned to a composite location + NTuple argLocTuple = translateToLocTuple(mdCaller, argTuple); + Location argLocalLoc = argLocTuple.get(0); - // check if an arg tuple has been already assigned to a composite location - NTuple argLocTuple = translateToLocTuple(mdCaller, argTuple); - Location argLocalLoc = argLocTuple.get(0); + // if (!isPrimitiveType(argTuple)) { + if (callerMapLocToCompLoc.containsKey(argLocalLoc)) { - // if (!isPrimitiveType(argTuple)) { - if (callerMapLocToCompLoc.containsKey(argLocalLoc)) { + CompositeLocation callerCompLoc = callerMapLocToCompLoc.get(argLocalLoc); + for (int i = 1; i < argLocTuple.size(); i++) { + callerCompLoc.addLocation(argLocTuple.get(i)); + } - CompositeLocation callerCompLoc = callerMapLocToCompLoc.get(argLocalLoc); - for (int i = 1; i < argLocTuple.size(); i++) { - callerCompLoc.addLocation(argLocTuple.get(i)); - } + if (callerCompLoc.getTuple().startsWith(baseLocTuple)) { - if (callerCompLoc.getTuple().startsWith(baseLocTuple)) { + FlowNode calleeParamFlowNode = calleeFlowGraph.getParamFlowNode(idx); + NTuple calleeParamDescTuple = calleeParamFlowNode.getDescTuple(); + NTuple calleeParamLocTuple = + translateToLocTuple(mdCallee, calleeParamDescTuple); - FlowNode calleeParamFlowNode = calleeFlowGraph.getParamFlowNode(idx); - NTuple calleeParamDescTuple = calleeParamFlowNode.getDescTuple(); - NTuple calleeParamLocTuple = - translateToLocTuple(mdCallee, calleeParamDescTuple); + System.out.println("---need to translate callerCompLoc=" + callerCompLoc + + " with baseTuple=" + baseLocTuple + " calleeParamLocTuple=" + + calleeParamLocTuple); - CompositeLocation newCalleeCompLoc = - translateCompositeLocationToCallee(callerCompLoc, baseLocTuple, mdCallee); + CompositeLocation newCalleeCompLoc = + translateCompositeLocationToCallee(callerCompLoc, baseLocTuple, mdCallee); - calleeGlobalGraph.addMapLocationToInferCompositeLocation(calleeParamLocTuple.get(0), - newCalleeCompLoc); + calleeGlobalGraph.addMapLocationToInferCompositeLocation(calleeParamLocTuple.get(0), + newCalleeCompLoc); - System.out.println("###need to assign composite location to=" + calleeParamDescTuple - + " with baseTuple=" + baseLocTuple); - System.out.println("---newCalleeCompLoc=" + newCalleeCompLoc); - } + System.out.println("---callee loc=" + calleeParamLocTuple.get(0) + + " newCalleeCompLoc=" + newCalleeCompLoc); + // System.out.println("###need to assign composite location to=" + calleeParamDescTuple + // + " with baseTuple=" + baseLocTuple); + } + + } } } @@ -487,14 +504,12 @@ public class LocationInference { CompositeLocation newCalleeCompLoc = new CompositeLocation(); - // replace the last element of the caller compLoc with the 'this' location of the callee - for (int i = 0; i < baseLocTuple.size() - 1; i++) { - newCalleeCompLoc.addLocation(baseLocTuple.get(i)); - } - Location calleeThisLoc = new Location(mdCallee, mdCallee.getThis()); newCalleeCompLoc.addLocation(calleeThisLoc); + // remove the base tuple from the caller + // ex; In the method invoation foo.bar.methodA(), the callee will have the composite location + // ,which is relative to the 'this' variable, for (int i = baseLocTuple.size(); i < callerCompLoc.getSize(); i++) { newCalleeCompLoc.addLocation(callerCompLoc.get(i)); } @@ -558,24 +573,37 @@ public class LocationInference { MethodDescriptor methodDescEventLoop = ssjava.getMethodContainingSSJavaLoop(); GlobalFlowGraph globalFlowGraph = getSubGlobalFlowGraph(methodDescEventLoop); - Set> prefixSet = new HashSet>(); + Set calculatedPrefixSet = new HashSet(); Set nodeSet = globalFlowGraph.getNodeSet(); next: for (Iterator iterator = nodeSet.iterator(); iterator.hasNext();) { GlobalFlowNode node = (GlobalFlowNode) iterator.next(); - Set incomingNodeSet = globalFlowGraph.getIncomingNodeSet(node); + + Location prefixLoc = node.getLocTuple().get(0); + + if (calculatedPrefixSet.contains(prefixLoc)) { + // the prefix loc has been already assigned to a composite location + continue; + } + + calculatedPrefixSet.add(prefixLoc); + + // Set incomingNodeSet = globalFlowGraph.getIncomingNodeSet(node); List> prefixList = calculatePrefixList(globalFlowGraph, node); - Set reachNodeSet = globalFlowGraph.getReachableNodeSetFrom(node); - // System.out.println("node=" + node + " inNodeSet=" + incomingNodeSet - // + " reachableNodeSet=" + reachNodeSet); + Set reachableNodeSet = + globalFlowGraph.getReachableNodeSetByPrefix(node.getLocTuple().get(0)); + // Set reachNodeSet = globalFlowGraph.getReachableNodeSetFrom(node); + + // System.out.println("node=" + node + " prefixList=" + prefixList + " reachableNodeSet=" + // + reachableNodeSet); for (int i = 0; i < prefixList.size(); i++) { NTuple curPrefix = prefixList.get(i); Set> reachableCommonPrefixSet = new HashSet>(); - for (Iterator iterator2 = reachNodeSet.iterator(); iterator2.hasNext();) { + for (Iterator iterator2 = reachableNodeSet.iterator(); iterator2.hasNext();) { GlobalFlowNode reachNode = (GlobalFlowNode) iterator2.next(); if (reachNode.getLocTuple().startsWith(curPrefix)) { reachableCommonPrefixSet.add(reachNode.getLocTuple()); @@ -584,16 +612,44 @@ public class LocationInference { if (!reachableCommonPrefixSet.isEmpty()) { - // TODO - if (!node.getLocTuple().startsWith(curPrefix.get(0))) { + MethodDescriptor curPrefixFirstElementMethodDesc = + (MethodDescriptor) curPrefix.get(0).getDescriptor(); + + MethodDescriptor nodePrefixLocFirstElementMethodDesc = + (MethodDescriptor) prefixLoc.getDescriptor(); + + if (curPrefixFirstElementMethodDesc.equals(nodePrefixLocFirstElementMethodDesc) + || isTransitivelyCalledFrom(nodePrefixLocFirstElementMethodDesc, + curPrefixFirstElementMethodDesc)) { + + // TODO + // if (!node.getLocTuple().startsWith(curPrefix.get(0))) { + + Location curPrefixLocalLoc = curPrefix.get(0); + if (globalFlowGraph.mapLocationToInferCompositeLocation.containsKey(curPrefixLocalLoc)) { + // in this case, the local variable of the current prefix has already got a composite + // location + // so we just ignore the current composite location. + + // System.out.println("HERE WE DO NOT ASSIGN A COMPOSITE LOCATION TO =" + node + // + " DUE TO " + curPrefix); + + continue next; + } + + Location targetLocalLoc = node.getLocTuple().get(0); + // CompositeLocation curCompLoc = globalFlowGraph.getCompositeLocation(targetLocalLoc); + // if ((curPrefix.size() + 1) > curCompLoc.getSize()) { + CompositeLocation newCompLoc = generateCompositeLocation(curPrefix); System.out.println("NEED TO ASSIGN COMP LOC TO " + node + " with prefix=" + curPrefix); System.out.println("- newCompLoc=" + newCompLoc); - - Location targetLocalLoc = node.getLocTuple().get(0); globalFlowGraph.addMapLocationToInferCompositeLocation(targetLocalLoc, newCompLoc); + // } continue next; + // } + } } @@ -617,13 +673,21 @@ public class LocationInference { private List> calculatePrefixList(GlobalFlowGraph graph, GlobalFlowNode node) { - System.out.println("\n##### calculatePrefixList=" + node); + System.out.println("\n##### calculatePrefixList node=" + node); - Set incomingNodeSet = graph.getIncomingNodeSet(node); + MethodDescriptor md = graph.getMethodDescriptor(); + + Set incomingNodeSetPrefix = + graph.getIncomingNodeSetByPrefix(node.getLocTuple().get(0)); + // System.out.println("incomingNodeSetPrefix=" + incomingNodeSetPrefix); + // + // Set reachableNodeSetPrefix = + // graph.getReachableNodeSetByPrefix(node.getLocTuple().get(0)); + // System.out.println("reachableNodeSetPrefix=" + reachableNodeSetPrefix); List> prefixList = new ArrayList>(); - for (Iterator iterator = incomingNodeSet.iterator(); iterator.hasNext();) { + for (Iterator iterator = incomingNodeSetPrefix.iterator(); iterator.hasNext();) { GlobalFlowNode inNode = (GlobalFlowNode) iterator.next(); NTuple inNodeTuple = inNode.getLocTuple(); @@ -649,6 +713,35 @@ public class LocationInference { } }); return prefixList; + + // List> prefixList = new ArrayList>(); + // + // for (Iterator iterator = incomingNodeSet.iterator(); iterator.hasNext();) { + // GlobalFlowNode inNode = (GlobalFlowNode) iterator.next(); + // NTuple inNodeTuple = inNode.getLocTuple(); + // + // for (int i = 1; i < inNodeTuple.size(); i++) { + // NTuple prefix = inNodeTuple.subList(0, i); + // if (!prefixList.contains(prefix)) { + // prefixList.add(prefix); + // } + // } + // } + // + // Collections.sort(prefixList, new Comparator>() { + // public int compare(NTuple arg0, NTuple arg1) { + // int s0 = arg0.size(); + // int s1 = arg1.size(); + // if (s0 > s1) { + // return -1; + // } else if (s0 == s1) { + // return 0; + // } else { + // return 1; + // } + // } + // }); + // return prefixList; } private GlobalFlowGraph constructSubGlobalFlowGraph(FlowGraph flowGraph) { @@ -700,7 +793,7 @@ public class LocationInference { NTuple locTuple = new NTuple(); Descriptor enclosingDesc = md; - System.out.println("md=" + md + " descTuple=" + descTuple); + // System.out.println("md=" + md + " descTuple=" + descTuple); for (int i = 0; i < descTuple.size(); i++) { Descriptor desc = descTuple.get(i); @@ -841,7 +934,6 @@ public class LocationInference { NTuple callerSrcNodeLocTuple = translateToCallerLocTuple(min, mdCallee, mdCaller, calleeSrcNode.getLocTuple()); - if (callerSrcNodeLocTuple != null) { Set outNodeSet = calleeSubGlobalGraph.getOutNodeSet(calleeSrcNode); @@ -2350,12 +2442,13 @@ public class LocationInference { // parameters Set localReachSet = calleeFlowGraph.getLocalReachFlowNodeSetFrom(paramNode1); + System.out.println("-param1=" + paramNode1 + " is higher than param2=" + paramNode2); + System.out.println("-- localReachSet from param1=" + localReachSet); - if (arg1Tuple.size() > 0 && arg2Tuple.size() > 2 && localReachSet.contains(paramNode2)) { + if (arg1Tuple.size() > 0 && arg2Tuple.size() > 0 && localReachSet.contains(paramNode2)) { // need to propagate an ordering relation s.t. arg1 is higher // than arg2 - System.out.println("-param1=" + paramNode1 + " is higher than param2=" + paramNode2); System.out .println("-arg1Tuple=" + arg1Tuple + " is higher than arg2Tuple=" + arg2Tuple); @@ -2926,6 +3019,7 @@ public class LocationInference { NTuple srcCurTuple = srcNode.getCurrentDescTuple(); NTuple dstCurTuple = dstNode.getCurrentDescTuple(); + System.out.println("srcCurTuple=" + srcCurTuple + " dstCurTuple=" + dstCurTuple); if (srcCurTuple.get(idx).equals(dstCurTuple.get(idx)) && srcCurTuple.size() > (idx + 1) && dstCurTuple.size() > (idx + 1)) { // value flow between fields: we don't need to add a binary relation @@ -2937,9 +3031,14 @@ public class LocationInference { if (idx == 0) { classDesc = ((VarDescriptor) desc).getType().getClassDesc(); } else { - classDesc = ((FieldDescriptor) desc).getType().getClassDesc(); - } + if (desc instanceof FieldDescriptor) { + classDesc = ((FieldDescriptor) desc).getType().getClassDesc(); + } else { + // TODO: need to handle a location descriptor case + classDesc = null; + } + } extractFlowsBetweenFields(classDesc, srcNode, dstNode, idx + 1); } else { @@ -3017,6 +3116,21 @@ public class LocationInference { } + public boolean isTransitivelyCalledFrom(MethodDescriptor callee, MethodDescriptor caller) { + // if the callee is transitively invoked from the caller + // return true; + + int callerIdx = toanalyze_methodDescList.indexOf(caller); + int calleeIdx = toanalyze_methodDescList.indexOf(callee); + + if (callerIdx < calleeIdx) { + return true; + } + + return false; + + } + public void constructFlowGraph() { System.out.println(""); diff --git a/Robust/src/Analysis/SSJava/SSJavaLattice.java b/Robust/src/Analysis/SSJava/SSJavaLattice.java index ef1722b7..847cfecb 100644 --- a/Robust/src/Analysis/SSJava/SSJavaLattice.java +++ b/Robust/src/Analysis/SSJava/SSJavaLattice.java @@ -320,6 +320,8 @@ public class SSJavaLattice extends Lattice { } public void insertNewLocationBetween(T higher, Set lowerSet, T newLoc) { + System.out.println("---insert new location=" + newLoc + " between=" + higher + "<->" + + lowerSet); Set connectedSet = get(higher); connectedSet.removeAll(lowerSet); connectedSet.add(newLoc); -- 2.34.1