From: bdemsky Date: Mon, 21 Mar 2011 06:22:37 +0000 (+0000) Subject: fixing bugs... X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=6d26ad1d02cdc6937c61c34b3e06939217aba5bb;p=IRC.git fixing bugs... --- diff --git a/Robust/src/Analysis/Disjoint/BuildStateMachines.java b/Robust/src/Analysis/Disjoint/BuildStateMachines.java index 966555de..277e6c48 100644 --- a/Robust/src/Analysis/Disjoint/BuildStateMachines.java +++ b/Robust/src/Analysis/Disjoint/BuildStateMachines.java @@ -89,7 +89,8 @@ public class BuildStateMachines { // reads of pointers make a transition if( e.getType() == Effect.read && - e.getField().getType().isPtr() ) { + ((e.getField()!=null && e.getField().getType().isPtr()) + ||(e.getField()==null && e.getAffectedAllocSite().getFlatNew().getType().dereference().isPtr()))) { smfe.addTransition( whereDefined, currentProgramPoint, diff --git a/Robust/src/Analysis/Disjoint/Effect.java b/Robust/src/Analysis/Disjoint/Effect.java index 7084b869..5e59e005 100644 --- a/Robust/src/Analysis/Disjoint/Effect.java +++ b/Robust/src/Analysis/Disjoint/Effect.java @@ -63,7 +63,8 @@ public class Effect { if (affectedAllocSite.equals(in.getAffectedAllocSite()) && type == in.getType() - && field.equals(in.getField())) { + && ((field!=null&&field.equals(in.getField()))|| + (field==null&&in.getField()==null))) { return true; } else { return false; @@ -97,8 +98,11 @@ public class Effect { s += "SU"; } - s += ", " + field.toStringBrief(); - + if (field==null) { + s += ", []"; + } else { + s += ", " + field.toStringBrief(); + } return s + ")"; } diff --git a/Robust/src/Analysis/OoOJava/Accessible.java b/Robust/src/Analysis/OoOJava/Accessible.java index f0f1855a..4fffed1b 100644 --- a/Robust/src/Analysis/OoOJava/Accessible.java +++ b/Robust/src/Analysis/OoOJava/Accessible.java @@ -24,6 +24,15 @@ public class Accessible { this.liveness=liveness; } + public boolean isAccessible(FlatNode fn, TempDescriptor tmp) { + for(int i=0;i inAccess=inAccessible.get(fcall); if (fcall.getReturnTemp()!=null&&!inAccess.contains(fcall.getReturnTemp())) { inAccess.add(fcall.getReturnTemp()); - toprocess.add(new Pair(fcall, fcallpair.getSecond())); + for(int i=0;i(fcall.getNext(i), fcallpair.getSecond())); + } } } } @@ -91,6 +102,12 @@ public class Accessible { for(Object o:methodsthatcouldbecalled) { MethodDescriptor md=(MethodDescriptor)o; FlatMethod fm=state.getMethodFlat(md); + + if (!methodmap.containsKey(md)) + methodmap.put(md, new HashSet>()); + + methodmap.get(md).add(new Pair(fcall, pairmd)); + HashSet tmpinaccess=new HashSet(); for(int i=0;i(fm.getNext(i),md)); + if (!inAccessible.containsKey(fm)) + inAccessible.put(fm, new HashSet()); inAccessible.get(fm).addAll(tmpinaccess); } } //be sure not to wipe out return value or other inaccessible temps - inAccessibleSet.addAll(inAccessible.get(fcall)); + Set oldtemps=inAccessible.get(fcall); + if (oldtemps!=null) + inAccessibleSet.addAll(oldtemps); } break; default: diff --git a/Robust/src/Analysis/OoOJava/OoOJavaAnalysis.java b/Robust/src/Analysis/OoOJava/OoOJavaAnalysis.java index 8ea2f51b..d5e42ebe 100644 --- a/Robust/src/Analysis/OoOJava/OoOJavaAnalysis.java +++ b/Robust/src/Analysis/OoOJava/OoOJavaAnalysis.java @@ -179,7 +179,7 @@ public class OoOJavaAnalysis { // 5th pass, use disjointness with NO FLAGGED REGIONS // to compute taints and effects if (state.POINTER) { - disjointAnalysisTaints = new Pointer(state, typeUtil, callGraph, rblockRel); + disjointAnalysisTaints = new Pointer(state, typeUtil, callGraph, rblockRel, liveness); ((Pointer)disjointAnalysisTaints).doAnalysis(); } else disjointAnalysisTaints = diff --git a/Robust/src/Analysis/Pointer/Edge.java b/Robust/src/Analysis/Pointer/Edge.java index 23342c2a..af23b048 100644 --- a/Robust/src/Analysis/Pointer/Edge.java +++ b/Robust/src/Analysis/Pointer/Edge.java @@ -90,6 +90,15 @@ public class Edge { return newe; } + public Edge addTaintSet(TaintSet t) { + Edge newe=copy(); + if (newe.taints==null) + newe.taints=t; + else + newe.taints=newe.taints.merge(t); + return newe; + } + public void taintModify(Set seseSet) { if (taints!=null) taints=Canonical.removeSESETaints(taints, seseSet); @@ -249,6 +258,22 @@ public class Edge { } } + public static MySet taintAll(MySet orig, Taint t) { + MySet taintedEdges=new MySet(); + for(Edge e:orig) { + taintedEdges.add(e.addTaint(t)); + } + return taintedEdges; + } + + public static MySet taintAll(MySet orig, TaintSet t) { + MySet taintedEdges=new MySet(); + for(Edge e:orig) { + taintedEdges.add(e.addTaintSet(t)); + } + return taintedEdges; + } + public static void mergeEdgeInto(MySet orig, Edge e) { if (orig.contains(e)) { Edge old=orig.get(e); diff --git a/Robust/src/Analysis/Pointer/GraphManip.java b/Robust/src/Analysis/Pointer/GraphManip.java index b5a1aa08..34b3d1bc 100644 --- a/Robust/src/Analysis/Pointer/GraphManip.java +++ b/Robust/src/Analysis/Pointer/GraphManip.java @@ -248,6 +248,9 @@ public class GraphManip { static MySet dereference(Graph graph, Delta delta, TempDescriptor dst, MySet srcEdges, FieldDescriptor fd, FlatNode fn, TaintSet taint) { MySet edgeset=new MySet(); + if (taint!=null) { + edgeset.addAll(Edge.taintAll(srcEdges, taint)); + } for(Edge edge:srcEdges) { TaintSet ts=edge.getTaints(); if (ts!=null) { diff --git a/Robust/src/Analysis/Pointer/Pointer.java b/Robust/src/Analysis/Pointer/Pointer.java index 0ba6759b..030ab326 100644 --- a/Robust/src/Analysis/Pointer/Pointer.java +++ b/Robust/src/Analysis/Pointer/Pointer.java @@ -12,6 +12,7 @@ import Analysis.Disjoint.Canonical; import Analysis.Disjoint.HeapAnalysis; import Analysis.CallGraph.CallGraph; import Analysis.OoOJava.RBlockRelationAnalysis; +import Analysis.OoOJava.Accessible; import Analysis.Disjoint.ExistPred; import Analysis.Disjoint.ReachGraph; import Analysis.Disjoint.EffectsAnalysis; @@ -36,8 +37,9 @@ public class Pointer implements HeapAnalysis{ TempDescriptor returntmp; RBlockRelationAnalysis taskAnalysis; EffectsAnalysis effectsAnalysis; + Accessible accessible; - public Pointer(State state, TypeUtil typeUtil, CallGraph callGraph, RBlockRelationAnalysis taskAnalysis) { + public Pointer(State state, TypeUtil typeUtil, CallGraph callGraph, RBlockRelationAnalysis taskAnalysis, Liveness liveness) { this(state, typeUtil); this.callGraph=callGraph; this.OoOJava=true; @@ -45,6 +47,8 @@ public class Pointer implements HeapAnalysis{ this.effectsAnalysis=new EffectsAnalysis(); effectsAnalysis.state=state; effectsAnalysis.buildStateMachines=new BuildStateMachines(); + accessible=new Accessible(state, callGraph, taskAnalysis, liveness); + accessible.doAnalysis(); } public Pointer(State state, TypeUtil typeUtil) { @@ -167,7 +171,7 @@ public class Pointer implements HeapAnalysis{ } //DEBUG - if (true) { + if (false) { int debugindex=0; for(Map.Entry e:bbgraphMap.entrySet()) { Graph g=e.getValue(); @@ -440,25 +444,21 @@ public class Pointer implements HeapAnalysis{ if (delta.getInit()) { removeInitTaints(null, delta, graph); for (TempDescriptor tmp:sese.getInVarSet()) { - System.out.println("TMP variable:"+tmp); Taint taint=Taint.factory(sese, null, tmp, AllocFactory.dummyNode, sese, ReachGraph.predsEmpty); MySet edges=GraphManip.getEdges(graph, delta, tmp); for(Edge e:edges) { Edge newe=e.addTaint(taint); delta.addVarEdge(newe); - System.out.println("Adding Edge:"+newe); } } } else { removeDiffTaints(null, delta); for (TempDescriptor tmp:sese.getInVarSet()) { - System.out.println("TMP variable:"+tmp); Taint taint=Taint.factory(sese, null, tmp, AllocFactory.dummyNode, sese, ReachGraph.predsEmpty); MySet edges=GraphManip.getDiffEdges(delta, tmp); for(Edge e:edges) { Edge newe=e.addTaint(taint); delta.addVarEdge(newe); - System.out.println("DAdding Edge:"+newe); } } } @@ -1259,7 +1259,6 @@ public class Pointer implements HeapAnalysis{ for(Map.Entry> e: delta.varedgeadd.entrySet()) { TempDescriptor tmp=e.getKey(); MySet edgestoadd=e.getValue(); - System.out.println("ADDING:"+edgestoadd); if (graph.varMap.containsKey(tmp)) { Edge.mergeEdgesInto(graph.varMap.get(tmp), edgestoadd); } else @@ -1307,6 +1306,19 @@ public class Pointer implements HeapAnalysis{ if (delta.getInit()) { MySet srcEdges=GraphManip.getEdges(graph, delta, src); MySet dstEdges=GraphManip.getEdges(graph, delta, dst); + + if (OoOJava&&!accessible.isAccessible(node, src)) { + Taint srcStallTaint=Taint.factory(node, src, AllocFactory.dummyNode, node, ReachGraph.predsEmpty); + srcEdges=Edge.taintAll(srcEdges, srcStallTaint); + updateVarDelta(graph, delta, src, srcEdges, null); + } + + if (OoOJava&&!accessible.isAccessible(node, dst)) { + Taint dstStallTaint=Taint.factory(node, dst, AllocFactory.dummyNode, node, ReachGraph.predsEmpty); + dstEdges=Edge.taintAll(dstEdges, dstStallTaint); + updateVarDelta(graph, delta, dst, dstEdges, null); + } + MySet edgesToAdd=GraphManip.genEdges(dstEdges, fd, srcEdges); MySet edgesToRemove=null; if (dstEdges.size()==1&&!dstEdges.iterator().next().dst.isSummary()&&fd!=null) { @@ -1331,6 +1343,18 @@ public class Pointer implements HeapAnalysis{ HashSet dstNodes=GraphManip.getNodes(graph, delta, dst); MySet newDstEdges=GraphManip.getDiffEdges(delta, dst); + if (OoOJava&&!accessible.isAccessible(node, src)) { + Taint srcStallTaint=Taint.factory(node, src, AllocFactory.dummyNode, node, ReachGraph.predsEmpty); + newSrcEdges=Edge.taintAll(newSrcEdges, srcStallTaint); + updateVarDelta(graph, delta, src, newSrcEdges, null); + } + + if (OoOJava&&!accessible.isAccessible(node, dst)) { + Taint dstStallTaint=Taint.factory(node, dst, AllocFactory.dummyNode, node, ReachGraph.predsEmpty); + newDstEdges=Edge.taintAll(newDstEdges, dstStallTaint); + updateVarDelta(graph, delta, dst, newDstEdges, null); + } + if (OoOJava) { effectsAnalysis.analyzeFlatSetFieldNode(newDstEdges, fd, node); } @@ -1431,8 +1455,8 @@ public class Pointer implements HeapAnalysis{ fd=ffn.getField(); dst=ffn.getDst(); } - if (OoOJava&&taskAnalysis.isPotentialStallSite(node)) { - taint=TaintSet.factory(Taint.factory(node, src, AllocFactory.dummyNode, null, ReachGraph.predsEmpty)); + if (OoOJava&&!accessible.isAccessible(node, src)) { + taint=TaintSet.factory(Taint.factory(node, src, AllocFactory.dummyNode, node, ReachGraph.predsEmpty)); } //Do nothing for non pointers @@ -1476,21 +1500,31 @@ public class Pointer implements HeapAnalysis{ MySet edgeAdd=delta.varedgeadd.get(tmp); MySet edgeRemove=delta.varedgeremove.get(tmp); MySet existingEdges=graph.getEdges(tmp); - for(Edge e: edgestoRemove) { - //remove edge from delta - if (edgeAdd!=null) - edgeAdd.remove(e); - //if the edge is already in the graph, add an explicit remove to the delta - if (existingEdges.contains(e)) - delta.removeVarEdge(e); - } + if (edgestoRemove!=null) + for(Edge e: edgestoRemove) { + //remove edge from delta + if (edgeAdd!=null) + edgeAdd.remove(e); + //if the edge is already in the graph, add an explicit remove to the delta + if (existingEdges.contains(e)) + delta.removeVarEdge(e); + } for(Edge e: edgestoAdd) { //Remove the edge from the remove set if (edgeRemove!=null) edgeRemove.remove(e); //Explicitly add it to the add set unless it is already in the graph - if (!existingEdges.contains(e)&&typeUtil.isSuperorType(tmp.getType(),e.dst.getType())) - delta.addVarEdge(e); + if (typeUtil.isSuperorType(tmp.getType(), e.dst.getType())) { + if (!existingEdges.contains(e)) { + delta.addVarEdge(e); + } else { + //See if the old edge subsumes the new one + Edge olde=existingEdges.get(e); + if (!olde.subsumes(e)) { + delta.addVarEdge(olde.merge(e)); + } + } + } } } @@ -1517,8 +1551,14 @@ public class Pointer implements HeapAnalysis{ if (edgeRemove!=null) edgeRemove.remove(e); //Explicitly add it to the add set unless it is already in the graph - if (!existingEdges.contains(e)||!existingEdges.get(e).isNew()) { + if (!existingEdges.contains(e)) { delta.addHeapEdge(e); + } else { + //See if the old edge subsumes the new one + Edge olde=existingEdges.get(e); + if (!olde.subsumes(e)) { + delta.addHeapEdge(olde.merge(e)); + } } } }