this.liveness=liveness;
}
+ public boolean isAccessible(FlatNode fn, TempDescriptor tmp) {
+ for(int i=0;i<fn.numPrev();i++) {
+ FlatNode fprev=fn.getPrev(i);
+ if (inAccessible.containsKey(fprev)&&inAccessible.get(fprev).contains(tmp))
+ return false;
+ }
+ return true;
+ }
+
public void computeFixPoint() {
nextNode:
while(!toprocess.isEmpty()) {
Set<TempDescriptor> inAccess=inAccessible.get(fcall);
if (fcall.getReturnTemp()!=null&&!inAccess.contains(fcall.getReturnTemp())) {
inAccess.add(fcall.getReturnTemp());
- toprocess.add(new Pair<FlatNode, MethodDescriptor>(fcall, fcallpair.getSecond()));
+ for(int i=0;i<fcall.numNext();i++) {
+ toprocess.add(new Pair<FlatNode, MethodDescriptor>(fcall.getNext(i), fcallpair.getSecond()));
+ }
}
}
}
for(Object o:methodsthatcouldbecalled) {
MethodDescriptor md=(MethodDescriptor)o;
FlatMethod fm=state.getMethodFlat(md);
+
+ if (!methodmap.containsKey(md))
+ methodmap.put(md, new HashSet<Pair<FlatCall, MethodDescriptor>>());
+
+ methodmap.get(md).add(new Pair<FlatCall, MethodDescriptor>(fcall, pairmd));
+
HashSet<TempDescriptor> tmpinaccess=new HashSet<TempDescriptor>();
for(int i=0;i<fm.numParameters();i++) {
TempDescriptor fmtmp=fm.getParameter(i);
if (!tmpinaccess.isEmpty()&&(!inAccessible.containsKey(fm)||!inAccessible.get(fm).containsAll(tmpinaccess))) {
for(int i=0;i<fm.numNext();i++)
toprocess.add(new Pair<FlatNode, MethodDescriptor>(fm.getNext(i),md));
+ if (!inAccessible.containsKey(fm))
+ inAccessible.put(fm, new HashSet<TempDescriptor>());
inAccessible.get(fm).addAll(tmpinaccess);
}
}
//be sure not to wipe out return value or other inaccessible temps
- inAccessibleSet.addAll(inAccessible.get(fcall));
+ Set<TempDescriptor> oldtemps=inAccessible.get(fcall);
+ if (oldtemps!=null)
+ inAccessibleSet.addAll(oldtemps);
}
break;
default:
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;
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;
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) {
}
//DEBUG
- if (true) {
+ if (false) {
int debugindex=0;
for(Map.Entry<BBlock, Graph> e:bbgraphMap.entrySet()) {
Graph g=e.getValue();
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<Edge> 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<Edge> edges=GraphManip.getDiffEdges(delta, tmp);
for(Edge e:edges) {
Edge newe=e.addTaint(taint);
delta.addVarEdge(newe);
- System.out.println("DAdding Edge:"+newe);
}
}
}
for(Map.Entry<TempDescriptor, MySet<Edge>> e: delta.varedgeadd.entrySet()) {
TempDescriptor tmp=e.getKey();
MySet<Edge> edgestoadd=e.getValue();
- System.out.println("ADDING:"+edgestoadd);
if (graph.varMap.containsKey(tmp)) {
Edge.mergeEdgesInto(graph.varMap.get(tmp), edgestoadd);
} else
if (delta.getInit()) {
MySet<Edge> srcEdges=GraphManip.getEdges(graph, delta, src);
MySet<Edge> 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<Edge> edgesToAdd=GraphManip.genEdges(dstEdges, fd, srcEdges);
MySet<Edge> edgesToRemove=null;
if (dstEdges.size()==1&&!dstEdges.iterator().next().dst.isSummary()&&fd!=null) {
HashSet<AllocNode> dstNodes=GraphManip.getNodes(graph, delta, dst);
MySet<Edge> 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);
}
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
MySet<Edge> edgeAdd=delta.varedgeadd.get(tmp);
MySet<Edge> edgeRemove=delta.varedgeremove.get(tmp);
MySet<Edge> 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));
+ }
+ }
+ }
}
}
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));
+ }
}
}
}