FlatSESEEnterNode sese ) {
assert ts != null;
assert ts.isCanonical();
- assert sese != null;
// NEVER a cached result... (cry)
TaintSet out = new TaintSet();
import java.io.*;
-public class DisjointAnalysis {
+public class DisjointAnalysis implements HeapAnalysis {
///////////////////////////////////////////
//
Alloc affectedAlloc = edge.getDst();
Effect effect = new Effect(affectedAlloc, Effect.read, fld);
- for (Iterator<Taint> taintSetIter = taintSet.iterator(); taintSetIter.hasNext();) {
- Taint taint = taintSetIter.next();
- add(taint, effect, currentProgramPoint);
- }
+ if (taintSet!=null)
+ for (Taint taint:taintSet.getTaints()) {
+ add(taint, effect, currentProgramPoint);
+ }
}
}
TaintSet taintSet = edge.getTaints();
Alloc affectedAlloc = edge.getDst();
Effect effect = new Effect(affectedAlloc, Effect.write, fld);
- for (Iterator<Taint> taintSetIter = taintSet.iterator(); taintSetIter.hasNext();) {
- Taint taint = taintSetIter.next();
- add( taint, effect, currentProgramPoint );
- }
+ if (taintSet!=null)
+ for (Taint taint:taintSet.getTaints()) {
+ add( taint, effect, currentProgramPoint );
+ }
}
}
--- /dev/null
+package Analysis.Disjoint;
+import IR.Flat.FlatNew;
+
+public interface HeapAnalysis {
+ public EffectsAnalysis getEffectsAnalysis();
+ public Alloc getAllocationSiteFromFlatNew(FlatNew node);
+}
+
// either type of taint includes a var
// and allocation site
protected TempDescriptor var;
- protected AllocSite allocSite;
+ protected Alloc allocSite;
// taints have a new, possibly null element which is
// the FlatNode at which the tainted reference was
public static Taint factory( FlatSESEEnterNode sese,
TempDescriptor insetVar,
- AllocSite as,
+ Alloc as,
FlatNode whereDefined,
ExistPredSet eps ) {
Taint out = new Taint( sese, null, insetVar, as, whereDefined, eps );
public static Taint factory( FlatNode stallSite,
TempDescriptor var,
- AllocSite as,
+ Alloc as,
FlatNode whereDefined,
ExistPredSet eps ) {
Taint out = new Taint( null, stallSite, var, as, whereDefined, eps );
public static Taint factory( FlatSESEEnterNode sese,
FlatNode stallSite,
TempDescriptor var,
- AllocSite as,
+ Alloc as,
FlatNode whereDefined,
ExistPredSet eps ) {
Taint out = new Taint( sese, stallSite, var, as, whereDefined, eps );
protected Taint( FlatSESEEnterNode sese,
FlatNode stallSite,
TempDescriptor v,
- AllocSite as,
+ Alloc as,
FlatNode fnDefined,
ExistPredSet eps ) {
assert
return var;
}
- public AllocSite getAllocSite() {
+ public Alloc getAllocSite() {
return allocSite;
}
import java.util.Map.Entry;
import IR.State;
+import Analysis.Disjoint.Alloc;
import Analysis.Disjoint.AllocSite;
import Analysis.Disjoint.DisjointAnalysis;
import Analysis.Disjoint.Effect;
public void addStallSiteEffect(Taint t, Effect e) {
FlatNode fn = t.getStallSite();
TempDescriptor var = t.getVar();
- AllocSite as = t.getAllocSite();
+ Alloc as = t.getAllocSite();
String id = var + "_fn" + fn.hashCode();
ConflictNode node = id2cn.get(id);
FlatSESEEnterNode sese = t.getSESE();
TempDescriptor invar = t.getVar();
- AllocSite as = t.getAllocSite();
+ Alloc as = t.getAllocSite();
String id = invar + "_sese" + sese.getPrettyIdentifier();
ConflictNode node = id2cn.get(id);
private int calculateConflictType(ConflictNode node, boolean useReachInfo) {
int conflictType = ConflictGraph.NON_WRITE_CONFLICT;
- Hashtable<AllocSite, Set<Effect>> alloc2readEffects = node.getReadEffectSet();
- Hashtable<AllocSite, Set<Effect>> alloc2writeEffects = node.getWriteEffectSet();
- Hashtable<AllocSite, Set<Effect>> alloc2SUEffects = node.getStrongUpdateEffectSet();
+ Hashtable<Alloc, Set<Effect>> alloc2readEffects = node.getReadEffectSet();
+ Hashtable<Alloc, Set<Effect>> alloc2writeEffects = node.getWriteEffectSet();
+ Hashtable<Alloc, Set<Effect>> alloc2SUEffects = node.getStrongUpdateEffectSet();
conflictType =
updateConflictType(conflictType, determineConflictType(node, alloc2writeEffects, node,
int conflictType = ConflictGraph.NON_WRITE_CONFLICT;
- Hashtable<AllocSite, Set<Effect>> alloc2readEffectsA = nodeA.getReadEffectSet();
- Hashtable<AllocSite, Set<Effect>> alloc2writeEffectsA = nodeA.getWriteEffectSet();
- Hashtable<AllocSite, Set<Effect>> alloc2SUEffectsA = nodeA.getStrongUpdateEffectSet();
- Hashtable<AllocSite, Set<Effect>> alloc2readEffectsB = nodeB.getReadEffectSet();
- Hashtable<AllocSite, Set<Effect>> alloc2writeEffectsB = nodeB.getWriteEffectSet();
- Hashtable<AllocSite, Set<Effect>> alloc2SUEffectsB = nodeB.getStrongUpdateEffectSet();
+ Hashtable<Alloc, Set<Effect>> alloc2readEffectsA = nodeA.getReadEffectSet();
+ Hashtable<Alloc, Set<Effect>> alloc2writeEffectsA = nodeA.getWriteEffectSet();
+ Hashtable<Alloc, Set<Effect>> alloc2SUEffectsA = nodeA.getStrongUpdateEffectSet();
+ Hashtable<Alloc, Set<Effect>> alloc2readEffectsB = nodeB.getReadEffectSet();
+ Hashtable<Alloc, Set<Effect>> alloc2writeEffectsB = nodeB.getWriteEffectSet();
+ Hashtable<Alloc, Set<Effect>> alloc2SUEffectsB = nodeB.getStrongUpdateEffectSet();
// if node A has write effects on reading/writing regions of node B
conflictType =
}
private int hasStrongUpdateConflicts(ConflictNode nodeA,
- Hashtable<AllocSite, Set<Effect>> SUEffectsTableA, ConflictNode nodeB,
- Hashtable<AllocSite, Set<Effect>> readTableB, Hashtable<AllocSite, Set<Effect>> writeTableB,
+ Hashtable<Alloc, Set<Effect>> SUEffectsTableA, ConflictNode nodeB,
+ Hashtable<Alloc, Set<Effect>> readTableB, Hashtable<Alloc, Set<Effect>> writeTableB,
boolean useReachInfo) {
int conflictType = ConflictGraph.NON_WRITE_CONFLICT;
Iterator effectItrA = SUEffectsTableA.entrySet().iterator();
while (effectItrA.hasNext()) {
Map.Entry meA = (Map.Entry) effectItrA.next();
- AllocSite asA = (AllocSite) meA.getKey();
+ Alloc asA = (Alloc) meA.getKey();
Set<Effect> strongUpdateSetA = (Set<Effect>) meA.getValue();
Iterator effectItrB = readTableB.entrySet().iterator();
while (effectItrB.hasNext()) {
Map.Entry meB = (Map.Entry) effectItrB.next();
- AllocSite asB = (AllocSite) meB.getKey();
+ Alloc asB = (Alloc) meB.getKey();
Set<Effect> esB = (Set<Effect>) meB.getValue();
for (Iterator iterator = strongUpdateSetA.iterator(); iterator.hasNext();) {
effectItrB = writeTableB.entrySet().iterator();
while (effectItrB.hasNext()) {
Map.Entry meB = (Map.Entry) effectItrB.next();
- AllocSite asB = (AllocSite) meB.getKey();
+ Alloc asB = (Alloc) meB.getKey();
Set<Effect> esB = (Set<Effect>) meB.getValue();
for (Iterator iterator = strongUpdateSetA.iterator(); iterator.hasNext();) {
}
private int determineConflictType(ConflictNode nodeA,
- Hashtable<AllocSite, Set<Effect>> nodeAtable, ConflictNode nodeB,
- Hashtable<AllocSite, Set<Effect>> nodeBtable, boolean useReachInfo) {
+ Hashtable<Alloc, Set<Effect>> nodeAtable, ConflictNode nodeB,
+ Hashtable<Alloc, Set<Effect>> nodeBtable, boolean useReachInfo) {
int conflictType = ConflictGraph.NON_WRITE_CONFLICT;
Iterator effectItrA = nodeAtable.entrySet().iterator();
while (effectItrA.hasNext()) {
Map.Entry meA = (Map.Entry) effectItrA.next();
- AllocSite asA = (AllocSite) meA.getKey();
+ Alloc asA = (Alloc) meA.getKey();
Set<Effect> esA = (Set<Effect>) meA.getValue();
Iterator effectItrB = nodeBtable.entrySet().iterator();
while (effectItrB.hasNext()) {
Map.Entry meB = (Map.Entry) effectItrB.next();
- AllocSite asB = (AllocSite) meB.getKey();
+ Alloc asB = (Alloc) meB.getKey();
Set<Effect> esB = (Set<Effect>) meB.getValue();
for (Iterator iterator = esA.iterator(); iterator.hasNext();) {
return conflictType;
}
- private void addCoarseEffect(ConflictNode node, AllocSite as, Effect e) {
+ private void addCoarseEffect(ConflictNode node, Alloc as, Effect e) {
Taint t = node.getTaint(as);
addEffectSetByTaint(t, e);
}
import java.util.Iterator;
import java.util.Set;
+import Analysis.Disjoint.Alloc;
import Analysis.Disjoint.AllocSite;
import Analysis.Disjoint.Effect;
import Analysis.Disjoint.Taint;
public class ConflictNode {
protected HashSet<ConflictEdge> edgeSet;
- protected HashSet<AllocSite> allocSet;
+ protected HashSet<Alloc> allocSet;
protected HashSet<Taint> taintSet;
- protected Hashtable<AllocSite, Set<Effect>> alloc2readEffectSet;
- protected Hashtable<AllocSite, Set<Effect>> alloc2writeEffectSet;
- protected Hashtable<AllocSite, Set<Effect>> alloc2strongUpdateEffectSet;
+ protected Hashtable<Alloc, Set<Effect>> alloc2readEffectSet;
+ protected Hashtable<Alloc, Set<Effect>> alloc2writeEffectSet;
+ protected Hashtable<Alloc, Set<Effect>> alloc2strongUpdateEffectSet;
protected int nodeType;
protected String id;
edgeSet = new HashSet<ConflictEdge>();
// redundant views of access root's
// allocation sites for efficient retrieval
- allocSet = new HashSet<AllocSite>();
+ allocSet = new HashSet<Alloc>();
taintSet = new HashSet<Taint>();
- alloc2readEffectSet = new Hashtable<AllocSite, Set<Effect>>();
- alloc2writeEffectSet = new Hashtable<AllocSite, Set<Effect>>();
- alloc2strongUpdateEffectSet = new Hashtable<AllocSite, Set<Effect>>();
+ alloc2readEffectSet = new Hashtable<Alloc, Set<Effect>>();
+ alloc2writeEffectSet = new Hashtable<Alloc, Set<Effect>>();
+ alloc2strongUpdateEffectSet = new Hashtable<Alloc, Set<Effect>>();
this.id = id;
this.nodeType = nodeType;
taintSet.add(t);
}
- public Taint getTaint(AllocSite as) {
+ public Taint getTaint(Alloc as) {
for (Iterator iterator = taintSet.iterator(); iterator.hasNext();) {
Taint t = (Taint) iterator.next();
if (t.getAllocSite().equals(as)) {
return null;
}
- public void addEffect(AllocSite as, Effect e) {
+ public void addEffect(Alloc as, Effect e) {
if (e.getType() == Effect.read) {
addReadEffect(as, e);
} else if (e.getType() == Effect.write) {
}
}
- public void addReadEffect(AllocSite as, Effect e) {
+ public void addReadEffect(Alloc as, Effect e) {
allocSet.add(as);
Set<Effect> effectSet = alloc2readEffectSet.get(as);
if (effectSet == null) {
alloc2readEffectSet.put(as, effectSet);
}
- public void addWriteEffect(AllocSite as, Effect e) {
+ public void addWriteEffect(Alloc as, Effect e) {
allocSet.add(as);
Set<Effect> effectSet = alloc2writeEffectSet.get(as);
if (effectSet == null) {
alloc2writeEffectSet.put(as, effectSet);
}
- public void addStrongUpdateEffect(AllocSite as, Effect e) {
+ public void addStrongUpdateEffect(Alloc as, Effect e) {
allocSet.add(as);
Set<Effect> effectSet = alloc2strongUpdateEffectSet.get(as);
if (effectSet == null) {
alloc2strongUpdateEffectSet.put(as, effectSet);
}
- public Hashtable<AllocSite, Set<Effect>> getReadEffectSet() {
+ public Hashtable<Alloc, Set<Effect>> getReadEffectSet() {
return alloc2readEffectSet;
}
- public Hashtable<AllocSite, Set<Effect>> getWriteEffectSet() {
+ public Hashtable<Alloc, Set<Effect>> getWriteEffectSet() {
return alloc2writeEffectSet;
}
- public Hashtable<AllocSite, Set<Effect>> getStrongUpdateEffectSet() {
+ public Hashtable<Alloc, Set<Effect>> getStrongUpdateEffectSet() {
return alloc2strongUpdateEffectSet;
}
public Set<FlatNew> getFlatNewSet() {
Set<FlatNew> fnSet = new HashSet<FlatNew>();
for (Iterator iterator = allocSet.iterator(); iterator.hasNext();) {
- AllocSite as = (AllocSite) iterator.next();
+ Alloc as = (Alloc) iterator.next();
FlatNew fn = as.getFlatNew();
fnSet.add(fn);
}
import java.util.Stack;
import java.util.Map.Entry;
+import Analysis.Pointer.Pointer;
import Analysis.ArrayReferencees;
import Analysis.Liveness;
import Analysis.CallGraph.CallGraph;
+import Analysis.Disjoint.HeapAnalysis;
import Analysis.Disjoint.DisjointAnalysis;
import Analysis.Disjoint.Effect;
import Analysis.Disjoint.EffectsAnalysis;
private TypeUtil typeUtil;
private CallGraph callGraph;
private RBlockRelationAnalysis rblockRel;
- private DisjointAnalysis disjointAnalysisTaints;
+ private HeapAnalysis disjointAnalysisTaints;
private DisjointAnalysis disjointAnalysisReach;
private Set<MethodDescriptor> descriptorsToAnalyze;
return fm;
}
- public DisjointAnalysis getDisjointAnalysis() {
+ public HeapAnalysis getDisjointAnalysis() {
return disjointAnalysisTaints;
}
-
public OoOJavaAnalysis( State state,
TypeUtil typeUtil,
CallGraph callGraph,
// 5th pass, use disjointness with NO FLAGGED REGIONS
// to compute taints and effects
- disjointAnalysisTaints =
+ if (state.POINTER) {
+ disjointAnalysisTaints = new Pointer(state, typeUtil, callGraph, rblockRel);
+ ((Pointer)disjointAnalysisTaints).doAnalysis();
+ } else
+ disjointAnalysisTaints =
new DisjointAnalysis(state, typeUtil, callGraph, liveness, arrayReferencees, null,
rblockRel,
true ); // suppress output--this is an intermediate pass
if (state.OOODEBUG) {
try {
writeReports("");
- disjointAnalysisTaints.getEffectsAnalysis().writeEffects("effects.txt");
+ disjointAnalysisTaints.getEffectsAnalysis().writeEffects("effects.txt");
writeConflictGraph();
} catch (IOException e) {}
}
import IR.Flat.*;
public class AllocFactory {
+ public static AllocNode dummyNode=new AllocNode(-1, null, false);
+
public static class AllocNode implements Alloc {
int allocsite;
boolean summary;
import Analysis.Liveness;
import Analysis.Pointer.BasicBlock.BBlock;
import Analysis.Pointer.AllocFactory.AllocNode;
+import Analysis.Disjoint.Alloc;
import Analysis.Disjoint.Taint;
import Analysis.Disjoint.TaintSet;
import Analysis.Disjoint.Canonical;
+import Analysis.Disjoint.HeapAnalysis;
import Analysis.CallGraph.CallGraph;
import Analysis.OoOJava.RBlockRelationAnalysis;
+import Analysis.Disjoint.ExistPred;
+import Analysis.Disjoint.ReachGraph;
import Analysis.Disjoint.EffectsAnalysis;
import Analysis.Disjoint.BuildStateMachines;
import java.io.*;
-public class Pointer {
+public class Pointer implements HeapAnalysis{
HashMap<FlatMethod, BasicBlock> blockMap;
HashMap<BBlock, Graph> bbgraphMap;
HashMap<FlatNode, Graph> graphMap;
HashMap<BBlock, Set<PPoint>> returnMap;
HashMap<BBlock, Set<TempDescriptor>> bblivetemps;
- boolean OoOJava=false;
+ private boolean OoOJava=false;
CallGraph callGraph;
State state;
TypeUtil typeUtil;
TempDescriptor returntmp;
RBlockRelationAnalysis taskAnalysis;
EffectsAnalysis effectsAnalysis;
- BuildStateMachines buildStateMachines;
public Pointer(State state, TypeUtil typeUtil, CallGraph callGraph, RBlockRelationAnalysis taskAnalysis) {
this(state, typeUtil);
this.returntmp=new TempDescriptor("RETURNVAL", stringcd);
}
+ public EffectsAnalysis getEffectsAnalysis() {
+ return effectsAnalysis;
+ }
+
public BasicBlock getBBlock(FlatMethod fm) {
if (!blockMap.containsKey(fm)) {
blockMap.put(fm, BasicBlock.getBBlock(fm));
}
//DEBUG
- if (true) {
+ if (false) {
int debugindex=0;
for(Map.Entry<BBlock, Graph> e:bbgraphMap.entrySet()) {
Graph g=e.getValue();
debugindex++;
}
}
+ if (OoOJava) {
+ effectsAnalysis.buildStateMachines.writeStateMachines();
+ }
}
void plotGraph(Graph g, String name) {
if (delta.getInit()) {
removeInitTaints(null, delta, graph);
for (TempDescriptor tmp:sese.getInVarSet()) {
- Taint taint=Taint.factory(sese, null, tmp, null, sese, null);
+ 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);
}
}
} else {
- removeDiffTaints(null, delta, graph);
+ removeDiffTaints(null, delta);
for (TempDescriptor tmp:sese.getInVarSet()) {
- Taint taint=Taint.factory(sese, null, tmp, null, sese, null);
+ 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);
continue;
for(Edge e:entry.getValue()) {
//check whether this edge has been removed
- if (removemap==null&&removemap.containsKey(entry.getKey())&&
+ if (removemap!=null&&removemap.containsKey(entry.getKey())&&
removemap.get(entry.getKey()).contains(e))
continue;
//have real edge
}
}
- void removeDiffTaints(FlatSESEEnterNode sese, Delta delta, Graph graph) {
-
- }
-
/* This function compute the edges for the this variable for a
* callee if it exists. */
delta.addVarEdge(e);
}
}
-
+
+ public Alloc getAllocationSiteFromFlatNew(FlatNew node) {
+ return allocFactory.getAllocNode(node, false);
+ }
+
void processSumHeapEdgeSet(HashMap<AllocNode, MySet<Edge>> map, Delta delta, Graph graph) {
MySet<Edge> edgestoadd=new MySet<Edge>();
MySet<Edge> edgestoremove=new MySet<Edge>();
edgetoadd=origEdgeKey;
}
}
- if (seseCallers!=null)
+ if (seseCallers!=null&&edgetoadd!=null)
edgetoadd.taintModify(seseCallers);
mergeCallEdge(graph, newDelta, edgetoadd);
}
dst=ffn.getDst();
}
if (OoOJava&&taskAnalysis.isPotentialStallSite(node)) {
- taint=TaintSet.factory(Taint.factory(node, src, null, null, null));
+ taint=TaintSet.factory(Taint.factory(node, src, AllocFactory.dummyNode, null, ReachGraph.predsEmpty));
}
//Do nothing for non pointers
ConflictGraph conflictGraph;
ReachGraph rg;
Hashtable<Taint, Set<Effect>> conflicts;
- DisjointAnalysis disjointAnaylsis = oooa.getDisjointAnalysis();
+ DisjointAnalysis disjointAnalysis = (DisjointAnalysis) oooa.getDisjointAnalysis();
//Go through the SESE's
printDebug(generalDebug, "======================SESE's======================");
(parentSESE = (FlatSESEEnterNode) fsen.getParents().iterator().next()) != null &&
(conflictGraph = oooa.getConflictGraph(parentSESE)) != null &&
(conflicts = conflictGraph.getConflictEffectSet(fsen)) != null &&
- (rg = disjointAnaylsis.getEnterReachGraph(fsen)) != null ){
+ (rg = disjointAnalysis.getEnterReachGraph(fsen)) != null ){
addToTraverseToDoList(fsen, rg, conflicts, conflictGraph);
}
if( fsen.getParents().size() != 0 &&
(conflictGraph = oooa.getConflictGraph(fsen)) != null &&
(conflicts = conflictGraph.getConflictEffectSet(fn)) != null &&
- (rg = disjointAnaylsis.getEnterReachGraph(fn)) != null ){
+ (rg = disjointAnalysis.getEnterReachGraph(fn)) != null ){
Set<SESELock> seseLockSet = oooa.getLockMappings(conflictGraph);
Set<WaitingElement> waitingElementSet =
private void printoutTable(EffectsTable table) {
System.out.println("==============EFFECTS TABLE PRINTOUT==============");
- for(AllocSite as: table.table.keySet()) {
+ for(Alloc as: table.table.keySet()) {
System.out.println("\tFor AllocSite " + as.getUniqueAllocSiteID());
BucketOfEffects boe = table.table.get(as);
}
private class EffectsTable {
- private Hashtable<AllocSite, BucketOfEffects> table;
+ private Hashtable<Alloc, BucketOfEffects> table;
public EffectsTable(Hashtable<Taint, Set<Effect>> effects,
Hashtable<Taint, Set<Effect>> conflicts) {
- table = new Hashtable<AllocSite, BucketOfEffects>();
+ table = new Hashtable<Alloc, BucketOfEffects>();
// rehash all effects (as a 5-tuple) by their affected allocation site
for (Taint t : effects.keySet()) {
printoutTable(this);
}
- for(AllocSite key: table.keySet()) {
+ for(Alloc key: table.keySet()) {
BucketOfEffects effects = table.get(key);
//make sure there are actually conflicts in the bucket
if(effects.potentiallyConflictingRoots != null && !effects.potentiallyConflictingRoots.isEmpty()){