import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;
+import IR.State;
import Analysis.Disjoint.AllocSite;
import Analysis.Disjoint.DisjointAnalysis;
public static final int FINE_GRAIN_EDGE = 1;
public static final int COARSE_GRAIN_EDGE = 2;
public static final int CONFLICT = 3;
+ State state;
- public ConflictGraph() {
+ public ConflictGraph(State state) {
+ this.state=state;
id2cn = new Hashtable<String, ConflictNode>();
sese2te = new Hashtable<FlatNode, Hashtable<Taint, Set<Effect>>>();
}
}
}
} else {
+ if (state.RCR) {
+ //need coarse effects for RCR from just one pass
+ addCoarseEffect(nodeA, asA, effectA);
+ if (!nodeA.equals(nodeB)) {
+ addCoarseEffect(nodeB, asB, effectB);
+ }
+ }
return ConflictGraph.CONFLICT;
}
}
Set<FlatNew> sitesToFlag = new HashSet<FlatNew>();
calculateConflicts(sitesToFlag, false);
- // 9th pass, ask disjoint analysis to compute reachability
- // for objects that may cause heap conflicts so the most
- // efficient method to deal with conflict can be computed
- // later
- disjointAnalysisReach =
+ if (!state.RCR) {
+ // 9th pass, ask disjoint analysis to compute reachability
+ // for objects that may cause heap conflicts so the most
+ // efficient method to deal with conflict can be computed
+ // later
+
+ disjointAnalysisReach =
new DisjointAnalysis(state, typeUtil, callGraph, liveness, arrayReferencees, sitesToFlag,
- null, // don't do effects analysis again!
- null // don't do effects analysis again!
- );
- // 10th pass, calculate conflicts with reachability info
- calculateConflicts(null, true);
-
+ null, // don't do effects analysis again!
+ null // don't do effects analysis again!
+ );
+ // 10th pass, calculate conflicts with reachability info
+ calculateConflicts(null, true);
+ }
// 11th pass, compiling locks
synthesizeLocks();
ConflictGraph conflictGraph = sese2conflictGraph.get(seseStack.peek());
if (conflictGraph == null) {
- conflictGraph = new ConflictGraph();
+ conflictGraph = new ConflictGraph(state);
}
conflictGraph_nodeAction(fn, seseStack.peek());
}
conflictGraph = sese2conflictGraph.get(currentSESE.getParent());
if (conflictGraph == null) {
- conflictGraph = new ConflictGraph();
+ conflictGraph = new ConflictGraph(state);
}
FlatSESEEnterNode fsen = (FlatSESEEnterNode) fn;
conflictGraph = sese2conflictGraph.get(currentSESE);
if (conflictGraph == null) {
- conflictGraph = new ConflictGraph();
+ conflictGraph = new ConflictGraph(state);
}
if (fn instanceof FlatFieldNode) {
conflictGraph = sese2conflictGraph.get(currentSESE);
if (conflictGraph == null) {
- conflictGraph = new ConflictGraph();
+ conflictGraph = new ConflictGraph(state);
}
if (fn instanceof FlatSetFieldNode) {
case FKind.FlatCall: {
conflictGraph = sese2conflictGraph.get(currentSESE);
if (conflictGraph == null) {
- conflictGraph = new ConflictGraph();
+ conflictGraph = new ConflictGraph(state);
}
FlatCall fc = (FlatCall) fn;
try {
rcr = new RuntimeConflictResolver(PREFIX);
rcr.setGlobalEffects(oooa.getDisjointAnalysis().getEffectsAnalysis().getAllEffects());
- }
- catch (FileNotFoundException e) {
+ } catch (FileNotFoundException e) {
System.out.println("Runtime Conflict Resolver could not create output file.");
}
}
if(state.RCR && rcr != null) {
Analysis.OoOJava.ConflictGraph conflictGraph;
Hashtable<Taint, Set<Effect>> conflicts;
+
+ System.out.println("-------");
+ System.out.println(fsen);
+ System.out.println(fsen.getIsCallerSESEplaceholder());
+ System.out.println(fsen.getParent());
+
+ if (fsen.getParent()!=null) {
+ conflictGraph = oooa.getConflictGraph(fsen.getParent());
+ System.out.println("CG="+conflictGraph);
+ if (conflictGraph!=null)
+ System.out.println("Conflicts="+conflictGraph.getConflictEffectSet(fsen));
+ }
if(!fsen.getIsCallerSESEplaceholder() && fsen.getParent()!=null &&
(conflictGraph = oooa.getConflictGraph(fsen.getParent())) != null &&
- (conflicts = conflictGraph.getConflictEffectSet(fsen)) != null){
-
+ (conflicts = conflictGraph.getConflictEffectSet(fsen)) != null) {
FlatMethod fm=fsen.getfmEnclosing();
ReachGraph rg=oooa.getDisjointAnalysis().getReachGraph(fm.getMethod());
if(rcr.cSideDebug)
if((conflictGraph != null) &&
(conflicts = graph.getConflictEffectSet(fn)) != null &&
(rg != null)){
-
rcr.addToTraverseToDoList(fn, waitingElement.getTempDesc(), rg, conflicts);
}
}
* Note: All computation is done upon closing the object. Steps 1-3 only input data
*/
public class RuntimeConflictResolver {
- public static final boolean javaDebug = false;
+ public static final boolean javaDebug = true;
public static final boolean cSideDebug = false;
private PrintWriter cFile;
public void addToTraverseToDoList(FlatSESEEnterNode rblock, ReachGraph rg, Hashtable<Taint, Set<Effect>> conflicts) {
//Add to todo list
toTraverse.add(new TraversalInfo(rblock, rg));
-
+
//Add to Global conflicts
for(Taint t: conflicts.keySet()) {
if(globalConflicts.containsKey(t)) {
}
//This is to prevent duplicate traversals from being generated
- if(doneTaints.containsKey(taint) && doneTaints.get(taint) != null)
+ if(doneTaints.containsKey(taint))
return;
doneTaints.put(taint, traverserIDCounter++);
return;
}
- if(doneTaints.containsKey(taint) && doneTaints.get(taint) != null)
+ if(doneTaints.containsKey(taint))
return;
doneTaints.put(taint, traverserIDCounter++);
if(t.f instanceof FlatSESEEnterNode) {
traverseSESEBlock((FlatSESEEnterNode)t.f, t.rg);
- }
- else {
+ } else {
if(t.invar == null) {
System.out.println("RCR ERROR: Attempted to run a stall site traversal with NO INVAR");
- }
- else {
+ } else {
traverseStallSite(t.f, t.invar, t.rg);
}
}
cFile.println(" case " + doneTaints.get(t)+ ":");
if(t.isRBlockTaint()) {
cFile.println(" " + this.getTraverserInvocation(t.getVar(), "startingPtr", t.getSESE()));
- }
- else if (t.isStallSiteTaint()){
+ } else if (t.isStallSiteTaint()){
cFile.println(" " + this.getTraverserInvocation(t.getVar(), "startingPtr", t.getStallSite()));
} else {
System.out.println("RuntimeConflictResolver encountered a taint that is neither SESE nor stallsite: " + t);
if (table == null)
return;
- Iterator<RefEdge> possibleEdges = varNode.iteratorToReferencees();
+ Iterator<RefEdge> possibleEdges = varNode.iteratorToReferencees();
while (possibleEdges.hasNext()) {
RefEdge edge = possibleEdges.next();
assert edge != null;
bucket = new BucketOfEffects();
table.put(e.getAffectedAllocSite(), bucket);
}
- printDebug(javaDebug, "Added Taint" + t + " Effect " + e + "Conflict Status = " + (localConflicts!=null?localConflicts.contains(e):false));
+ printDebug(javaDebug, "Added Taint" + t + " Effect " + e + "Conflict Status = " + (localConflicts!=null?localConflicts.contains(e):false)+" localConflicts = "+localConflicts);
bucket.add(t, e, localConflicts!=null?localConflicts.contains(e):false);
}
}