From: yeom Date: Mon, 18 Apr 2011 22:22:41 +0000 (+0000) Subject: bug fixes: printing out linenum & source file name in the conflict graph. X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=71da589a9abd52699e5af0a4bbb0185b7d734989;p=IRC.git bug fixes: printing out linenum & source file name in the conflict graph. --- diff --git a/Robust/src/Analysis/OoOJava/ConflictGraph.java b/Robust/src/Analysis/OoOJava/ConflictGraph.java index b015625d..f4fd1b66 100644 --- a/Robust/src/Analysis/OoOJava/ConflictGraph.java +++ b/Robust/src/Analysis/OoOJava/ConflictGraph.java @@ -11,6 +11,8 @@ import java.util.Iterator; import java.util.Map; import java.util.Set; import java.util.Map.Entry; + +import IR.ClassDescriptor; import IR.State; import Util.Pair; @@ -37,11 +39,11 @@ public class ConflictGraph { public static final int NON_WRITE_CONFLICT = 0; public static final int FINE_GRAIN_EDGE = 1; public static final int COARSE_GRAIN_EDGE = 2; - + State state; public ConflictGraph(State state) { - this.state=state; + this.state = state; id2cn = new Hashtable(); sese2te = new Hashtable>>(); } @@ -73,7 +75,8 @@ public class ConflictGraph { } } - public void addStallSite(Hashtable> taint2Effects, TempDescriptor var) { + public void addStallSite(Hashtable> taint2Effects, TempDescriptor var, + ClassDescriptor cd) { if (taint2Effects == null) { return; } @@ -87,14 +90,14 @@ public class ConflictGraph { while (effectIter.hasNext()) { Effect effect = (Effect) effectIter.next(); if (taint.getVar().equals(var)) { - addStallSiteEffect(taint, effect); + addStallSiteEffect(taint, effect, cd); } } } } } - public void addStallSiteEffect(Taint t, Effect e) { + public void addStallSiteEffect(Taint t, Effect e, ClassDescriptor cd) { FlatNode fn = t.getStallSite(); TempDescriptor var = t.getVar(); Alloc as = t.getAllocSite(); @@ -102,7 +105,7 @@ public class ConflictGraph { String id = var + "_fn" + fn.hashCode(); ConflictNode node = id2cn.get(id); if (node == null) { - node = new ConflictNode(id, ConflictNode.STALLSITE, t.getVar(), t.getStallSite()); + node = new ConflictNode(id, ConflictNode.STALLSITE, t.getVar(), t.getStallSite(), cd); } node.addEffect(as, e); node.addTaint(t); @@ -209,8 +212,8 @@ public class ConflictGraph { if ((!currentNode.getID().equals(entryNodeID)) && !(analyzedIDSet.contains(currentNode.getID() + entryNodeID) || analyzedIDSet - .contains(entryNodeID + currentNode.getID()))) { - + .contains(entryNodeID + currentNode.getID()))) { + conflictType = calculateConflictType(currentNode, entryNode, useReachInfo); if (conflictType > ConflictGraph.NON_WRITE_CONFLICT) { addConflictEdge(conflictType, currentNode, entryNode); @@ -227,20 +230,22 @@ public class ConflictGraph { } private int calculateConflictType(ConflictNode node, boolean useReachInfo) { - + int conflictType = ConflictGraph.NON_WRITE_CONFLICT; - Hashtable> alloc2readEffects = node.getReadEffectSet(); - Hashtable> alloc2writeEffects = node.getWriteEffectSet(); - Hashtable> alloc2SUEffects = node.getStrongUpdateEffectSet(); + Hashtable> alloc2readEffects = node.getReadEffectSet(); + Hashtable> alloc2writeEffects = node.getWriteEffectSet(); + Hashtable> alloc2SUEffects = node.getStrongUpdateEffectSet(); conflictType = - updateConflictType(conflictType, determineConflictType(node, alloc2writeEffects, node, - alloc2writeEffects, useReachInfo)); + updateConflictType(conflictType, + determineConflictType(node, alloc2writeEffects, node, alloc2writeEffects, useReachInfo)); conflictType = - updateConflictType(conflictType, hasStrongUpdateConflicts(node, alloc2SUEffects, node, - alloc2readEffects, alloc2writeEffects, useReachInfo)); + updateConflictType( + conflictType, + hasStrongUpdateConflicts(node, alloc2SUEffects, node, alloc2readEffects, + alloc2writeEffects, useReachInfo)); return conflictType; } @@ -258,31 +263,41 @@ public class ConflictGraph { // if node A has write effects on reading/writing regions of node B conflictType = - updateConflictType(conflictType, determineConflictType(nodeA, alloc2writeEffectsA, nodeB, - alloc2readEffectsB, useReachInfo)); + updateConflictType( + conflictType, + determineConflictType(nodeA, alloc2writeEffectsA, nodeB, alloc2readEffectsB, + useReachInfo)); conflictType = - updateConflictType(conflictType, determineConflictType(nodeA, alloc2writeEffectsA, nodeB, - alloc2writeEffectsB, useReachInfo)); + updateConflictType( + conflictType, + determineConflictType(nodeA, alloc2writeEffectsA, nodeB, alloc2writeEffectsB, + useReachInfo)); // if node B has write effects on reading regions of node A conflictType = - updateConflictType(conflictType, determineConflictType(nodeB, alloc2writeEffectsB, nodeA, - alloc2readEffectsA, useReachInfo)); + updateConflictType( + conflictType, + determineConflictType(nodeB, alloc2writeEffectsB, nodeA, alloc2readEffectsA, + useReachInfo)); // strong udpate effects conflict with all effects // on objects that are reachable from the same heap roots // if node A has SU on regions of node B if (!alloc2SUEffectsA.isEmpty()) { conflictType = - updateConflictType(conflictType, hasStrongUpdateConflicts(nodeA, alloc2SUEffectsA, nodeB, - alloc2readEffectsB, alloc2writeEffectsB, useReachInfo)); + updateConflictType( + conflictType, + hasStrongUpdateConflicts(nodeA, alloc2SUEffectsA, nodeB, alloc2readEffectsB, + alloc2writeEffectsB, useReachInfo)); } // if node B has SU on regions of node A if (!alloc2SUEffectsB.isEmpty()) { conflictType = - updateConflictType(conflictType, hasStrongUpdateConflicts(nodeB, alloc2SUEffectsB, nodeA, - alloc2readEffectsA, alloc2writeEffectsA, useReachInfo)); + updateConflictType( + conflictType, + hasStrongUpdateConflicts(nodeB, alloc2SUEffectsB, nodeA, alloc2readEffectsA, + alloc2writeEffectsA, useReachInfo)); } return conflictType; @@ -332,7 +347,7 @@ public class ConflictGraph { if (!nodeA.equals(nodeB)) { addCoarseEffect(nodeB, asB, effectB); } - conflictType=ConflictGraph.COARSE_GRAIN_EDGE; + conflictType = ConflictGraph.COARSE_GRAIN_EDGE; } else { return ConflictGraph.COARSE_GRAIN_EDGE; } @@ -384,9 +399,8 @@ public class ConflictGraph { } - private int determineConflictType(ConflictNode nodeA, - Hashtable> nodeAtable, ConflictNode nodeB, - Hashtable> nodeBtable, boolean useReachInfo) { + private int determineConflictType(ConflictNode nodeA, Hashtable> nodeAtable, + ConflictNode nodeB, Hashtable> nodeBtable, boolean useReachInfo) { int conflictType = ConflictGraph.NON_WRITE_CONFLICT; @@ -408,8 +422,9 @@ public class ConflictGraph { Effect effectB = (Effect) iterator2.next(); if (effectA.getAffectedAllocSite().equals(effectB.getAffectedAllocSite()) - && ((effectA.getField()!=null&&effectB.getField()!=null&&effectA.getField().equals(effectB.getField()))|| - (effectA.getField()==null&&effectB.getField()==null))) { + && ((effectA.getField() != null && effectB.getField() != null && effectA.getField() + .equals(effectB.getField())) || (effectA.getField() == null && effectB + .getField() == null))) { if (useReachInfo) { FlatNew fnRoot1 = asA.getFlatNew(); @@ -446,7 +461,7 @@ public class ConflictGraph { if (!nodeA.equals(nodeB)) { addCoarseEffect(nodeB, asB, effectB); } - conflictType=ConflictGraph.COARSE_GRAIN_EDGE; + conflictType = ConflictGraph.COARSE_GRAIN_EDGE; } else { return ConflictGraph.COARSE_GRAIN_EDGE; } @@ -467,12 +482,12 @@ public class ConflictGraph { private void addEffectSetByTaint(Taint t, Effect e) { - FlatNode node=t.getSESE(); - if(node==null){ + FlatNode node = t.getSESE(); + if (node == null) { // stall site case - node=t.getStallSite(); + node = t.getStallSite(); } - + Hashtable> taint2Conflicts = sese2te.get(node); if (taint2Conflicts == null) { taint2Conflicts = new Hashtable>(); @@ -566,7 +581,7 @@ public class ConflictGraph { newElement.setStatus(seseLock.getNodeType(node)); newElement.setTempDesc(node.getVar()); if (isFineElement(newElement.getStatus())) { - newElement.setDynID(node.getVar().toString()); + newElement.setDynID(node.getVar().toString()); } if (!waitingElementSet.contains(newElement)) { waitingElementSet.add(newElement); @@ -583,7 +598,7 @@ public class ConflictGraph { // handle the case that multiple enqueues by an SESE for different live-in // into the same queue - return refineQueue(waitingElementSet); + return refineQueue(waitingElementSet); } @@ -602,7 +617,7 @@ public class ConflictGraph { set.add(waitingElement); map.put(new Integer(waitingElement.getQueueID()), set); } - + Set keySet = map.keySet(); for (Iterator iterator = keySet.iterator(); iterator.hasNext();) { Integer queueID = (Integer) iterator.next(); @@ -643,20 +658,20 @@ public class ConflictGraph { if (SCCelement != null) { // if there is at lease one SCC element, just enqueue SCC and // ignore others. - if(state.RCR){ + if (state.RCR) { // for rcr, we need to label all of coarse tempdescriptors // here assume that all waiting elements are coarse for (Iterator iterator = waitingElementSet.iterator(); iterator.hasNext();) { WaitingElement waitingElement = (WaitingElement) iterator.next(); SCCelement.addTempDesc(waitingElement.getTempDesc()); - if(waitingElement!=SCCelement){ + if (waitingElement != SCCelement) { waitingElement.setBogus(true); refinedSet.add(waitingElement); } } } refinedSet.add(SCCelement); - } else if (numCoarse == 1 && (numRead + numWrite == total)) { + } else if (numCoarse == 1 && (numRead + numWrite == total)) { // if one is a coarse, the othere are reads/write, enqueue SCC. WaitingElement we = new WaitingElement(); we.setQueueID(queueID); @@ -664,11 +679,11 @@ public class ConflictGraph { refinedSet.add(we); } else if (numCoarse == total) { // if there are multiple coarses, enqueue just one coarse. - if(state.RCR){ + if (state.RCR) { // for rcr, we need to label all of coarse tempdescriptors for (Iterator iterator = waitingElementSet.iterator(); iterator.hasNext();) { WaitingElement waitingElement = (WaitingElement) iterator.next(); - if(waitingElement!=coarseElement){ + if (waitingElement != coarseElement) { coarseElement.addTempDesc(waitingElement.getTempDesc()); waitingElement.setBogus(true); refinedSet.add(waitingElement); @@ -769,7 +784,7 @@ public class ConflictGraph { attributes += "label=\"" + node.getID() + "\\n"; if (node.isStallSiteNode()) { - String srcFileName = node.getVar().getType().getClassDesc().getSourceFileName(); + String srcFileName = node.getSourceFileName(); int separatorIdx = srcFileName.lastIndexOf(File.separator); if (separatorIdx > 0) { srcFileName = srcFileName.substring(separatorIdx + 1); @@ -816,7 +831,7 @@ public class ConflictGraph { bw.close(); } - + public Hashtable getId2cn() { return id2cn; } diff --git a/Robust/src/Analysis/OoOJava/ConflictNode.java b/Robust/src/Analysis/OoOJava/ConflictNode.java index 3b6c3019..2fac1199 100644 --- a/Robust/src/Analysis/OoOJava/ConflictNode.java +++ b/Robust/src/Analysis/OoOJava/ConflictNode.java @@ -9,6 +9,7 @@ import Analysis.Disjoint.Alloc; import Analysis.Disjoint.AllocSite; import Analysis.Disjoint.Effect; import Analysis.Disjoint.Taint; +import IR.ClassDescriptor; import IR.Flat.FlatNew; import IR.Flat.FlatNode; import IR.Flat.FlatSESEEnterNode; @@ -31,6 +32,8 @@ public class ConflictNode { protected FlatSESEEnterNode fsen; protected boolean toBePruned = false; + protected ClassDescriptor cd; + public boolean isTobePruned() { return toBePruned; } @@ -50,9 +53,11 @@ public class ConflictNode { public static final int INVAR = 0; public static final int STALLSITE = 1; - public ConflictNode(String id, int nodeType, TempDescriptor var, FlatNode stallSite) { + public ConflictNode(String id, int nodeType, TempDescriptor var, FlatNode stallSite, + ClassDescriptor cd) { this(id, var, nodeType); this.stallSite = stallSite; + this.cd = cd; } public ConflictNode(String id, int nodeType, TempDescriptor var, FlatSESEEnterNode fsen) { @@ -259,4 +264,8 @@ public class ConflictNode { return true; } + public String getSourceFileName() { + return cd.getSourceFileName(); + } + } diff --git a/Robust/src/Analysis/OoOJava/OoOJavaAnalysis.java b/Robust/src/Analysis/OoOJava/OoOJavaAnalysis.java index 2bf261e8..2b1a839d 100644 --- a/Robust/src/Analysis/OoOJava/OoOJavaAnalysis.java +++ b/Robust/src/Analysis/OoOJava/OoOJavaAnalysis.java @@ -62,24 +62,24 @@ public class OoOJavaAnalysis { return codePlans.keySet(); } - public ContextTaskNames getContextTaskNames( FlatMethod fm ) { - ContextTaskNames out = fn2contextTaskNames.get( fm ); - if( out == null ) { + public ContextTaskNames getContextTaskNames(FlatMethod fm) { + ContextTaskNames out = fn2contextTaskNames.get(fm); + if (out == null) { out = new ContextTaskNames(); } return out; } - public ContextTaskNames getContextTaskNames( FlatSESEEnterNode fsen ) { - ContextTaskNames out = fn2contextTaskNames.get( fsen ); - if( out == null ) { + public ContextTaskNames getContextTaskNames(FlatSESEEnterNode fsen) { + ContextTaskNames out = fn2contextTaskNames.get(fsen); + if (out == null) { out = new ContextTaskNames(); } return out; } - public FlatMethod getContainingFlatMethod( FlatNode fn ) { - FlatMethod fm = fn2fm.get( fn ); + public FlatMethod getContainingFlatMethod(FlatNode fn) { + FlatMethod fm = fn2fm.get(fn); assert fm != null; return fm; } @@ -92,34 +92,31 @@ public class OoOJavaAnalysis { return buildStateMachines; } - public OoOJavaAnalysis( State state, - TypeUtil typeUtil, - CallGraph callGraph, - Liveness liveness, - ArrayReferencees arrayReferencees ) { + public OoOJavaAnalysis(State state, TypeUtil typeUtil, CallGraph callGraph, Liveness liveness, + ArrayReferencees arrayReferencees) { State.logEvent("Starting OoOJavaAnalysis"); - this.state = state; - this.typeUtil = typeUtil; - this.callGraph = callGraph; - this.liveness = liveness; + this.state = state; + this.typeUtil = typeUtil; + this.callGraph = callGraph; + this.liveness = liveness; this.maxSESEage = state.OOO_MAXSESEAGE; - livenessGlobalView = new Hashtable>(); - livenessVirtualReads = new Hashtable>(); - variableResults = new Hashtable(); - notAvailableResults = new Hashtable>(); - codePlans = new Hashtable(); - wdvNodesToSpliceIn = new Hashtable(); - notAvailableIntoSESE = new Hashtable>(); - sese2conflictGraph = new Hashtable(); + livenessGlobalView = new Hashtable>(); + livenessVirtualReads = new Hashtable>(); + variableResults = new Hashtable(); + notAvailableResults = new Hashtable>(); + codePlans = new Hashtable(); + wdvNodesToSpliceIn = new Hashtable(); + notAvailableIntoSESE = new Hashtable>(); + sese2conflictGraph = new Hashtable(); conflictGraph2SESELock = new Hashtable>(); - fn2contextTaskNames = new Hashtable(); - fn2fm = new Hashtable(); + fn2contextTaskNames = new Hashtable(); + fn2fm = new Hashtable(); // state machines support heap examiners with // state transitions to improve precision - if( state.RCR ) { + if (state.RCR) { buildStateMachines = new BuildStateMachines(); } @@ -132,14 +129,13 @@ public class OoOJavaAnalysis { descriptorsToAnalyze.add(mdSourceEntry); - // 0th pass, setup a useful mapping of any flat node to the // flat method it is a part of Iterator methItr = descriptorsToAnalyze.iterator(); while (methItr.hasNext()) { Descriptor d = methItr.next(); - FlatMethod fm = state.getMethodFlat( d ); - buildFlatNodeToFlatMethod( fm ); + FlatMethod fm = state.getMethodFlat(d); + buildFlatNodeToFlatMethod(fm); } State.logEvent("OoOJavaAnalysis Oth pass completed"); @@ -149,14 +145,12 @@ public class OoOJavaAnalysis { State.logEvent("OoOJavaAnalysis 1st pass completed"); - // 2nd pass, liveness, in-set out-set (no virtual reads yet!) Iterator seseItr = rblockRel.getLocalRootSESEs().iterator(); while (seseItr.hasNext()) { FlatSESEEnterNode sese = seseItr.next(); livenessAnalysisBackward(sese); } - State.logEvent("OoOJavaAnalysis 2nd pass completed"); @@ -164,14 +158,14 @@ public class OoOJavaAnalysis { methItr = rblockRel.getMethodsWithSESEs().iterator(); while (methItr.hasNext()) { Descriptor d = methItr.next(); - FlatMethod fm = state.getMethodFlat(d); - // starting from roots do a forward, fixed-point - // variable analysis for refinement and stalls - variableAnalysisForward(fm); + FlatMethod fm = state.getMethodFlat(d); + // starting from roots do a forward, fixed-point + // variable analysis for refinement and stalls + variableAnalysisForward(fm); } - + State.logEvent("OoOJavaAnalysis 3rd pass completed"); - + // 4th pass, compute liveness contribution from // virtual reads discovered in variable pass seseItr = rblockRel.getLocalRootSESEs().iterator(); @@ -179,19 +173,20 @@ public class OoOJavaAnalysis { FlatSESEEnterNode sese = seseItr.next(); livenessAnalysisBackward(sese); } - + State.logEvent("OoOJavaAnalysis 4th pass completed"); // 5th pass, use disjointness with NO FLAGGED REGIONS // to compute taints and effects if (state.POINTER) { - disjointAnalysisTaints = new Pointer(state, typeUtil, callGraph, rblockRel, liveness, buildStateMachines); - ((Pointer)disjointAnalysisTaints).doAnalysis(); + disjointAnalysisTaints = + new Pointer(state, typeUtil, callGraph, rblockRel, liveness, buildStateMachines); + ((Pointer) disjointAnalysisTaints).doAnalysis(); } else disjointAnalysisTaints = - new DisjointAnalysis(state, typeUtil, callGraph, liveness, arrayReferencees, null, - rblockRel, buildStateMachines, - true ); // suppress output--this is an intermediate pass + new DisjointAnalysis(state, typeUtil, callGraph, liveness, arrayReferencees, null, + rblockRel, buildStateMachines, true); // suppress output--this is + // an intermediate pass State.logEvent("OoOJavaAnalysis 5th pass completed"); @@ -208,29 +203,28 @@ public class OoOJavaAnalysis { // 7th pass, start conflict graphs where a parent's graph has a // node for possibly conflicting children and its own stall sites startConflictGraphs(); - State.logEvent("OoOJavaAnalysis 7th pass completed"); + State.logEvent("OoOJavaAnalysis 7th pass completed"); // 8th pass, calculate all possible conflicts without using // reachability info and identify set of FlatNew that next // disjoint reach. analysis should flag Set sitesToFlag = new HashSet(); calculateConflicts(sitesToFlag, false); - State.logEvent("OoOJavaAnalysis 8th pass completed"); + State.logEvent("OoOJavaAnalysis 8th pass completed"); 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 + // later disjointAnalysisReach = - new DisjointAnalysis(state, typeUtil, callGraph, liveness, - arrayReferencees, sitesToFlag, - null, // don't do effects analysis again! - null, // no BuildStateMachines needed - !state.OOODEBUG // only print out in OoOJava debug mode - ); - State.logEvent("OoOJavaAnalysis 9th pass completed"); + new DisjointAnalysis(state, typeUtil, callGraph, liveness, arrayReferencees, sitesToFlag, + null, // don't do effects analysis again! + null, // no BuildStateMachines needed + !state.OOODEBUG // only print out in OoOJava debug mode + ); + State.logEvent("OoOJavaAnalysis 9th pass completed"); // 10th pass, calculate conflicts with reachability info calculateConflicts(null, true); - State.logEvent("OoOJavaAnalysis 10th pass completed"); + State.logEvent("OoOJavaAnalysis 10th pass completed"); } else { // in RCR/DFJ we want to do some extra processing on the // state machines before they get handed off to code gen, @@ -238,13 +232,13 @@ public class OoOJavaAnalysis { // to identify heap examiners that are weakly connected, so // accomplish both at the same time pruneMachinesAndFindWeaklyConnectedExaminers(); - State.logEvent("OoOJavaAnalysis RCR pruneMachines pass completed"); + State.logEvent("OoOJavaAnalysis RCR pruneMachines pass completed"); } - // 11th pass, compiling memory Qs! The name "lock" is a legacy + // 11th pass, compiling memory Qs! The name "lock" is a legacy // term for the heap dependence queue, or memQ as the runtime calls it synthesizeLocks(); - State.logEvent("OoOJavaAnalysis 11th pass completed"); + State.logEvent("OoOJavaAnalysis 11th pass completed"); // 12th pass, compute a plan for code injections methItr = descriptorsToAnalyze.iterator(); @@ -254,7 +248,7 @@ public class OoOJavaAnalysis { codePlansForward(fm); } - State.logEvent("OoOJavaAnalysis 12th pass completed"); + State.logEvent("OoOJavaAnalysis 12th pass completed"); // 13th pass, // splice new IR nodes into graph after all // analysis passes are complete @@ -264,58 +258,53 @@ public class OoOJavaAnalysis { FlatWriteDynamicVarNode fwdvn = (FlatWriteDynamicVarNode) me.getValue(); fwdvn.spliceIntoIR(); } - State.logEvent("OoOJavaAnalysis 13th pass completed"); + State.logEvent("OoOJavaAnalysis 13th pass completed"); if (state.OOODEBUG) { try { writeReports(""); - disjointAnalysisTaints.getEffectsAnalysis().writeEffects("effects.txt"); + disjointAnalysisTaints.getEffectsAnalysis().writeEffects("effects.txt"); writeConflictGraph(); - } catch (IOException e) {} + } catch (IOException e) { + } } - State.logEvent("OoOJavaAnalysis completed"); + State.logEvent("OoOJavaAnalysis completed"); } - - private void buildFlatNodeToFlatMethod( FlatMethod fm ) { + private void buildFlatNodeToFlatMethod(FlatMethod fm) { Set flatNodesToVisit = new HashSet(); - flatNodesToVisit.add( fm ); + flatNodesToVisit.add(fm); Set flatNodesVisited = new HashSet(); - while( !flatNodesToVisit.isEmpty() ) { + while (!flatNodesToVisit.isEmpty()) { FlatNode fn = (FlatNode) flatNodesToVisit.iterator().next(); - flatNodesToVisit.remove( fn ); - flatNodesVisited.add( fn ); + flatNodesToVisit.remove(fn); + flatNodesVisited.add(fn); - fn2fm.put( fn, fm ); + fn2fm.put(fn, fm); - for( int i = 0; i < fn.numNext(); i++ ) { - FlatNode nn = fn.getNext( i ); - if( !flatNodesVisited.contains( nn ) ) { - flatNodesToVisit.add( nn ); + for (int i = 0; i < fn.numNext(); i++) { + FlatNode nn = fn.getNext(i); + if (!flatNodesVisited.contains(nn)) { + flatNodesToVisit.add(nn); } } } } - - // debug routine - /* - * Iterator iter = sese2conflictGraph.entrySet().iterator(); while - * (iter.hasNext()) { Entry e = (Entry) iter.next(); FlatNode fn = - * (FlatNode) e.getKey(); ConflictGraph conflictGraph = (ConflictGraph) - * e.getValue(); - * System.out.println("---------------------------------------"); - * System.out.println("CONFLICT GRAPH for " + fn); Set keySet = - * conflictGraph.id2cn.keySet(); for (Iterator iterator = keySet.iterator(); - * iterator.hasNext();) { String key = (String) iterator.next(); - * ConflictNode node = conflictGraph.id2cn.get(key); - * System.out.println("key=" + key + " \n" + node.toStringAllEffects()); } } - */ - - - + // debug routine + /* + * Iterator iter = sese2conflictGraph.entrySet().iterator(); while + * (iter.hasNext()) { Entry e = (Entry) iter.next(); FlatNode fn = (FlatNode) + * e.getKey(); ConflictGraph conflictGraph = (ConflictGraph) e.getValue(); + * System.out.println("---------------------------------------"); + * System.out.println("CONFLICT GRAPH for " + fn); Set keySet = + * conflictGraph.id2cn.keySet(); for (Iterator iterator = keySet.iterator(); + * iterator.hasNext();) { String key = (String) iterator.next(); ConflictNode + * node = conflictGraph.id2cn.get(key); System.out.println("key=" + key + + * " \n" + node.toStringAllEffects()); } } + */ private void writeFile(Set sitesToFlag) { @@ -333,59 +322,56 @@ public class OoOJavaAnalysis { } - private void livenessAnalysisBackward(FlatSESEEnterNode fsen) { // flow backward across nodes to compute liveness, and // take special care with sese enter/exit nodes that // alter this from normal liveness analysis Set flatNodesToVisit = new HashSet(); -// flatNodesToVisit.add( fm.getFlatExit() ); + // flatNodesToVisit.add( fm.getFlatExit() ); flatNodesToVisit.add(fsen.getFlatExit()); - while( !flatNodesToVisit.isEmpty() ) { + while (!flatNodesToVisit.isEmpty()) { FlatNode fn = (FlatNode) flatNodesToVisit.iterator().next(); - flatNodesToVisit.remove( fn ); + flatNodesToVisit.remove(fn); - Set prev = livenessGlobalView.get( fn ); + Set prev = livenessGlobalView.get(fn); // merge sets from control flow joins Set livein = new HashSet(); for (int i = 0; i < fn.numNext(); i++) { - FlatNode nn = fn.getNext( i ); - Set s = livenessGlobalView.get( nn ); - if( s != null ) { - livein.addAll( s ); + FlatNode nn = fn.getNext(i); + Set s = livenessGlobalView.get(nn); + if (s != null) { + livein.addAll(s); } } - - Set curr = liveness_nodeActions( fn, livein ); + + Set curr = liveness_nodeActions(fn, livein); // if a new result, schedule backward nodes for analysis - if( !curr.equals( prev ) ) { + if (!curr.equals(prev)) { - if(fn!=fsen){ - livenessGlobalView.put( fn, curr ); - for( int i = 0; i < fn.numPrev(); i++ ) { - FlatNode nn = fn.getPrev( i ); - flatNodesToVisit.add( nn ); + if (fn != fsen) { + livenessGlobalView.put(fn, curr); + for (int i = 0; i < fn.numPrev(); i++) { + FlatNode nn = fn.getPrev(i); + flatNodesToVisit.add(nn); } - } + } } } } - private Set liveness_nodeActions( FlatNode fn, - Set liveIn - ) { - switch( fn.kind() ) { + private Set liveness_nodeActions(FlatNode fn, Set liveIn) { + switch (fn.kind()) { case FKind.FlatSESEEnterNode: { // add whatever is live-in at a task enter to that // task's in-var set - FlatSESEEnterNode fsen = (FlatSESEEnterNode)fn; - if( liveIn != null ) { - fsen.addInVarSet( liveIn ); + FlatSESEEnterNode fsen = (FlatSESEEnterNode) fn; + if (liveIn != null) { + fsen.addInVarSet(liveIn); } // no break, should also execute default actions } @@ -393,41 +379,41 @@ public class OoOJavaAnalysis { default: { // handle effects of statement in reverse, writes then reads TempDescriptor[] writeTemps = fn.writesTemps(); - for( int i = 0; i < writeTemps.length; ++i ) { - liveIn.remove( writeTemps[i] ); + for (int i = 0; i < writeTemps.length; ++i) { + liveIn.remove(writeTemps[i]); // if we are analyzing code declared directly in a task, - FlatSESEEnterNode fsen = rblockRel.getLocalInnerRBlock( fn ); - if( fsen != null ) { + FlatSESEEnterNode fsen = rblockRel.getLocalInnerRBlock(fn); + if (fsen != null) { // check to see if we are writing to variables that will // be live-out at the task's exit (and therefore should // go in the task's out-var set) FlatSESEExitNode fsexn = fsen.getFlatExit(); - //note: liveness analysis can have corresponding decisions - Set livetemps= liveness.getLiveInTemps(fsen.getfmEnclosing(), fsexn); - if( livetemps != null && livetemps.contains( writeTemps[i] ) ) { - fsen.addOutVar( writeTemps[i] ); - } + // note: liveness analysis can have corresponding decisions + Set livetemps = liveness.getLiveInTemps(fsen.getfmEnclosing(), fsexn); + if (livetemps != null && livetemps.contains(writeTemps[i])) { + fsen.addOutVar(writeTemps[i]); + } } } TempDescriptor[] readTemps = fn.readsTemps(); - for( int i = 0; i < readTemps.length; ++i ) { - liveIn.add( readTemps[i] ); + for (int i = 0; i < readTemps.length; ++i) { + liveIn.add(readTemps[i]); } - Set virtualReadTemps = livenessVirtualReads.get( fn ); - if( virtualReadTemps != null ) { - liveIn.addAll( virtualReadTemps ); - } - } break; + Set virtualReadTemps = livenessVirtualReads.get(fn); + if (virtualReadTemps != null) { + liveIn.addAll(virtualReadTemps); + } + } + break; } // end switch return liveIn; } - private void variableAnalysisForward(FlatMethod fm) { Set flatNodesToVisit = new HashSet(); @@ -447,11 +433,11 @@ public class OoOJavaAnalysis { curr.merge(incoming); } - FlatSESEEnterNode currentSESE = rblockRel.getLocalInnerRBlock( fn ); - if( currentSESE == null ) { + FlatSESEEnterNode currentSESE = rblockRel.getLocalInnerRBlock(fn); + if (currentSESE == null) { currentSESE = rblockRel.getCallerProxySESE(); } - + variable_nodeActions(fn, curr, currentSESE); // if a new result, schedule forward nodes for analysis @@ -466,12 +452,10 @@ public class OoOJavaAnalysis { } } - private void variable_nodeActions(FlatNode fn, - VarSrcTokTable vstTable, - FlatSESEEnterNode currentSESE) { + private void variable_nodeActions(FlatNode fn, VarSrcTokTable vstTable, + FlatSESEEnterNode currentSESE) { switch (fn.kind()) { - case FKind.FlatSESEEnterNode: { FlatSESEEnterNode fsen = (FlatSESEEnterNode) fn; // ignore currently executing SESE, at this point @@ -479,8 +463,8 @@ public class OoOJavaAnalysis { // the current SESE vstTable.age(fsen); vstTable.assertConsistency(); - } break; - + } + break; case FKind.FlatSESEExitNode: { FlatSESEExitNode fsexn = (FlatSESEExitNode) fn; @@ -496,12 +480,10 @@ public class OoOJavaAnalysis { // written by an SESE and should be added to the in-set // anything virtually read by this SESE should be pruned // of parent or sibling sources - Set liveVars = liveness.getLiveInTemps(fsen.getfmEnclosing(), - fn); + Set liveVars = liveness.getLiveInTemps(fsen.getfmEnclosing(), fn); Set fsenVirtReads = - vstTable.calcVirtReadsAndPruneParentAndSiblingTokens(fsen, - liveVars); + vstTable.calcVirtReadsAndPruneParentAndSiblingTokens(fsen, liveVars); Set fsenVirtReadsOld = livenessVirtualReads.get(fn); if (fsenVirtReadsOld != null) { @@ -510,8 +492,7 @@ public class OoOJavaAnalysis { livenessVirtualReads.put(fn, fsenVirtReads); // virtual reads are forced in-vars! - fsen.addInVarSet( fsenVirtReads ); - + fsen.addInVarSet(fsenVirtReads); // then all child out-set tokens are guaranteed // to be filled in, so clobber those entries with @@ -526,8 +507,8 @@ public class OoOJavaAnalysis { vstTable.add(vst); } vstTable.assertConsistency(); - } break; - + } + break; case FKind.FlatOpNode: { FlatOpNode fon = (FlatOpNode) fn; @@ -549,34 +530,26 @@ public class OoOJavaAnalysis { // when we do x = y for variables, just copy over from a child, // there are two cases: - // 1. if the current task is the caller proxy, any local root is a child - boolean case1 = - currentSESE.getIsCallerProxySESE() && - rblockRel.getLocalRootSESEs().contains( vst.getSESE() ); - - // 2. if the child task is a locally-defined child of the current task - boolean case2 = currentSESE.getLocalChildren().contains( vst.getSESE() ); - - if( case1 || case2 ) { + // 1. if the current task is the caller proxy, any local root is a + // child + boolean case1 = + currentSESE.getIsCallerProxySESE() + && rblockRel.getLocalRootSESEs().contains(vst.getSESE()); + + // 2. if the child task is a locally-defined child of the current task + boolean case2 = currentSESE.getLocalChildren().contains(vst.getSESE()); + + if (case1 || case2) { // if the source comes from a child, copy it over - forAddition.add( new VariableSourceToken( ts, - vst.getSESE(), - vst.getAge(), - vst.getAddrVar() - ) - ); + forAddition.add(new VariableSourceToken(ts, vst.getSESE(), vst.getAge(), vst + .getAddrVar())); } else { // otherwise, stamp it as us as the source - forAddition.add( new VariableSourceToken( ts, - currentSESE, - new Integer( 0 ), - lhs - ) - ); + forAddition.add(new VariableSourceToken(ts, currentSESE, new Integer(0), lhs)); } } - vstTable.addAll( forAddition ); + vstTable.addAll(forAddition); // only break if this is an ASSIGN op node, // otherwise fall through to default case @@ -589,36 +562,31 @@ public class OoOJavaAnalysis { // fall through to this default case default: { TempDescriptor[] writeTemps = fn.writesTemps(); - if( writeTemps.length > 0 ) { + if (writeTemps.length > 0) { // for now, when writeTemps > 1, make sure // its a call node, programmer enforce only // doing stuff like calling a print routine - if( writeTemps.length > 1 ) { + if (writeTemps.length > 1) { assert fn.kind() == FKind.FlatCall || fn.kind() == FKind.FlatMethod; break; } - vstTable.remove( writeTemps[0] ); + vstTable.remove(writeTemps[0]); HashSet ts = new HashSet(); - ts.add( writeTemps[0] ); - - vstTable.add( new VariableSourceToken( ts, - currentSESE, - new Integer( 0 ), - writeTemps[0] - ) - ); + ts.add(writeTemps[0]); + + vstTable.add(new VariableSourceToken(ts, currentSESE, new Integer(0), writeTemps[0])); } vstTable.assertConsistency(); - } break; + } + break; } // end switch } - private void notAvailableForward(FlatMethod fm) { Set flatNodesToVisit = new HashSet(); @@ -639,8 +607,8 @@ public class OoOJavaAnalysis { } } - FlatSESEEnterNode currentSESE = rblockRel.getLocalInnerRBlock( fn ); - if( currentSESE == null ) { + FlatSESEEnterNode currentSESE = rblockRel.getLocalInnerRBlock(fn); + if (currentSESE == null) { currentSESE = rblockRel.getCallerProxySESE(); } @@ -658,10 +626,8 @@ public class OoOJavaAnalysis { } } - private void notAvailable_nodeActions(FlatNode fn, - Set notAvailSet, - FlatSESEEnterNode currentSESE - ) { + private void notAvailable_nodeActions(FlatNode fn, Set notAvailSet, + FlatSESEEnterNode currentSESE) { // any temps that are removed from the not available set // at this node should be marked in this node's code plan @@ -682,7 +648,8 @@ public class OoOJavaAnalysis { notAvailableIntoSESE.put(fsen, notAvailCopy); notAvailSet.clear(); - } break; + } + break; case FKind.FlatSESEExitNode: { FlatSESEExitNode fsexn = (FlatSESEExitNode) fn; @@ -693,11 +660,13 @@ public class OoOJavaAnalysis { Set notAvailIn = notAvailableIntoSESE.get(fsen); assert notAvailIn != null; notAvailSet.addAll(notAvailIn); - } break; + } + break; case FKind.FlatMethod: { notAvailSet.clear(); - } break; + } + break; case FKind.FlatOpNode: { FlatOpNode fon = (FlatOpNode) fn; @@ -766,12 +735,12 @@ public class OoOJavaAnalysis { } } } - } break; + } + break; } // end switch } - private void codePlansForward(FlatMethod fm) { // start from flat method top, visit every node in @@ -808,14 +777,12 @@ public class OoOJavaAnalysis { Set dotSTlive = livenessGlobalView.get(fn); - FlatSESEEnterNode currentSESE = rblockRel.getLocalInnerRBlock( fn ); - if( currentSESE == null ) { + FlatSESEEnterNode currentSESE = rblockRel.getLocalInnerRBlock(fn); + if (currentSESE == null) { currentSESE = rblockRel.getCallerProxySESE(); } - codePlans_nodeActions(fm, fn, - dotSTtable, dotSTnotAvailSet, - currentSESE); + codePlans_nodeActions(fm, fn, dotSTtable, dotSTnotAvailSet, currentSESE); for (int i = 0; i < fn.numNext(); i++) { FlatNode nn = fn.getNext(i); @@ -826,12 +793,9 @@ public class OoOJavaAnalysis { } } } - - private void codePlans_nodeActions(FlatMethod fm, - FlatNode fn, - VarSrcTokTable vstTableIn, - Set notAvailSetIn, - FlatSESEEnterNode currentSESE) { + + private void codePlans_nodeActions(FlatMethod fm, FlatNode fn, VarSrcTokTable vstTableIn, + Set notAvailSetIn, FlatSESEEnterNode currentSESE) { CodePlan plan = new CodePlan(currentSESE); @@ -853,11 +817,11 @@ public class OoOJavaAnalysis { // in order to classify in-vars correctly, pass // the parent SESE in--at other FlatNode types just // use the currentSESE - FlatSESEEnterNode parent = rblockRel.getLocalInnerRBlock( fn ); - if( parent == null ) { + FlatSESEEnterNode parent = rblockRel.getLocalInnerRBlock(fn); + if (parent == null) { parent = rblockRel.getCallerProxySESE(); } - + VSTWrapper vstIfStatic = new VSTWrapper(); Integer srcType = vstTableIn.getRefVarSrcType(inVar, parent, vstIfStatic); @@ -865,7 +829,7 @@ public class OoOJavaAnalysis { // variable and the child needs space in its SESE record if (srcType.equals(VarSrcTokTable.SrcType_DYNAMIC)) { fsen.addDynamicInVar(inVar); - addDynamicVar( parent, fm, inVar ); + addDynamicVar(parent, fm, inVar); } else if (srcType.equals(VarSrcTokTable.SrcType_STATIC)) { fsen.addStaticInVar(inVar); @@ -878,7 +842,8 @@ public class OoOJavaAnalysis { fsen.addReadyInVar(inVar); } } - } break; + } + break; case FKind.FlatSESEExitNode: { FlatSESEExitNode fsexn = (FlatSESEExitNode) fn; @@ -889,34 +854,32 @@ public class OoOJavaAnalysis { FlatSESEEnterNode exiter = fsexn.getFlatEnter(); Iterator outVarItr = exiter.getOutVarSet().iterator(); - while( outVarItr.hasNext() ) { + while (outVarItr.hasNext()) { TempDescriptor outVar = outVarItr.next(); - + VSTWrapper vstIfStatic = new VSTWrapper(); - Integer srcType = vstTableIn.getRefVarSrcType( outVar, - exiter, - vstIfStatic - ); + Integer srcType = vstTableIn.getRefVarSrcType(outVar, exiter, vstIfStatic); - if( srcType.equals( VarSrcTokTable.SrcType_DYNAMIC ) ) { + if (srcType.equals(VarSrcTokTable.SrcType_DYNAMIC)) { // if the out-var is dynamic, put it in the set of dyn out vars // so exiting code gen knows to look for the value, but also put // it in the set of dynamic vars the exiter must track! - exiter.addDynamicOutVar( outVar ); - addDynamicVar( exiter, fm, outVar ); + exiter.addDynamicOutVar(outVar); + addDynamicVar(exiter, fm, outVar); - } else if( srcType.equals( VarSrcTokTable.SrcType_STATIC ) ) { - exiter.addStaticOutVar( outVar ); + } else if (srcType.equals(VarSrcTokTable.SrcType_STATIC)) { + exiter.addStaticOutVar(outVar); VariableSourceToken vst = vstIfStatic.vst; - exiter.putStaticOutVar2src( outVar, vst ); - exiter.addStaticOutVarSrc( new SESEandAgePair( vst.getSESE(), vst.getAge() ) ); + exiter.putStaticOutVar2src(outVar, vst); + exiter.addStaticOutVarSrc(new SESEandAgePair(vst.getSESE(), vst.getAge())); } else { - assert srcType.equals( VarSrcTokTable.SrcType_READY ); - exiter.addReadyOutVar( outVar ); + assert srcType.equals(VarSrcTokTable.SrcType_READY); + exiter.addReadyOutVar(outVar); } } - } break; + } + break; case FKind.FlatOpNode: { FlatOpNode fon = (FlatOpNode) fn; @@ -936,9 +899,9 @@ public class OoOJavaAnalysis { if (rhsSrcType.equals(VarSrcTokTable.SrcType_DYNAMIC)) { // if rhs is dynamic going in, lhs will definitely be dynamic // going out of this node, so track that here - plan.addDynAssign( lhs, rhs ); - addDynamicVar( currentSESE, fm, lhs ); - addDynamicVar( currentSESE, fm, rhs ); + plan.addDynAssign(lhs, rhs); + addDynamicVar(currentSESE, fm, lhs); + addDynamicVar(currentSESE, fm, rhs); } else if (lhsSrcType.equals(VarSrcTokTable.SrcType_DYNAMIC)) { // otherwise, if the lhs is dynamic, but the rhs is not, we @@ -958,9 +921,9 @@ public class OoOJavaAnalysis { // a node with no live set has nothing to stall for // note: no reason to check here, remove this.... -// if (liveSetIn == null) { -// break; -// } + // if (liveSetIn == null) { + // break; + // } TempDescriptor[] readarray = fn.readsTemps(); for (int i = 0; i < readarray.length; i++) { @@ -981,8 +944,8 @@ public class OoOJavaAnalysis { // come from, so dynamically we must keep track // along various control paths, and therefore when we stall, // just stall for the exact thing we need and move on - plan.addDynamicStall( readtmp ); - addDynamicVar( currentSESE, fm, readtmp ); + plan.addDynamicStall(readtmp); + addDynamicVar(currentSESE, fm, readtmp); } else if (srcType.equals(VarSrcTokTable.SrcType_STATIC)) { // 2) Single token/age pair: Stall for token/age pair, and copy @@ -1001,11 +964,12 @@ public class OoOJavaAnalysis { Set copySet = new HashSet(); Iterator refVarItr = vstAlsoAvail.getRefVars().iterator(); - + while (refVarItr.hasNext()) { TempDescriptor refVar = refVarItr.next(); - //note: this should just use normal liveness in...only want to copy live variables... - if(liveness.getLiveInTemps(fm, fn).contains(refVar)){ + // note: this should just use normal liveness in...only want to + // copy live variables... + if (liveness.getLiveInTemps(fm, fn).contains(refVar)) { copySet.add(refVar); } } @@ -1042,44 +1006,42 @@ public class OoOJavaAnalysis { // the caller proxy generates useful analysis facts, but we // never need to generate another name for it in code (it is // ALWAYS the task executing the local method context) - if( vst.getSESE().getIsCallerProxySESE() ) { + if (vst.getSESE().getIsCallerProxySESE()) { continue; } - SESEandAgePair sap = new SESEandAgePair( vst.getSESE(), vst.getAge() ); - sap.getSESE().mustTrackAtLeastAge( sap.getAge() ); + SESEandAgePair sap = new SESEandAgePair(vst.getSESE(), vst.getAge()); + sap.getSESE().mustTrackAtLeastAge(sap.getAge()); FlatSESEEnterNode sese = currentSESE; - while( sese != null ) { - addNeededStaticName( sese, fm, sap ); + while (sese != null) { + addNeededStaticName(sese, fm, sap); sese = sese.getLocalParent(); } } codePlans.put(fn, plan); - - - - // if any variables at this-node-*dot* have a static source (exactly one vst) + // if any variables at this-node-*dot* have a static source (exactly one + // vst) // but go to a dynamic source at next-node-*dot*, create a new IR graph // node on that edge to track the sources dynamically - // NOTE: for this calculation use the currentSESE variable, except when the + // NOTE: for this calculation use the currentSESE variable, except when the // FlatNode fn is an Exit--in that case currentSESE is for the exiting task, // be we want to consider that the parent is tracking a variable coming out // of the exiting task FlatSESEEnterNode fsenDoingTracking; - if( fn instanceof FlatSESEExitNode ) { + if (fn instanceof FlatSESEExitNode) { fsenDoingTracking = currentSESE.getLocalParent(); - if( fsenDoingTracking == null ) { + if (fsenDoingTracking == null) { // if there is no local parent, there are one of two cases // 1) the current task is main, in which case this FlatNode - // is the main's exit, and doesn't need to do any of the - // following dynamic tracking + // is the main's exit, and doesn't need to do any of the + // following dynamic tracking // 2) the current task is defined in a method, so use the - // caller proxy in the variable source calcs below - if( currentSESE.equals( rblockRel.getMainSESE() ) ) { + // caller proxy in the variable source calcs below + if (currentSESE.equals(rblockRel.getMainSESE())) { return; } else { fsenDoingTracking = rblockRel.getCallerProxySESE(); @@ -1089,13 +1051,13 @@ public class OoOJavaAnalysis { fsenDoingTracking = currentSESE; } - VarSrcTokTable thisVstTable = variableResults.get(fn); for (int i = 0; i < fn.numNext(); i++) { FlatNode nn = fn.getNext(i); VarSrcTokTable nextVstTable = variableResults.get(nn); - // note: using the result of liveness analysis regardless of task structures - Set nextLiveIn=liveness.getLiveInTemps(fm, nn); + // note: using the result of liveness analysis regardless of task + // structures + Set nextLiveIn = liveness.getLiveInTemps(fm, nn); // the table can be null if it is one of the few IR nodes // completely outside of the root SESE scope @@ -1112,7 +1074,8 @@ public class OoOJavaAnalysis { FlatWriteDynamicVarNode fwdvn = wdvNodesToSpliceIn.get(fe); if (fwdvn == null) { - fwdvn = new FlatWriteDynamicVarNode(fn, nn, readyOrStatic2dynamicSet, fsenDoingTracking); + fwdvn = + new FlatWriteDynamicVarNode(fn, nn, readyOrStatic2dynamicSet, fsenDoingTracking); wdvNodesToSpliceIn.put(fe, fwdvn); } else { fwdvn.addMoreVar2Src(readyOrStatic2dynamicSet); @@ -1122,14 +1085,13 @@ public class OoOJavaAnalysis { } } - private void addDynamicVar( FlatSESEEnterNode fsen, - FlatMethod fm, - TempDescriptor var ) { + private void addDynamicVar(FlatSESEEnterNode fsen, FlatMethod fm, TempDescriptor var) { FlatNode fnContext; - - // note: dynamic variable declarations are always located in the flat method that encloses task block + + // note: dynamic variable declarations are always located in the flat method + // that encloses task block // there is no need to set fnContext to fsen - if( fsen.getIsCallerProxySESE() ) { + if (fsen.getIsCallerProxySESE()) { // attach the dynamic variable to track to // the flat method, so it can be declared at entry fnContext = fm; @@ -1137,24 +1099,22 @@ public class OoOJavaAnalysis { // otherwise the code context is a task body fnContext = fsen; } - //fnContext=fm; + // fnContext=fm; - ContextTaskNames ctn = fn2contextTaskNames.get( fnContext ); - if( ctn == null ) { + ContextTaskNames ctn = fn2contextTaskNames.get(fnContext); + if (ctn == null) { ctn = new ContextTaskNames(); } - ctn.addDynamicVar( var ); - fn2contextTaskNames.put( fnContext, ctn ); - + ctn.addDynamicVar(var); + fn2contextTaskNames.put(fnContext, ctn); + } - private void addNeededStaticName( FlatSESEEnterNode fsen, - FlatMethod fm, - SESEandAgePair sap ) { + private void addNeededStaticName(FlatSESEEnterNode fsen, FlatMethod fm, SESEandAgePair sap) { FlatNode fnContext; - if( fsen.getIsCallerProxySESE() ) { + if (fsen.getIsCallerProxySESE()) { // attach the dynamic variable to track to // the flat method, so it can be declared at entry fnContext = fm; @@ -1163,116 +1123,111 @@ public class OoOJavaAnalysis { fnContext = fsen; } - ContextTaskNames ctn = fn2contextTaskNames.get( fnContext ); - if( ctn == null ) { + ContextTaskNames ctn = fn2contextTaskNames.get(fnContext); + if (ctn == null) { ctn = new ContextTaskNames(); } - ctn.addNeededStaticName( sap ); + ctn.addNeededStaticName(sap); - fn2contextTaskNames.put( fnContext, ctn ); + fn2contextTaskNames.put(fnContext, ctn); } - private void startConflictGraphs() { // first, for each task, consider whether it has any children, and if // effects analysis says they should be a conflict node in the that // parent's conflict graph Set allSESEs = rblockRel.getAllSESEs(); - for( Iterator iterator = allSESEs.iterator(); iterator.hasNext(); ) { + for (Iterator iterator = allSESEs.iterator(); iterator.hasNext();) { FlatSESEEnterNode parent = (FlatSESEEnterNode) iterator.next(); - if( parent.getIsLeafSESE() ) { + if (parent.getIsLeafSESE()) { continue; } EffectsAnalysis effectsAnalysis = disjointAnalysisTaints.getEffectsAnalysis(); - ConflictGraph conflictGraph = sese2conflictGraph.get( parent ); + ConflictGraph conflictGraph = sese2conflictGraph.get(parent); assert conflictGraph == null; - conflictGraph = new ConflictGraph( state ); + conflictGraph = new ConflictGraph(state); Set children = parent.getChildren(); - for( Iterator iterator2 = children.iterator(); iterator2.hasNext(); ) { + for (Iterator iterator2 = children.iterator(); iterator2.hasNext();) { FlatSESEEnterNode child = (FlatSESEEnterNode) iterator2.next(); - Hashtable> taint2Effects = effectsAnalysis.get( child ); - conflictGraph.addLiveIn( taint2Effects ); + Hashtable> taint2Effects = effectsAnalysis.get(child); + conflictGraph.addLiveIn(taint2Effects); } - sese2conflictGraph.put( parent, conflictGraph ); + sese2conflictGraph.put(parent, conflictGraph); } // then traverse all methods looking for potential stall sites, and // add those stall sites as nodes in any task's conflict graph that // might be executing at the point of the stall site Iterator descItr = descriptorsToAnalyze.iterator(); - while( descItr.hasNext() ) { + while (descItr.hasNext()) { MethodDescriptor md = descItr.next(); - FlatMethod fm = state.getMethodFlat( md ); - if( fm != null ) { - addStallSitesToConflictGraphs( fm ); + FlatMethod fm = state.getMethodFlat(md); + if (fm != null) { + addStallSitesToConflictGraphs(fm); } - } + } } - private void addStallSitesToConflictGraphs( FlatMethod fm ) { + private void addStallSitesToConflictGraphs(FlatMethod fm) { Set flatNodesToVisit = new HashSet(); - flatNodesToVisit.add( fm ); + flatNodesToVisit.add(fm); Set visited = new HashSet(); - while( !flatNodesToVisit.isEmpty() ) { + while (!flatNodesToVisit.isEmpty()) { FlatNode fn = (FlatNode) flatNodesToVisit.iterator().next(); - flatNodesToVisit.remove( fn ); - visited.add( fn ); + flatNodesToVisit.remove(fn); + visited.add(fn); - Set currentSESEs = - rblockRel.getPossibleExecutingRBlocks( fn ); + Set currentSESEs = rblockRel.getPossibleExecutingRBlocks(fn); - conflictGraph_nodeAction( fn, currentSESEs ); + conflictGraph_nodeAction(fn, currentSESEs, fm.getMethod().getClassDesc()); // schedule forward nodes for analysis - for( int i = 0; i < fn.numNext(); i++ ) { - FlatNode nn = fn.getNext( i ); - if( !visited.contains( nn ) ) { - flatNodesToVisit.add( nn ); + for (int i = 0; i < fn.numNext(); i++) { + FlatNode nn = fn.getNext(i); + if (!visited.contains(nn)) { + flatNodesToVisit.add(nn); } } } } - private void conflictGraph_nodeAction( FlatNode fn, - Set currentSESEs - ) { + private void conflictGraph_nodeAction(FlatNode fn, Set currentSESEs, + ClassDescriptor cd) { EffectsAnalysis effectsAnalysis = disjointAnalysisTaints.getEffectsAnalysis(); - Hashtable> taint2Effects = effectsAnalysis.get( fn ); - + Hashtable> taint2Effects = effectsAnalysis.get(fn); // repeat the process of adding a stall site to a conflict graph // for each task that might be executing at a possible stall site Iterator seseItr = currentSESEs.iterator(); - while( seseItr.hasNext() ) { + while (seseItr.hasNext()) { FlatSESEEnterNode currentSESE = seseItr.next(); - ConflictGraph conflictGraph = sese2conflictGraph.get( currentSESE ); - if( conflictGraph == null ) { + ConflictGraph conflictGraph = sese2conflictGraph.get(currentSESE); + if (conflictGraph == null) { assert currentSESE.getIsLeafSESE(); continue; } TempDescriptor lhs; TempDescriptor rhs; - - switch( fn.kind() ) { + switch (fn.kind()) { case FKind.FlatFieldNode: case FKind.FlatElementNode: { - if( fn instanceof FlatFieldNode ) { + if (fn instanceof FlatFieldNode) { FlatFieldNode ffn = (FlatFieldNode) fn; rhs = ffn.getSrc(); } else { @@ -1280,14 +1235,14 @@ public class OoOJavaAnalysis { rhs = fen.getSrc(); } - conflictGraph.addStallSite( taint2Effects, rhs ); - } break; - + conflictGraph.addStallSite(taint2Effects, rhs, cd); + } + break; case FKind.FlatSetFieldNode: case FKind.FlatSetElementNode: { - if( fn instanceof FlatSetFieldNode ) { + if (fn instanceof FlatSetFieldNode) { FlatSetFieldNode fsfn = (FlatSetFieldNode) fn; lhs = fsfn.getDst(); rhs = fsfn.getSrc(); @@ -1297,29 +1252,28 @@ public class OoOJavaAnalysis { rhs = fsen.getSrc(); } - conflictGraph.addStallSite( taint2Effects, rhs ); - conflictGraph.addStallSite( taint2Effects, lhs ); - } break; - + conflictGraph.addStallSite(taint2Effects, rhs, cd); + conflictGraph.addStallSite(taint2Effects, lhs, cd); + } + break; case FKind.FlatCall: { FlatCall fc = (FlatCall) fn; lhs = fc.getThis(); - conflictGraph.addStallSite( taint2Effects, lhs ); - } break; + conflictGraph.addStallSite(taint2Effects, lhs, cd); + } + break; } - - if( conflictGraph.id2cn.size() > 0 ) { - sese2conflictGraph.put( currentSESE, conflictGraph ); + + if (conflictGraph.id2cn.size() > 0) { + sese2conflictGraph.put(currentSESE, conflictGraph); } } } - - private void calculateConflicts( Set sitesToFlag, - boolean useReachInfo ) { + private void calculateConflicts(Set sitesToFlag, boolean useReachInfo) { // decide fine-grain edge or coarse-grain edge among all vertexes by // pair-wise comparison @@ -1339,7 +1293,6 @@ public class OoOJavaAnalysis { } } - private void writeConflictGraph() { Enumeration keyEnum = sese2conflictGraph.keys(); while (keyEnum.hasMoreElements()) { @@ -1356,25 +1309,23 @@ public class OoOJavaAnalysis { } } - // the traversal for pruning state machines and finding // machines that are weakly connected BOTH consider conflicting // effects between heap roots, so it is smart to compute all of // this together public void pruneMachinesAndFindWeaklyConnectedExaminers() { - ProcessStateMachines psm=new ProcessStateMachines(buildStateMachines, rblockRel); + ProcessStateMachines psm = new ProcessStateMachines(buildStateMachines, rblockRel); psm.doProcess(); buildStateMachines.writeStateMachines("pruned"); } - - private void synthesizeLocks() { // for every conflict graph, generate a set of memory queues // (called SESELock in this code!) to cover the graph Set> graphEntrySet = sese2conflictGraph.entrySet(); for (Iterator iterator = graphEntrySet.iterator(); iterator.hasNext();) { - Map.Entry graphEntry = (Map.Entry) iterator.next(); + Map.Entry graphEntry = + (Map.Entry) iterator.next(); FlatNode sese = graphEntry.getKey(); ConflictGraph conflictGraph = graphEntry.getValue(); calculateCovering(conflictGraph); @@ -1519,7 +1470,7 @@ public class OoOJavaAnalysis { } } while (changed); - HashSet notCovered=new HashSet(); + HashSet notCovered = new HashSet(); do { // coarse changed = false; int type; @@ -1534,18 +1485,18 @@ public class OoOJavaAnalysis { // and it is not parent type = ConflictNode.SCC; } else { - if(state.RCR){ + if (state.RCR) { type = ConflictNode.PARENT_COARSE; - }else{ + } else { type = ConflictNode.PARENT_WRITE; } } seseLock.addConflictNode(edge.getVertexU(), type); } else { if (edge.getVertexU().isStallSiteNode()) { - if(state.RCR){ + if (state.RCR) { type = ConflictNode.PARENT_COARSE; - }else{ + } else { if (edge.getVertexU().getWriteEffectSet().isEmpty()) { type = ConflictNode.PARENT_READ; } else { @@ -1563,18 +1514,18 @@ public class OoOJavaAnalysis { // and it is not parent type = ConflictNode.SCC; } else { - if(state.RCR){ + if (state.RCR) { type = ConflictNode.PARENT_COARSE; - }else{ + } else { type = ConflictNode.PARENT_WRITE; } } seseLock.addConflictNode(edge.getVertexV(), type); } else { if (edge.getVertexV().isStallSiteNode()) { - if(state.RCR){ + if (state.RCR) { type = ConflictNode.PARENT_COARSE; - }else{ + } else { if (edge.getVertexV().getWriteEffectSet().isEmpty()) { type = ConflictNode.PARENT_READ; } else { @@ -1597,7 +1548,7 @@ public class OoOJavaAnalysis { // new node has a coarse-grained edge to all fine-read, fine-write, // parent changed = true; - + if (newNode.isInVarNode() && (!seseLock.hasSelfCoarseEdge(newNode)) && seseLock.hasCoarseEdgeWithParentCoarse(newNode)) { // this case can't be covered by this queue @@ -1611,7 +1562,7 @@ public class OoOJavaAnalysis { coarseToCover.remove(edge); break; } - + if (seseLock.hasSelfCoarseEdge(newNode)) { // SCC if (newNode.isStallSiteNode()) { @@ -1688,11 +1639,10 @@ public class OoOJavaAnalysis { return rblockRel.getCallerProxySESE(); } - public Set getPossibleExecutingRBlocks( FlatNode fn ) { - return rblockRel.getPossibleExecutingRBlocks( fn ); + public Set getPossibleExecutingRBlocks(FlatNode fn) { + return rblockRel.getPossibleExecutingRBlocks(fn); } - public void writeReports(String timeReport) throws java.io.IOException { BufferedWriter bw = new BufferedWriter(new FileWriter("ooojReport_summary.txt")); @@ -1708,17 +1658,18 @@ public class OoOJavaAnalysis { MethodDescriptor md = methItr.next(); FlatMethod fm = state.getMethodFlat(md); if (fm != null) { - bw = new BufferedWriter(new FileWriter("ooojReport_" + - md.getClassMethodName() + - md.getSafeMethodDescriptor() + - ".txt")); + bw = + new BufferedWriter(new FileWriter("ooojReport_" + md.getClassMethodName() + + md.getSafeMethodDescriptor() + ".txt")); bw.write("OoOJava Results for " + md + "\n-------------------\n"); - bw.write("Dynamic vars to manage:\n " + getContextTaskNames( fm ).getDynamicVarSet() ); + bw.write("Dynamic vars to manage:\n " + getContextTaskNames(fm).getDynamicVarSet()); - bw.write("\n\nLive-In, Root View\n------------------\n" + fm.printMethod(livenessGlobalView)); + bw.write("\n\nLive-In, Root View\n------------------\n" + + fm.printMethod(livenessGlobalView)); bw.write("\n\nVariable Results-Out\n----------------\n" + fm.printMethod(variableResults)); - bw.write("\n\nNot Available Results-Out\n---------------------\n" + fm.printMethod(notAvailableResults)); + bw.write("\n\nNot Available Results-Out\n---------------------\n" + + fm.printMethod(notAvailableResults)); bw.write("\n\nCode Plans\n----------\n" + fm.printMethod(codePlans)); bw.close(); } @@ -1730,14 +1681,12 @@ public class OoOJavaAnalysis { Iterator rootItr = rblockRel.getLocalRootSESEs().iterator(); while (rootItr.hasNext()) { FlatSESEEnterNode root = rootItr.next(); - printSESEHierarchyTree(bw, root, 0); + printSESEHierarchyTree(bw, root, 0); } } - private void printSESEHierarchyTree(BufferedWriter bw, - FlatSESEEnterNode fsen, - int depth - ) throws java.io.IOException { + private void printSESEHierarchyTree(BufferedWriter bw, FlatSESEEnterNode fsen, int depth) + throws java.io.IOException { for (int i = 0; i < depth; ++i) { bw.write(" "); } @@ -1753,11 +1702,11 @@ public class OoOJavaAnalysis { private void printSESEInfo(BufferedWriter bw) throws java.io.IOException { bw.write("\nSESE info\n-------------\n"); Iterator fsenItr = rblockRel.getAllSESEs().iterator(); - while( fsenItr.hasNext() ) { + while (fsenItr.hasNext()) { FlatSESEEnterNode fsen = fsenItr.next(); bw.write("SESE " + fsen.getPrettyIdentifier()); - if( fsen.getIsLeafSESE() ) { + if (fsen.getIsLeafSESE()) { bw.write(" (leaf)"); } bw.write(" {\n"); @@ -1777,7 +1726,7 @@ public class OoOJavaAnalysis { } } - bw.write(" Dynamic vars to manage: " + getContextTaskNames( fsen ).getDynamicVarSet() + "\n"); + bw.write(" Dynamic vars to manage: " + getContextTaskNames(fsen).getDynamicVarSet() + "\n"); bw.write(" out-set: " + fsen.getOutVarSet() + "\n"); tItr = fsen.getOutVarSet().iterator();