From: jjenista Date: Mon, 31 Jan 2011 21:31:44 +0000 (+0000) Subject: cleaning up OoOJava and related systems, touching lots of files, these systems are... X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=72372762c4f0bf0f57c71e1fded17ea7735d0640;p=IRC.git cleaning up OoOJava and related systems, touching lots of files, these systems are PARTIALLY updated, the system is stable but won't compile user programs correctly until fully updated --- diff --git a/Robust/src/Analysis/Disjoint/DisjointAnalysis.java b/Robust/src/Analysis/Disjoint/DisjointAnalysis.java index d3be8ed0..d76cdf41 100644 --- a/Robust/src/Analysis/Disjoint/DisjointAnalysis.java +++ b/Robust/src/Analysis/Disjoint/DisjointAnalysis.java @@ -4,7 +4,6 @@ import Analysis.CallGraph.*; import Analysis.Liveness; import Analysis.ArrayReferencees; import Analysis.OoOJava.RBlockRelationAnalysis; -import Analysis.OoOJava.RBlockStatusAnalysis; import IR.*; import IR.Flat.*; import IR.Tree.Modifiers; @@ -386,7 +385,6 @@ public class DisjointAnalysis { public Liveness liveness; public ArrayReferencees arrayReferencees; public RBlockRelationAnalysis rblockRel; - public RBlockStatusAnalysis rblockStatus; public TypeUtil typeUtil; public int allocationDepth; @@ -618,10 +616,9 @@ public class DisjointAnalysis { Liveness l, ArrayReferencees ar, Set sitesToFlag, - RBlockRelationAnalysis rra, - RBlockStatusAnalysis rsa + RBlockRelationAnalysis rra ) { - init( s, tu, cg, l, ar, sitesToFlag, rra, rsa, false ); + init( s, tu, cg, l, ar, sitesToFlag, rra, false ); } public DisjointAnalysis( State s, @@ -631,10 +628,9 @@ public class DisjointAnalysis { ArrayReferencees ar, Set sitesToFlag, RBlockRelationAnalysis rra, - RBlockStatusAnalysis rsa, boolean suppressOutput ) { - init( s, tu, cg, l, ar, sitesToFlag, rra, rsa, suppressOutput ); + init( s, tu, cg, l, ar, sitesToFlag, rra, suppressOutput ); } protected void init( State state, @@ -644,7 +640,6 @@ public class DisjointAnalysis { ArrayReferencees arrayReferencees, Set sitesToFlag, RBlockRelationAnalysis rra, - RBlockStatusAnalysis rsa, boolean suppressOutput ) { @@ -657,7 +652,6 @@ public class DisjointAnalysis { this.arrayReferencees = arrayReferencees; this.sitesToFlag = sitesToFlag; this.rblockRel = rra; - this.rblockStatus = rsa; if( rblockRel != null ) { doEffectsAnalysis = true; @@ -1120,13 +1114,14 @@ public class DisjointAnalysis { case FKind.FlatGenReachNode: { FlatGenReachNode fgrn = (FlatGenReachNode) fn; - System.out.println( "Generating a reach graph!" ); + System.out.println( " Generating reach graph for program point: "+fgrn.getGraphName() ); + rg.writeGraph( "genReach"+fgrn.getGraphName(), true, // write labels (variables) - true, // selectively hide intermediate temp vars + false, // selectively hide intermediate temp vars true, // prune unreachable heap regions false, // hide reachability altogether - true, // hide subset reachability states + false, // hide subset reachability states true, // hide predicates true ); // hide edge taints } break; @@ -1170,7 +1165,7 @@ public class DisjointAnalysis { // before transfer, do effects analysis support if( doEffectsAnalysis && fmContaining != fmAnalysisEntry ) { - if(rblockStatus.isInCriticalRegion(fmContaining, fn)){ + if(rblockRel.isPotentialStallSite(fn)){ // x gets status of y if(!rg.isAccessible(rhs)){ rg.makeInaccessible(lhs); @@ -1193,7 +1188,7 @@ public class DisjointAnalysis { // before transfer, do effects analysis support if( doEffectsAnalysis && fmContaining != fmAnalysisEntry ) { - if(rblockStatus.isInCriticalRegion(fmContaining, fn)){ + if(rblockRel.isPotentialStallSite(fn)){ // x gets status of y if(!rg.isAccessible(rhs)){ rg.makeInaccessible(lhs); @@ -1216,7 +1211,7 @@ public class DisjointAnalysis { // a stall-site taint if( doEffectsAnalysis && fmContaining != fmAnalysisEntry ) { - if(rblockStatus.isInCriticalRegion(fmContaining, fn)){ + if(rblockRel.isPotentialStallSite(fn)){ // x=y.f, stall y if not accessible // contributes read effects on stall site of y if(!rg.isAccessible(rhs)) { @@ -1254,7 +1249,7 @@ public class DisjointAnalysis { // stall-site taints if( doEffectsAnalysis && fmContaining != fmAnalysisEntry ) { - if(rblockStatus.isInCriticalRegion(fmContaining, fn)){ + if(rblockRel.isPotentialStallSite(fn)){ // x.y=f , stall x and y if they are not accessible // also contribute write effects on stall site of x if(!rg.isAccessible(lhs)) { @@ -1297,7 +1292,7 @@ public class DisjointAnalysis { // before transfer func, possibly inject // stall-site taint if( doEffectsAnalysis && fmContaining != fmAnalysisEntry ) { - if(rblockStatus.isInCriticalRegion(fmContaining, fn)){ + if(rblockRel.isPotentialStallSite(fn)){ // x=y.f, stall y if not accessible // contributes read effects on stall site of y // after this, x and y are accessbile. @@ -1337,7 +1332,7 @@ public class DisjointAnalysis { // stall-site taints if( doEffectsAnalysis && fmContaining != fmAnalysisEntry ) { - if(rblockStatus.isInCriticalRegion(fmContaining, fn)){ + if(rblockRel.isPotentialStallSite(fn)){ // x.y=f , stall x and y if they are not accessible // also contribute write effects on stall site of x if(!rg.isAccessible(lhs)) { @@ -1377,7 +1372,7 @@ public class DisjointAnalysis { // before transform, support effects analysis if (doEffectsAnalysis && fmContaining != fmAnalysisEntry) { - if (rblockStatus.isInCriticalRegion(fmContaining, fn)) { + if (rblockRel.isPotentialStallSite(fn)) { // after creating new object, lhs is accessible rg.makeAccessible(lhs); } @@ -1391,11 +1386,6 @@ public class DisjointAnalysis { case FKind.FlatSESEEnterNode: sese = (FlatSESEEnterNode) fn; - if( sese.getIsCallerSESEplaceholder() ) { - // ignore these dummy rblocks! - break; - } - if( doEffectsAnalysis && fmContaining != fmAnalysisEntry ) { // always remove ALL stall site taints at enter @@ -1583,7 +1573,6 @@ public class DisjointAnalysis { System.out.println( " callee hasn't been analyzed, scheduling: "+mdPossible ); } - } else { // calculate the method call transform rgPossibleCaller.resolveMethodCall( fc, diff --git a/Robust/src/Analysis/Disjoint/EffectsAnalysis.java b/Robust/src/Analysis/Disjoint/EffectsAnalysis.java index 43f210c8..221f23ae 100644 --- a/Robust/src/Analysis/Disjoint/EffectsAnalysis.java +++ b/Robust/src/Analysis/Disjoint/EffectsAnalysis.java @@ -60,10 +60,6 @@ public class EffectsAnalysis { } protected void add(Taint t, Effect e) { - if( t.getSESE() != null && - t.getSESE().getIsCallerSESEplaceholder() ) { - return; - } Taint tNoPreds = Canonical.changePredsTo( t, ReachGraph.predsEmpty diff --git a/Robust/src/Analysis/Disjoint/ReachGraph.java b/Robust/src/Analysis/Disjoint/ReachGraph.java index b2da61a8..a8d8b605 100644 --- a/Robust/src/Analysis/Disjoint/ReachGraph.java +++ b/Robust/src/Analysis/Disjoint/ReachGraph.java @@ -1174,7 +1174,7 @@ public class ReachGraph { // so we capture the full change from the old alpha: ReachSet localDelta = Canonical.applyChangeSet( n.getAlpha(), C, - true + true ); // but this propagation may be only one of many concurrent // possible changes, so keep a running union with the node's @@ -1281,9 +1281,6 @@ public class ReachGraph { public void taintInSetVars( FlatSESEEnterNode sese ) { - if( sese.getIsCallerSESEplaceholder() ) { - return; - } Iterator isvItr = sese.getInVarSet().iterator(); while( isvItr.hasNext() ) { @@ -1339,9 +1336,6 @@ public class ReachGraph { } public void removeInContextTaints( FlatSESEEnterNode sese ) { - if( sese.getIsCallerSESEplaceholder() ) { - return; - } Iterator meItr = id2hrn.entrySet().iterator(); while( meItr.hasNext() ) { @@ -2199,10 +2193,10 @@ public class ReachGraph { private static boolean resolveMethodDebugDOTwriteLabels = true; private static boolean resolveMethodDebugDOTselectTemps = true; private static boolean resolveMethodDebugDOTpruneGarbage = true; - private static boolean resolveMethodDebugDOThideReach = true; - private static boolean resolveMethodDebugDOThideSubsetReach = true; + private static boolean resolveMethodDebugDOThideReach = false; + private static boolean resolveMethodDebugDOThideSubsetReach = false; private static boolean resolveMethodDebugDOThidePreds = true; - private static boolean resolveMethodDebugDOThideEdgeTaints = false; + private static boolean resolveMethodDebugDOThideEdgeTaints = true; static String debugGraphPrefix; static int debugCallSiteVisitCounter; @@ -2220,6 +2214,7 @@ public class ReachGraph { ) { if( writeDebugDOTs ) { + System.out.println( " Writing out visit "+ debugCallSiteVisitCounter+ " to debug call site" ); @@ -4400,7 +4395,6 @@ public class ReachGraph { boolean hideEdgeTaints, Set callerNodeIDsCopiedToCallee ) { - try { // remove all non-word characters from the graph name so // the filename and identifier in dot don't cause errors diff --git a/Robust/src/Analysis/Disjoint/Taint.java b/Robust/src/Analysis/Disjoint/Taint.java index e5ab027b..fc87353b 100644 --- a/Robust/src/Analysis/Disjoint/Taint.java +++ b/Robust/src/Analysis/Disjoint/Taint.java @@ -194,12 +194,7 @@ public class Taint extends Canonical { String s; if( isRBlockTaint() ) { - if( sese.getIsCallerSESEplaceholder() ) { - s = "placeh"; - } else { - s = sese.getPrettyIdentifier(); - } - + s = sese.getPrettyIdentifier(); } else { s = stallSite.toString(); } diff --git a/Robust/src/Analysis/MLP/CodePlan.java b/Robust/src/Analysis/MLP/CodePlan.java deleted file mode 100644 index d5d398dd..00000000 --- a/Robust/src/Analysis/MLP/CodePlan.java +++ /dev/null @@ -1,108 +0,0 @@ -package Analysis.MLP; - -import IR.*; -import IR.Flat.*; -import java.util.*; -import java.io.*; - - -// a code plan contains information based on analysis results -// for injecting code before and/or after a flat node -public class CodePlan { - - private Hashtable< VariableSourceToken, Set > stall2copySet; - private Set dynamicStallSet; - private Hashtable dynAssign_lhs2rhs; - private Set dynAssign_lhs2curr; - private FlatSESEEnterNode currentSESE; - - public CodePlan( FlatSESEEnterNode fsen ) { - stall2copySet = new Hashtable< VariableSourceToken, Set >(); - dynamicStallSet = new HashSet(); - dynAssign_lhs2rhs = new Hashtable(); - dynAssign_lhs2curr = new HashSet(); - currentSESE = fsen; - } - - public FlatSESEEnterNode getCurrentSESE() { - return currentSESE; - } - - public void addStall2CopySet( VariableSourceToken stallToken, - Set copySet ) { - - if( stall2copySet.containsKey( stallToken ) ) { - Set priorCopySet = stall2copySet.get( stallToken ); - priorCopySet.addAll( copySet ); - } else { - stall2copySet.put( stallToken, copySet ); - } - } - - public Set getStallTokens() { - return stall2copySet.keySet(); - } - - public Set getCopySet( VariableSourceToken stallToken ) { - return stall2copySet.get( stallToken ); - } - - - public void addDynamicStall( TempDescriptor var ) { - dynamicStallSet.add( var ); - } - - public Set getDynamicStallSet() { - return dynamicStallSet; - } - - public void addDynAssign( TempDescriptor lhs, - TempDescriptor rhs ) { - dynAssign_lhs2rhs.put( lhs, rhs ); - } - - public Hashtable getDynAssigns() { - return dynAssign_lhs2rhs; - } - - public void addDynAssign( TempDescriptor lhs ) { - dynAssign_lhs2curr.add( lhs ); - } - - public Set getDynAssignCurr() { - return dynAssign_lhs2curr; - } - - public String toString() { - String s = " PLAN: "; - - if( !stall2copySet.entrySet().isEmpty() ) { - s += "[STATIC STALLS:"; - } - Iterator cpsItr = stall2copySet.entrySet().iterator(); - while( cpsItr.hasNext() ) { - Map.Entry me = (Map.Entry) cpsItr.next(); - VariableSourceToken stallToken = (VariableSourceToken) me.getKey(); - Set copySet = (Set) me.getValue(); - - s += "("+stallToken+"->"+copySet+")"; - } - if( !stall2copySet.entrySet().isEmpty() ) { - s += "]"; - } - - if( !dynamicStallSet.isEmpty() ) { - s += "[DYN STALLS:"+dynamicStallSet+"]"; - } - - if( !dynAssign_lhs2rhs.isEmpty() ) { - s += "[DYN ASSIGNS:"+dynAssign_lhs2rhs+"]"; - } - - if( !dynAssign_lhs2curr.isEmpty() ) { - s += "[DYN ASS2CURR:"+dynAssign_lhs2curr+"]"; - } - - return s; - } -} diff --git a/Robust/src/Analysis/MLP/ConflictGraph.java b/Robust/src/Analysis/MLP/ConflictGraph.java deleted file mode 100644 index 9d126045..00000000 --- a/Robust/src/Analysis/MLP/ConflictGraph.java +++ /dev/null @@ -1,1200 +0,0 @@ -package Analysis.MLP; - -import java.io.BufferedWriter; -import java.io.FileWriter; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Hashtable; -import java.util.Iterator; -import java.util.Set; -import java.util.Map.Entry; - -import Analysis.OwnershipAnalysis.HeapRegionNode; -import Analysis.OwnershipAnalysis.OwnershipGraph; -import Analysis.OwnershipAnalysis.ReachabilitySet; -import Analysis.OwnershipAnalysis.TokenTuple; -import IR.Flat.FlatMethod; -import IR.Flat.FlatSESEEnterNode; -import IR.Flat.TempDescriptor; - -public class ConflictGraph { - - static private int uniqueCliqueIDcount = 100; - - public Hashtable id2cn; - private OwnershipGraph og; - - public ConflictGraph(OwnershipGraph og) { - id2cn = new Hashtable(); - this.og = og; - } - - public boolean hasConflictEdge() { - - Set keySet = id2cn.keySet(); - for (Iterator iterator = keySet.iterator(); iterator.hasNext();) { - String key = (String) iterator.next(); - ConflictNode node = id2cn.get(key); - if (node.getEdgeSet().size() > 0) { - return true; - } - } - return false; - } - - public void analyzeConflicts() { - - Set keySet = id2cn.keySet(); - Set analyzedIDSet = new HashSet(); - - for (Iterator iterator = keySet.iterator(); iterator.hasNext();) { - String nodeID = (String) iterator.next(); - ConflictNode node = id2cn.get(nodeID); - analyzePossibleConflicts(analyzedIDSet, node); - } - } - - private boolean compareHRNSet(Set setA, - Set setB) { - boolean found = false; - for (Iterator iterator = setA.iterator(); iterator.hasNext();) { - HeapRegionNode heapRegionNode = (HeapRegionNode) iterator.next(); - String gID = heapRegionNode.getGloballyUniqueIdentifier(); - for (Iterator iterator2 = setB.iterator(); iterator2.hasNext();) { - HeapRegionNode heapRegionNode2 = (HeapRegionNode) iterator2 - .next(); - if (heapRegionNode2.getGloballyUniqueIdentifier().equals(gID)) { - found = true; - } - } - } - if (!found) { - return false; - } - return true; - } - - public String addStallNode(TempDescriptor td, FlatMethod fm, - StallSite stallSite, Set reachabilitySet) { - - String stallNodeID = td + "_" + fm.getMethod().getSymbol(); - - if (!id2cn.containsKey(stallNodeID)) { - StallSiteNode newNode = new StallSiteNode(stallNodeID, td, - stallSite, reachabilitySet); - id2cn.put(stallNodeID, newNode); - // it add new new stall node to conflict graph - return stallNodeID; - } - // it doesn't add new stall node because stall node has already been - // added. - return null; - } - - public StallSiteNode getStallNode(String stallNodeID) { - ConflictNode node = id2cn.get(stallNodeID); - if (node instanceof StallSiteNode) { - return (StallSiteNode) node; - } else { - return null; - } - } - - public void addLiveInNode(TempDescriptor td, Set hrnSet, - FlatSESEEnterNode fsen, Set readEffectsSet, - Set writeEffectsSet, - Set strongUpdateSet, Set reachabilitySet) { - - String liveinNodeID = td + "_" + fsen.getIdentifier(); - - LiveInNode newNode = new LiveInNode(liveinNodeID, td, hrnSet, - readEffectsSet, writeEffectsSet, strongUpdateSet, - reachabilitySet, fsen.getIdentifier()); - id2cn.put(liveinNodeID, newNode); - - } - - public void addConflictEdge(int type, ConflictNode nodeU, ConflictNode nodeV) { - - // if there are two edges between the same node pair, coarse has a - // priority - HashSet set = nodeU.getEdgeSet(); - ConflictEdge toBeRemoved = null; - for (Iterator iterator = set.iterator(); iterator.hasNext();) { - ConflictEdge conflictEdge = (ConflictEdge) iterator.next(); - - if ((conflictEdge.getVertexU().equals(nodeU) && conflictEdge - .getVertexV().equals(nodeV)) - || (conflictEdge.getVertexU().equals(nodeV) && conflictEdge - .getVertexV().equals(nodeU))) { - if (conflictEdge.getType() == ConflictEdge.FINE_GRAIN_EDGE - && type == ConflictEdge.COARSE_GRAIN_EDGE) { - toBeRemoved = conflictEdge; - break; - } else if (conflictEdge.getType() == ConflictEdge.COARSE_GRAIN_EDGE - && type == ConflictEdge.FINE_GRAIN_EDGE) { - // ignore - return; - } - } - } - - if (toBeRemoved != null) { - nodeU.getEdgeSet().remove(toBeRemoved); - nodeV.getEdgeSet().remove(toBeRemoved); - } - - ConflictEdge newEdge = new ConflictEdge(nodeU, nodeV, type); - nodeU.addEdge(newEdge); - nodeV.addEdge(newEdge); - - } - - public Set getStallSiteWaitingElementSet( - ParentChildConflictsMap conflictsMap, HashSet seseLockSet) { - - HashSet waitingElementSet = new HashSet(); - Set> s = id2cn.entrySet(); - Collection stallSites = conflictsMap.getStallMap().values(); - - for (Iterator iterator = stallSites.iterator(); iterator.hasNext();) { - - StallSite stallSite = (StallSite) iterator.next(); - Iterator> i = s.iterator(); - while (i.hasNext()) { - Entry entry = i.next(); - ConflictNode node = entry.getValue(); - - if (node instanceof StallSiteNode) { - StallSiteNode stallSiteNode = (StallSiteNode) node; - if (stallSiteNode.getStallSite().equals(stallSite)) { - HashSet edgeSet = stallSiteNode - .getEdgeSet(); - for (Iterator iter2 = edgeSet.iterator(); iter2 - .hasNext();) { - ConflictEdge conflictEdge = (ConflictEdge) iter2 - .next(); - - for (Iterator seseLockIter = seseLockSet - .iterator(); seseLockIter.hasNext();) { - SESELock seseLock = seseLockIter.next(); - if (seseLock - .containsConflictNode(stallSiteNode) - && seseLock - .containsConflictEdge(conflictEdge)) { - WaitingElement newElement = new WaitingElement(); - newElement.setQueueID(seseLock.getID()); - if (isFineElement(newElement.getStatus())) { - newElement - .setDynID(node - .getTempDescriptor() - .toString()); - } - newElement.setStatus(seseLock - .getNodeType(stallSiteNode)); - waitingElementSet.add(newElement); - } - } - } - } - } - } - - } - - return waitingElementSet; - } - - private Set getConnectedConflictNode(ConflictEdge conflictEdge, - int seseID) { - - HashSet nodeIDSet = new HashSet(); - - if (conflictEdge.getVertexU() instanceof LiveInNode) { - LiveInNode lin = (LiveInNode) conflictEdge.getVertexU(); - if (lin.getSESEIdentifier() != seseID) { - nodeIDSet.add(new Integer(lin.getSESEIdentifier())); - } - } else { - // it is stall site - nodeIDSet.add(new Integer(-1)); - } - if (conflictEdge.getVertexV() instanceof LiveInNode) { - LiveInNode lin = (LiveInNode) conflictEdge.getVertexV(); - if (lin.getSESEIdentifier() != seseID) { - nodeIDSet.add(new Integer(lin.getSESEIdentifier())); - } - } else { - // it is stall site - nodeIDSet.add(new Integer(-1)); - } - - // self-edge case - if (conflictEdge.getVertexU() instanceof LiveInNode - && conflictEdge.getVertexV() instanceof LiveInNode) { - if (((LiveInNode) conflictEdge.getVertexU()).getSESEIdentifier() == seseID - && ((LiveInNode) conflictEdge.getVertexV()) - .getSESEIdentifier() == seseID) { - nodeIDSet.add(seseID); - } - } - - return nodeIDSet; - } - - public Set getConnectedConflictNodeSet(int seseID) { - - HashSet nodeIDSet = new HashSet(); - - Set> s = id2cn.entrySet(); - Iterator> i = s.iterator(); - - while (i.hasNext()) { - Entry entry = i.next(); - ConflictNode node = entry.getValue(); - - if (node instanceof LiveInNode) { - LiveInNode liveInNode = (LiveInNode) node; - if (liveInNode.getSESEIdentifier() == seseID) { - HashSet edgeSet = liveInNode.getEdgeSet(); - for (Iterator iterator = edgeSet.iterator(); iterator - .hasNext();) { - ConflictEdge conflictEdge = (ConflictEdge) iterator - .next(); - // - nodeIDSet.addAll(getConnectedConflictNode(conflictEdge, - seseID)); - // - } - } - } - } - - return nodeIDSet; - - } - - public SESEWaitingQueue getWaitingElementSetBySESEID(int seseID, - HashSet seseLockSet) { - HashSet waitingElementSet = new HashSet(); - - Set> s = id2cn.entrySet(); - Iterator> i = s.iterator(); - - while (i.hasNext()) { - Entry entry = i.next(); - ConflictNode node = entry.getValue(); - - if (node instanceof LiveInNode) { - LiveInNode liveInNode = (LiveInNode) node; - if (liveInNode.getSESEIdentifier() == seseID) { - - HashSet edgeSet = liveInNode.getEdgeSet(); - - for (Iterator iterator = edgeSet.iterator(); iterator - .hasNext();) { - ConflictEdge conflictEdge = (ConflictEdge) iterator - .next(); - - for (Iterator seseLockIter = seseLockSet - .iterator(); seseLockIter.hasNext();) { - SESELock seseLock = seseLockIter.next(); - if (seseLock.containsConflictNode(liveInNode) - && seseLock - .containsConflictEdge(conflictEdge)) { - WaitingElement newElement = new WaitingElement(); - newElement.setQueueID(seseLock.getID()); - newElement.setStatus(seseLock - .getNodeType(liveInNode)); - if (isFineElement(newElement.getStatus())) { - newElement.setDynID(node - .getTempDescriptor().toString()); - newElement.setTempDesc(node.getTempDescriptor()); - } - if (!waitingElementSet.contains(newElement)) { - waitingElementSet.add(newElement); - } - - } - } - } - - } - } - - } - - //handle the case that multiple enqueues by an SESE for different live-in into the same queue - return refineQueue(waitingElementSet); -// return waitingElementSet; - - } - - public SESEWaitingQueue refineQueue(Set waitingElementSet) { - - Set refinedSet=new HashSet(); - HashMap> map = new HashMap>(); - SESEWaitingQueue seseDS=new SESEWaitingQueue(); - - for (Iterator iterator = waitingElementSet.iterator(); iterator - .hasNext();) { - WaitingElement waitingElement = (WaitingElement) iterator.next(); - Set set=map.get(new Integer(waitingElement.getQueueID())); - if(set==null){ - set=new HashSet(); - } - 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(); - Set queueWEset=map.get(queueID); - refineQueue(queueID.intValue(),queueWEset,seseDS); - } - - return seseDS; - } - - private void refineQueue(int queueID, - Set waitingElementSet, SESEWaitingQueue seseDS) { - - if (waitingElementSet.size() > 1) { - //only consider there is more than one element submitted by same SESE - Set refinedSet = new HashSet(); - - int numCoarse = 0; - int numRead = 0; - int numWrite = 0; - int total=waitingElementSet.size(); - WaitingElement SCCelement = null; - WaitingElement coarseElement = null; - - for (Iterator iterator = waitingElementSet.iterator(); iterator - .hasNext();) { - WaitingElement waitingElement = (WaitingElement) iterator - .next(); - if (waitingElement.getStatus() == ConflictNode.FINE_READ) { - numRead++; - } else if (waitingElement.getStatus() == ConflictNode.FINE_WRITE) { - numWrite++; - } else if (waitingElement.getStatus() == ConflictNode.COARSE) { - numCoarse++; - coarseElement = waitingElement; - } else if (waitingElement.getStatus() == ConflictNode.SCC) { - SCCelement = waitingElement; - } - } - - if (SCCelement != null) { - // if there is at lease one SCC element, just enqueue SCC and - // ignore others. - refinedSet.add(SCCelement); - } 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); - we.setStatus(ConflictNode.SCC); - refinedSet.add(we); - } else if (numCoarse == total) { - // if there are multiple coarses, enqueue just one coarse. - refinedSet.add(coarseElement); - } else if(numWrite==total || (numRead+numWrite)==total){ - // code generator is going to handle the case for multiple writes & read/writes. - seseDS.setType(queueID, SESEWaitingQueue.EXCEPTION); - refinedSet.addAll(waitingElementSet); - } else{ - // otherwise, enqueue everything. - refinedSet.addAll(waitingElementSet); - } - seseDS.setWaitingElementSet(queueID, refinedSet); - } else { - seseDS.setWaitingElementSet(queueID, waitingElementSet); - } - - } - - public boolean isFineElement(int type) { - if (type == ConflictNode.FINE_READ || type == ConflictNode.FINE_WRITE - || type == ConflictNode.PARENT_READ - || type == ConflictNode.PARENT_WRITE) { - return true; - } else { - return false; - } - } - - public HashSet getEdgeSet() { - - HashSet returnSet = new HashSet(); - - Collection nodes = id2cn.values(); - for (Iterator iterator = nodes.iterator(); iterator.hasNext();) { - ConflictNode conflictNode = (ConflictNode) iterator.next(); - returnSet.addAll(conflictNode.getEdgeSet()); - } - - return returnSet; - } - - public void writeGraph(String graphName, boolean filter) - throws java.io.IOException { - - graphName = graphName.replaceAll("[\\W]", ""); - - BufferedWriter bw = new BufferedWriter(new FileWriter(graphName - + ".dot")); - bw.write("graph " + graphName + " {\n"); - - HashSet visited = new HashSet(); - // then visit every heap region node - Set> s = id2cn.entrySet(); - Iterator> i = s.iterator(); - - HashSet addedSet = new HashSet(); - - while (i.hasNext()) { - Entry entry = i.next(); - ConflictNode node = entry.getValue(); - - if (filter) { - if (node.getID().startsWith("___dst") - || node.getID().startsWith("___srctmp") - || node.getID().startsWith("___neverused") - || node.getID().startsWith("___temp")) { - - continue; - } - } - - String attributes = "["; - - attributes += "label=\"ID" + node.getID() + "\\n"; - - if (node instanceof StallSiteNode) { - attributes += "STALL SITE" + "\\n" + "\"]"; - } else { - attributes += "LIVE-IN" + "\\n" + "\"]"; - } - bw.write(entry.getKey() + attributes + ";\n"); - - HashSet edgeSet = node.getEdgeSet(); - for (Iterator iterator = edgeSet.iterator(); iterator.hasNext();) { - ConflictEdge conflictEdge = (ConflictEdge) iterator.next(); - - ConflictNode u = conflictEdge.getVertexU(); - ConflictNode v = conflictEdge.getVertexV(); - - if (filter) { - String uID = u.getID(); - String vID = v.getID(); - if (uID.startsWith("___dst") || uID.startsWith("___srctmp") - || uID.startsWith("___neverused") - || uID.startsWith("___temp") - || vID.startsWith("___dst") - || vID.startsWith("___srctmp") - || vID.startsWith("___neverused") - || vID.startsWith("___temp")) { - continue; - } - } - - if (!addedSet.contains(conflictEdge)) { - bw.write(" " + u.getID() + "--" + v.getID() + "[label=" - + conflictEdge.toGraphEdgeString() - + ",decorate];\n"); - addedSet.add(conflictEdge); - } - - } - } - - bw.write(" graphTitle[label=\"" + graphName + "\",shape=box];\n"); - - bw.write("}\n"); - bw.close(); - - } - - private int calculateConflictType(StallSiteNode nodeA, LiveInNode nodeB) { - - StallSite stallSite = nodeA.getStallSite(); - Set writeEffectsSet = nodeB.getWriteEffectsSet(); - Set readEffectsSet = nodeB.getReadEffectsSet(); - - int conflictType = 0; - - if (writeEffectsSet != null) { - Iterator writeIter = writeEffectsSet.iterator(); - while (writeIter.hasNext()) { - SESEEffectsKey seseEffectsKey = (SESEEffectsKey) writeIter - .next(); - String writeHeapRegionID = seseEffectsKey.getHRNUniqueId(); - String writeFieldName = seseEffectsKey.getFieldDescriptor(); - - HashSet stallSiteHRNSet = nodeA.getHRNSet(); - for (Iterator iterator = stallSiteHRNSet.iterator(); iterator - .hasNext();) { - HeapRegionNode stallHRN = (HeapRegionNode) iterator.next(); - if (stallHRN.getGloballyUniqueIdentifier().equals( - writeHeapRegionID)) { - // check whether there are read or write effects of - // stall sites - HashSet effectSet = stallSite.getEffectSet(); - for (Iterator iterator2 = effectSet.iterator(); iterator2 - .hasNext();) { - Effect effect = (Effect) iterator2.next(); - String stallEffectfieldName = effect.getField(); - - if (stallEffectfieldName.equals(writeFieldName)) { - int newType = determineConflictType(nodeA, - effect, nodeB, seseEffectsKey); - if (newType > conflictType) { - // coarse-grain conflict overrides - // fine-grain conflict - conflictType = newType; - } - } - } - } - } - - } - } - - if (readEffectsSet != null) { - Iterator readIter = readEffectsSet.iterator(); - while (readIter.hasNext()) { - SESEEffectsKey seseEffectsKey = (SESEEffectsKey) readIter - .next(); - String readHeapRegionID = seseEffectsKey.getHRNUniqueId(); - String readFieldName = seseEffectsKey.getFieldDescriptor(); - - HashSet stallSiteHRNSet = nodeA.getHRNSet(); - for (Iterator iterator = stallSiteHRNSet.iterator(); iterator - .hasNext();) { - HeapRegionNode stallHRN = (HeapRegionNode) iterator.next(); - if (stallHRN.getGloballyUniqueIdentifier().equals( - readHeapRegionID)) { - - HashSet effectSet = stallSite.getEffectSet(); - for (Iterator iterator2 = effectSet.iterator(); iterator2 - .hasNext();) { - Effect effect = (Effect) iterator2.next(); - String stallEffectfieldName = effect.getField(); - - if (effect.getEffectType().equals( - StallSite.WRITE_EFFECT)) { - if (stallEffectfieldName.equals(readFieldName)) { - int newType = determineConflictType(nodeA, - effect, nodeB, seseEffectsKey); - if (newType > conflictType) { - // coarse-grain conflict overrides - // fine-grain conflict - conflictType = newType; - } - } - } - } - } - } - } - } -//System.out.println("%%%%%%%%%%%%%% RETURN conflictType="+conflictType); - return conflictType; - } - - private int calculateConflictType(LiveInNode nodeA, LiveInNode nodeB) { - - Set readEffectsSetA = nodeA.getReadEffectsSet(); - Set writeEffectsSetA = nodeA.getWriteEffectsSet(); - Set strongUpdateSetA = nodeA.getStrongUpdateSet(); - - Set readEffectsSetB = nodeB.getReadEffectsSet(); - Set writeEffectsSetB = nodeB.getWriteEffectsSet(); - Set strongUpdateSetB = nodeB.getStrongUpdateSet(); - - int conflictType = 0; - - // if node A has write effects on reading/writing regions of node B - if (writeEffectsSetA != null) { - Iterator writeIterA = writeEffectsSetA.iterator(); - while (writeIterA.hasNext()) { - SESEEffectsKey seseEffectsKey = (SESEEffectsKey) writeIterA - .next(); - String writeHeapRegionID = seseEffectsKey.getHRNUniqueId(); - String writeFieldName = seseEffectsKey.getFieldDescriptor(); - - if (readEffectsSetB != null) { - - Iterator readIterB = readEffectsSetB - .iterator(); - while (readIterB.hasNext()) { - SESEEffectsKey readingEffect = (SESEEffectsKey) readIterB - .next(); - - if (readingEffect.getHRNUniqueId().equals( - writeHeapRegionID) - && readingEffect.getFieldDescriptor().equals( - writeFieldName)) { - int newType = determineConflictType(nodeA, - seseEffectsKey, nodeB, readingEffect); - if (newType > conflictType) { - // coarse-grain conflict overrides fine-grain - // conflict - conflictType = newType; - } - } - } - - } - - if (writeEffectsSetB != null) { - Iterator writeIterB = writeEffectsSetB - .iterator(); - while (writeIterB.hasNext()) { - SESEEffectsKey writingEffect = (SESEEffectsKey) writeIterB - .next(); - - if (writingEffect.getHRNUniqueId().equals( - writeHeapRegionID) - && writingEffect.getFieldDescriptor().equals( - writeFieldName)) { - int newType = determineConflictType(nodeA, - seseEffectsKey, nodeB, writingEffect); - if (newType > conflictType) { - // coarse-grain conflict overrides fine-grain - // conflict - conflictType = newType; - } - } - - } - } - - } - } - - // if node B has write effects on reading regions of node A - if (writeEffectsSetB != null) { - Iterator writeIterB = writeEffectsSetB.iterator(); - while (writeIterB.hasNext()) { - SESEEffectsKey seseEffectsKey = (SESEEffectsKey) writeIterB - .next(); - - // if (!hasStrongUpdate(seseEffectsKey, strongUpdateSetB)) { - - String writeHeapRegionID = seseEffectsKey.getHRNUniqueId(); - String writeFieldName = seseEffectsKey.getFieldDescriptor(); - - if (readEffectsSetA != null) { - Iterator readIterA = readEffectsSetA - .iterator(); - while (readIterA.hasNext()) { - SESEEffectsKey readingEffect = (SESEEffectsKey) readIterA - .next(); - - if (readingEffect.getHRNUniqueId().equals( - writeHeapRegionID) - && readingEffect.getFieldDescriptor().equals( - writeFieldName)) { - int newType = determineConflictType(nodeA, - readingEffect, nodeB, seseEffectsKey); - if (newType > conflictType) { - // coarse-grain conflict overrides fine-grain - // conflict - conflictType = newType; - } - } - - } - } - - if (writeEffectsSetA != null) { - Iterator writeIterA = writeEffectsSetA - .iterator(); - while (writeIterA.hasNext()) { - SESEEffectsKey writingEffect = (SESEEffectsKey) writeIterA - .next(); - - if (writingEffect.getHRNUniqueId().equals( - writeHeapRegionID) - && writingEffect.getFieldDescriptor().equals( - writeFieldName)) { - int newType = determineConflictType(nodeA, - writingEffect, nodeB, seseEffectsKey); - if (newType > conflictType) { - // coarse-grain conflict overrides fine-grain - // conflict - conflictType = newType; - } - } - - } - } - - } - } - return conflictType; - } - - private Set getSameHeapRoot(Set setA, - Set setB) { - - Set retSet = new HashSet(); - - if (compareHRNSet(setA, setB)) { - for (Iterator iterator = setA.iterator(); iterator.hasNext();) { - HeapRegionNode heapRegionNode = (HeapRegionNode) iterator - .next(); - String gID = heapRegionNode.getGloballyUniqueIdentifier(); - for (Iterator iterator2 = setB.iterator(); iterator2.hasNext();) { - HeapRegionNode heapRegionNode2 = (HeapRegionNode) iterator2 - .next(); - if (heapRegionNode2.getGloballyUniqueIdentifier().equals( - gID)) { - retSet.add(heapRegionNode2); - } - } - } - } - - return retSet; - - } - - private boolean isReachableFrom(HeapRegionNode root1, HeapRegionNode root2, - ReachabilitySet rset) { - - boolean reachable=false; - - TokenTuple h1 = new TokenTuple(root1.getID(), !root1.isSingleObject(), - TokenTuple.ARITY_ONE).makeCanonical(); - - TokenTuple h1plus = new TokenTuple(root1.getID(), !root1 - .isSingleObject(), TokenTuple.ARITY_ONEORMORE).makeCanonical(); - - TokenTuple h1star = new TokenTuple(root1.getID(), !root1 - .isSingleObject(), TokenTuple.ARITY_ZEROORMORE).makeCanonical(); - - TokenTuple h2 = new TokenTuple(root2.getID(), !root2.isSingleObject(), - TokenTuple.ARITY_ONE).makeCanonical(); - - TokenTuple h2plus = new TokenTuple(root2.getID(), !root2 - .isSingleObject(), TokenTuple.ARITY_ONEORMORE).makeCanonical(); - - TokenTuple h2star = new TokenTuple(root2.getID(), !root2 - .isSingleObject(), TokenTuple.ARITY_ZEROORMORE).makeCanonical(); - - // only do this one if they are different tokens - if( h1 != h2 && - rset.containsTupleSetWithBoth(h1, h2) ) { - reachable = true; - } - if( rset.containsTupleSetWithBoth(h1plus, h2) ) { - reachable = true; - } - if( rset.containsTupleSetWithBoth(h1star, h2) ) { - reachable = true; - } - if( rset.containsTupleSetWithBoth(h1, h2plus) ) { - reachable = true; - } - if( rset.containsTupleSetWithBoth(h1plus, h2plus) ) { - reachable = true; - } - if( rset.containsTupleSetWithBoth(h1star, h2plus) ) { - reachable = true; - } - if( rset.containsTupleSetWithBoth(h1, h2star) ) { - reachable = true; - } - if( rset.containsTupleSetWithBoth(h1plus, h2star) ) { - reachable = true; - } - if( rset.containsTupleSetWithBoth(h1star, h2star) ) { - reachable = true; - } - - return reachable; - - } - - private int determineConflictType(StallSiteNode stallSiteNodeA, - Effect effect, LiveInNode liveInNodeB, - SESEEffectsKey effectB) { - - Set liveInHrnSetA = stallSiteNodeA.getStallSite().getHRNSet(); - Set liveInHrnSetB = liveInNodeB.getHRNSet(); - - // check whether alloc site is reached from both heap roots - boolean isDisjoint=true; - HeapRegionNode effectHrn=og.gid2hrn.get(effectB.getHRNUniqueId()); - if(effectHrn.isSingleObject()){ - for (Iterator iterator = liveInHrnSetA.iterator(); iterator.hasNext();) { - HeapRegionNode r1 = (HeapRegionNode) iterator.next(); - for (Iterator iterator2 = liveInHrnSetB.iterator(); iterator2.hasNext();) { - HeapRegionNode r2 = (HeapRegionNode) iterator2.next(); - r1=og.gid2hrn.get(r1.getGloballyUniqueIdentifier()); - r2=og.gid2hrn.get(r2.getGloballyUniqueIdentifier()); - if(isReachableFrom(r1,r2,effectB.getRSet())){ - isDisjoint=false; - } - } - } - if(isDisjoint){ - return ConflictEdge.NON_WRITE_CONFLICT; - } - } - - /* - HeapRegionNode r1=liveInHrnSetA.iterator().next(); - HeapRegionNode r2=liveInHrnSetB.iterator().next(); - - r1=og.gid2hrn.get(r1.getGloballyUniqueIdentifier()); - r2=og.gid2hrn.get(r2.getGloballyUniqueIdentifier()); - - System.out.println("r1="+r1); - System.out.println("r2="+r2); - System.out.println("effectB="+effectB.getRSet()); - System.out.println("###STALL calculateConflictType2"); - if(!isReachableFrom(r1,r2,effectB.getRSet())){ - System.out.println("###STALL calculateConflictType3"); - return ConflictEdge.NON_WRITE_CONFLICT; - } - */ - Set entryHRNSet = getSameHeapRoot(liveInHrnSetA, - liveInHrnSetB); - if (entryHRNSet.size() == 0) { - return ConflictEdge.COARSE_GRAIN_EDGE; - } - - for (Iterator iterator = entryHRNSet.iterator(); iterator.hasNext();) { - HeapRegionNode hrn = (HeapRegionNode) iterator.next(); - - String entryIdentifier = hrn.getGloballyUniqueIdentifier(); - HeapRegionNode entryHRN = og.gid2hrn.get(entryIdentifier); - - TokenTuple h1 = new TokenTuple(entryHRN.getID(), !entryHRN - .isSingleObject(), TokenTuple.ARITY_ONE).makeCanonical(); - - TokenTuple h1star = new TokenTuple(entryHRN.getID(), true, - TokenTuple.ARITY_ONEORMORE).makeCanonical(); - - if (effectB.getRSet().containsTuple(h1star)) { - return ConflictEdge.COARSE_GRAIN_EDGE; - }else if (effectB.getRSet().containsTuple(h1)) { - // rechability states contain heap root with arity 1 - return ConflictEdge.FINE_GRAIN_EDGE; - } - } - return ConflictEdge.NON_WRITE_CONFLICT; - } - - private int determineConflictType(LiveInNode liveInNodeA, - SESEEffectsKey effectA, LiveInNode liveInNodeB, - SESEEffectsKey effectB) { - - if (liveInNodeA.getSESEIdentifier() == liveInNodeB.getSESEIdentifier()) { - return ConflictEdge.NON_WRITE_CONFLICT; - } - - Set liveInHrnSetA = liveInNodeA.getHRNSet(); - Set liveInHrnSetB = liveInNodeB.getHRNSet(); - - // check whether alloc site is reached from both heap roots - boolean isDisjoint=true; - HeapRegionNode effectHrn=og.gid2hrn.get(effectB.getHRNUniqueId()); - if(effectHrn.isSingleObject()){ - for (Iterator iterator = liveInHrnSetA.iterator(); iterator.hasNext();) { - HeapRegionNode r1 = (HeapRegionNode) iterator.next(); - for (Iterator iterator2 = liveInHrnSetB.iterator(); iterator2.hasNext();) { - HeapRegionNode r2 = (HeapRegionNode) iterator2.next(); - r1=og.gid2hrn.get(r1.getGloballyUniqueIdentifier()); - r2=og.gid2hrn.get(r2.getGloballyUniqueIdentifier()); - - if(isReachableFrom(r1,r2,effectB.getRSet())){ - isDisjoint=false; - }else{ - } - } - } - if(isDisjoint){ - return ConflictEdge.NON_WRITE_CONFLICT; - } - } - - /* - HeapRegionNode r1=liveInHrnSetA.iterator().next(); - HeapRegionNode r2=liveInHrnSetB.iterator().next(); - -// r1=og.gid2hrn.get(r1.getGloballyUniqueIdentifier()); -// r2=og.gid2hrn.get(r2.getGloballyUniqueIdentifier()); - System.out.println("@@r1="+r1); - System.out.println("@@r2="+r2); - System.out.println("@@effectB="+effectA.getRSet()); - - if(!isReachableFrom(r1,r2,effectA.getRSet())){ - // two heap root are disjoint - return ConflictEdge.NON_WRITE_CONFLICT; - } - */ - - Set entryHRNSet = getSameHeapRoot(liveInHrnSetA, - liveInHrnSetB); - if (entryHRNSet.size() == 0 ) { - return ConflictEdge.COARSE_GRAIN_EDGE; - } - if(entryHRNSet.size()!=liveInHrnSetA.size() || entryHRNSet.size()!=liveInHrnSetB.size()){ - return ConflictEdge.COARSE_GRAIN_EDGE; - } - - int count=0; - for (Iterator iterator = entryHRNSet.iterator(); iterator.hasNext();) { - HeapRegionNode hrn = (HeapRegionNode) iterator.next(); - if(hrn.getType()!=null && hrn.getType().isImmutable()){ - count++; - } - } - if(count==entryHRNSet.size()){ - return ConflictEdge.FINE_GRAIN_EDGE; - } - - for (Iterator iterator = entryHRNSet.iterator(); iterator.hasNext();) { - HeapRegionNode hrn = (HeapRegionNode) iterator.next(); - - String entryIdentifier = hrn.getGloballyUniqueIdentifier(); - HeapRegionNode entryHRN = og.gid2hrn.get(entryIdentifier); - - TokenTuple h1 = new TokenTuple(entryHRN.getID(), !entryHRN - .isSingleObject(), TokenTuple.ARITY_ONE).makeCanonical(); - - TokenTuple h1star = new TokenTuple(entryHRN.getID(), true, - TokenTuple.ARITY_ONEORMORE).makeCanonical(); - - if (effectA.getRSet().containsTuple(h1star)) { - return ConflictEdge.COARSE_GRAIN_EDGE; - } else if (effectA.getRSet().containsTuple(h1)) { - // rechability states contain heap root with arity 1 - return ConflictEdge.FINE_GRAIN_EDGE; - } - - } - - return ConflictEdge.NON_WRITE_CONFLICT; - - } - - private int calculateSelfConflictType(LiveInNode liveInNode) { - - // if strong update effect exists, it conflicts every effects of objects that are reachable from same heap root - Set strongUpdateSet = liveInNode.getStrongUpdateSet(); - if(strongUpdateSet!=null && strongUpdateSet.size()>0){ - return ConflictEdge.FINE_GRAIN_EDGE; - } - - if (liveInNode.getWriteEffectsSet() != null - && liveInNode.getWriteEffectsSet().size() > 0) { - - Set writeEffectsSet=liveInNode.getWriteEffectsSet(); - - int immuntableCount = 0; - for (Iterator iterator = liveInNode.getHRNSet() - .iterator(); iterator.hasNext();) { - HeapRegionNode root = iterator.next(); - if(root.getType()!=null && root.getType().isImmutable()){ - immuntableCount++; - } - } - if (immuntableCount == liveInNode.getHRNSet().size()) { - // in this case, heap root is a parameter heap region - return ConflictEdge.FINE_GRAIN_EDGE; - } - - - int paramCount = 0; - for (Iterator iterator = liveInNode.getHRNSet() - .iterator(); iterator.hasNext();) { - HeapRegionNode root = iterator.next(); - if (root.isParameter()) { - paramCount++; - } - } - - if (paramCount == liveInNode.getHRNSet().size()) { - // in this case, heap root is a parameter heap region - return ConflictEdge.FINE_GRAIN_EDGE; - } - - if (liveInNode.getHRNSet().size()==1) { - HeapRegionNode hrn = liveInNode.getHRNSet().iterator().next(); - String entryIdentifier = hrn.getGloballyUniqueIdentifier(); - HeapRegionNode entryHRN = og.gid2hrn.get(entryIdentifier); - - boolean containsStar=false; - for (Iterator iterator = writeEffectsSet.iterator(); iterator - .hasNext();) { - SESEEffectsKey effect = (SESEEffectsKey) iterator.next(); - TokenTuple h1 = new TokenTuple(entryHRN.getID(), !entryHRN - .isSingleObject(), TokenTuple.ARITY_ONE).makeCanonical(); - TokenTuple h1star = new TokenTuple(entryHRN.getID(), true, TokenTuple.ARITY_ZEROORMORE).makeCanonical(); - if (effect.getRSet().containsTuple(h1star)) { - // rechability states contain heap root with arity star - containsStar=true; - } - } - if(containsStar){ - return ConflictEdge.COARSE_GRAIN_EDGE; - }else{ - return ConflictEdge.FINE_GRAIN_EDGE; - } - }else{ - return ConflictEdge.COARSE_GRAIN_EDGE; - } - - - /* - boolean containsAllTuple=true; - for (Iterator iterator2 = writeEffectsSet.iterator(); iterator2 - .hasNext();) { - SESEEffectsKey seseEffectsKey = (SESEEffectsKey) iterator2 - .next(); - ReachabilitySet rset = seseEffectsKey.getRSet(); - Iterator tsetIter=rset.iterator(); - int countNotContained=0; - while (tsetIter.hasNext()) { - TokenTupleSet tokenTupleSet = (TokenTupleSet) tsetIter - .next(); - boolean found=true; - for (Iterator iterator = rootIDSet.iterator(); iterator - .hasNext();) { - Integer rootID = (Integer) iterator.next(); - if(tokenTupleSet.containsToken(rootID)==null){ - found=false; - } - } - if(!found){ - countNotContained++; - } - } - if(countNotContained==rset.size()){ - containsAllTuple=false; - } - } - - if (containsAllTuple && liveInNode.getHRNSet().size() > 1) { - return ConflictEdge.COARSE_GRAIN_EDGE; - } else { - return ConflictEdge.FINE_GRAIN_EDGE; - } - */ - - - - } - - return ConflictEdge.NON_WRITE_CONFLICT; - - } - - public void analyzePossibleConflicts(Set analyzedIDSet, - ConflictNode currentNode) { - - // compare with all nodes - // examine the case where self-edge exists - if (currentNode instanceof LiveInNode) { - LiveInNode liveInNode = (LiveInNode) currentNode; - int conflictType=calculateSelfConflictType(liveInNode); - if(conflictType>0){ - addConflictEdge(conflictType, currentNode, - currentNode); - } - } - - Set> set = id2cn.entrySet(); - for (Iterator iterator = set.iterator(); iterator.hasNext();) { - Entry entry = (Entry) iterator - .next(); - - String entryNodeID = entry.getKey(); - ConflictNode entryNode = entry.getValue(); - - if ((!currentNode.getID().equals(entryNodeID)) - && !(analyzedIDSet.contains(currentNode.getID() - + entryNodeID) || analyzedIDSet - .contains(entryNodeID + currentNode.getID()))) { - - if (currentNode instanceof StallSiteNode - && entryNode instanceof LiveInNode) { - - int conflictType = calculateConflictType((StallSiteNode) currentNode, (LiveInNode) entryNode); - if (conflictType > 0) { - addConflictEdge(conflictType, currentNode, entryNode); - } - - analyzedIDSet.add(currentNode.getID() + entryNodeID); - - } else if (currentNode instanceof LiveInNode - && entryNode instanceof LiveInNode) { - - int conflictType = calculateConflictType( - (LiveInNode) currentNode, (LiveInNode) entryNode); - if (conflictType > 0) { - addConflictEdge(conflictType, currentNode, entryNode); - } - analyzedIDSet.add(currentNode.getID() + entryNodeID); - } - - } - - } - - } - -} - -class ConflictEdge { - - private ConflictNode u; - private ConflictNode v; - private int type; - - public static final int NON_WRITE_CONFLICT = 0; - public static final int FINE_GRAIN_EDGE = 1; - public static final int COARSE_GRAIN_EDGE = 2; - - public ConflictEdge(ConflictNode u, ConflictNode v, int type) { - this.u = u; - this.v = v; - this.type = type; - } - - public String toGraphEdgeString() { - if (type == FINE_GRAIN_EDGE) { - return "\"F_CONFLICT\""; - } else if (type == COARSE_GRAIN_EDGE) { - return "\"C_CONFLICT\""; - } else { - return "CONFLICT\""; - } - } - - public ConflictNode getVertexU() { - return u; - } - - public ConflictNode getVertexV() { - return v; - } - - public int getType() { - return type; - } - - public String toString() { - return getVertexU() + "-" + getVertexV(); - } - -} diff --git a/Robust/src/Analysis/MLP/ConflictNode.java b/Robust/src/Analysis/MLP/ConflictNode.java deleted file mode 100644 index 8243ad88..00000000 --- a/Robust/src/Analysis/MLP/ConflictNode.java +++ /dev/null @@ -1,66 +0,0 @@ -package Analysis.MLP; - -import java.util.HashSet; -import java.util.Set; - -import IR.Flat.TempDescriptor; - -public abstract class ConflictNode { - - protected TempDescriptor td; - protected String id; - protected HashSet edgeSet; - protected Set reachabilitySet; - protected TempDescriptor alias; - protected int type; - - public static final int FINE_READ = 0; - public static final int FINE_WRITE = 1; - public static final int PARENT_READ = 2; - public static final int PARENT_WRITE = 3; - public static final int COARSE = 4; - public static final int PARENT_COARSE = 5; - public static final int SCC = 6; - - - - public ConflictNode() { - edgeSet = new HashSet(); - } - - public TempDescriptor getTempDescriptor() { - return td; - } - - public String getID() { - return id; - } - - public int getType(){ - return type; - } - - public void setType(int type){ - this.type=type; - } - public void addEdge(ConflictEdge edge) { - edgeSet.add(edge); - } - - public HashSet getEdgeSet() { - return edgeSet; - } - - public Set getReachabilitySet() { - return reachabilitySet; - } - - public TempDescriptor getAlias(){ - return alias; - } - - public void setAlias(TempDescriptor alias){ - this.alias=alias; - } - -} diff --git a/Robust/src/Analysis/MLP/GloballyUniqueTokenTuple.java b/Robust/src/Analysis/MLP/GloballyUniqueTokenTuple.java deleted file mode 100644 index a461c484..00000000 --- a/Robust/src/Analysis/MLP/GloballyUniqueTokenTuple.java +++ /dev/null @@ -1,66 +0,0 @@ -package Analysis.MLP; - -import Analysis.OwnershipAnalysis.Canonical; -import Analysis.OwnershipAnalysis.TokenTuple; - -public class GloballyUniqueTokenTuple extends Canonical{ - - private Integer token; - private boolean isMultiObject; - private int arity; - private String id; - - public GloballyUniqueTokenTuple(String uniqueID, TokenTuple tt) { - this.id = uniqueID; - this.arity = tt.getArity(); - this.token = tt.getToken(); - this.isMultiObject = tt.isMultiObject(); - } - - public boolean isMultiObject() { - return isMultiObject; - } - - public int getArity() { - return arity; - } - - public int hashCode() { - return id.hashCode() + arity; - } - - public String getID() { - return id; - } - - public boolean equals(Object o) { - if (o == null) { - return false; - } - - if (!(o instanceof GloballyUniqueTokenTuple)) { - return false; - } - - GloballyUniqueTokenTuple tt = (GloballyUniqueTokenTuple) o; - - return id.equals(tt.getID()) && arity == tt.getArity(); - } - - public String toString() { - String s = id; - - if (isMultiObject) { - s += "M"; - } - - if (arity == TokenTuple.ARITY_ZEROORMORE) { - s += "*"; - } else if (arity == TokenTuple.ARITY_ONEORMORE) { - s += "+"; - } - - return s; - } - -} diff --git a/Robust/src/Analysis/MLP/LiveInNode.java b/Robust/src/Analysis/MLP/LiveInNode.java deleted file mode 100644 index aaa4ec6c..00000000 --- a/Robust/src/Analysis/MLP/LiveInNode.java +++ /dev/null @@ -1,178 +0,0 @@ -package Analysis.MLP; - -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; - -import Analysis.OwnershipAnalysis.HeapRegionNode; -import IR.Flat.TempDescriptor; - -public class LiveInNode extends ConflictNode { - - Set readEffectsSet; - Set writeEffectsSet; - Set strongUpdateSet; - Set hrnSet; - int seseID; - - public LiveInNode(String id, TempDescriptor td, Set hrnSet, - Set readEffectsSet, - Set writeEffectsSet, Set strongUpdateSet, Set reachabilitySet, int seseID) { - this.hrnSet = hrnSet; - this.id = id; - this.td = td; - this.readEffectsSet = readEffectsSet; - this.writeEffectsSet = writeEffectsSet; - this.strongUpdateSet=strongUpdateSet; - this.reachabilitySet = reachabilitySet; - this.seseID=seseID; - } - - public Set getHRNSet() { - return hrnSet; - } - - public Set getReadEffectsSet() { - return readEffectsSet; - } - - public Set getWriteEffectsSet() { - return writeEffectsSet; - } - - public Set getStrongUpdateSet(){ - return strongUpdateSet; - } - - public void addReadEffectsSet(Set newReadEffectsSet) { - if (newReadEffectsSet != null) { - readEffectsSet.addAll(newReadEffectsSet); - } - } - - public void addWriteEffectsSet(Set newWriteEffectsSet) { - if (newWriteEffectsSet != null) { - writeEffectsSet.addAll(newWriteEffectsSet); - } - } - - public void addReachabilitySet(Set newReachabilitySet) { - if (newReachabilitySet != null) { - reachabilitySet.addAll(newReachabilitySet); - } - } - - public boolean isWriteConflictWith(StallSiteNode stallNode) { - - // if live-in var has write-effects on heap region node of stall site, - // it is write conflict - - boolean result = false; - StallSite stallSite = stallNode.getStallSite(); - - if (writeEffectsSet != null) { - Iterator writeIter = writeEffectsSet.iterator(); - while (writeIter.hasNext()) { - SESEEffectsKey seseEffectsKey = (SESEEffectsKey) writeIter - .next(); - String writeHeapRegionID = seseEffectsKey.getHRNUniqueId(); - String writeFieldName = seseEffectsKey.getFieldDescriptor(); - - HashSet stallSiteHRNSet = stallNode.getHRNSet(); - for (Iterator iterator = stallSiteHRNSet.iterator(); iterator - .hasNext();) { - HeapRegionNode stallHRN = (HeapRegionNode) iterator.next(); - if (stallHRN.getGloballyUniqueIdentifier().equals( - writeHeapRegionID)) { - - // check whether there are read or write effects of - // stall sites - - HashSet effectSet = stallSite.getEffectSet(); - for (Iterator iterator2 = effectSet.iterator(); iterator2 - .hasNext();) { - Effect effect = (Effect) iterator2.next(); - String stallEffectfieldName = effect.getField(); - - if (stallEffectfieldName.equals(writeFieldName)) { - result = result | true; - } - } - - } - } - - } - } - - if (readEffectsSet != null) { - Iterator readIter = readEffectsSet.iterator(); - while (readIter.hasNext()) { - - SESEEffectsKey seseEffectsKey = (SESEEffectsKey) readIter - .next(); - String readHeapRegionID = seseEffectsKey.getHRNUniqueId(); - String readFieldName = seseEffectsKey.getFieldDescriptor(); - - HashSet stallSiteHRNSet = stallNode.getHRNSet(); - for (Iterator iterator = stallSiteHRNSet.iterator(); iterator - .hasNext();) { - HeapRegionNode stallHRN = (HeapRegionNode) iterator.next(); - if (stallHRN.getGloballyUniqueIdentifier().equals( - readHeapRegionID)) { - - HashSet effectSet = stallSite.getEffectSet(); - for (Iterator iterator2 = effectSet.iterator(); iterator2 - .hasNext();) { - Effect effect = (Effect) iterator2.next(); - String stallEffectfieldName = effect.getField(); - - if (effect.getEffectType().equals( - StallSite.WRITE_EFFECT)) { - if (stallEffectfieldName.equals(readFieldName)) { - result = result | true; - } - } - - } - - } - - } - - } - } - - return result; - } - - public int getSESEIdentifier(){ - return seseID; - } - - public boolean equals(Object o) { - - if (o == null) { - return false; - } - - if (!(o instanceof LiveInNode)) { - return false; - } - - LiveInNode in = (LiveInNode) o; - - if (id.equals(in.id)) { - return true; - } else { - return false; - } - - } - - public String toString() { - String str = "LiveInNode " + id +" type="+type; - return str; - } - -} diff --git a/Robust/src/Analysis/MLP/MLPAnalysis.java b/Robust/src/Analysis/MLP/MLPAnalysis.java deleted file mode 100644 index c0e610cc..00000000 --- a/Robust/src/Analysis/MLP/MLPAnalysis.java +++ /dev/null @@ -1,3846 +0,0 @@ -package Analysis.MLP; - -import java.io.BufferedWriter; -import java.io.FileWriter; -import java.io.IOException; -import java.io.StringWriter; -import java.util.Enumeration; -import java.util.HashSet; -import java.util.Hashtable; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.Map; -import java.util.Collection; -import java.util.Set; -import java.util.Stack; -import java.util.Map.Entry; -import Analysis.CallGraph.CallGraph; -import Analysis.CallGraph.JavaCallGraph; -import Analysis.OwnershipAnalysis.AllocationSite; -import Analysis.OwnershipAnalysis.EffectsKey; -import Analysis.OwnershipAnalysis.HeapRegionNode; -import Analysis.OwnershipAnalysis.LabelNode; -import Analysis.OwnershipAnalysis.MethodContext; -import Analysis.OwnershipAnalysis.MethodEffects; -import Analysis.OwnershipAnalysis.OwnershipAnalysis; -import Analysis.OwnershipAnalysis.OwnershipGraph; -import Analysis.OwnershipAnalysis.OwnershipNode; -import Analysis.OwnershipAnalysis.ParameterDecomposition; -import Analysis.OwnershipAnalysis.ReachabilitySet; -import Analysis.OwnershipAnalysis.ReferenceEdge; -import Analysis.OwnershipAnalysis.TokenTuple; -import Analysis.OwnershipAnalysis.TokenTupleSet; -import IR.Descriptor; -import IR.FieldDescriptor; -import IR.MethodDescriptor; -import IR.Operation; -import IR.State; -import IR.TypeDescriptor; -import IR.TypeUtil; -import IR.Flat.FKind; -import IR.Flat.FlatCall; -import IR.Flat.FlatCondBranch; -import IR.Flat.FlatEdge; -import IR.Flat.FlatElementNode; -import IR.Flat.FlatFieldNode; -import IR.Flat.FlatMethod; -import IR.Flat.FlatNew; -import IR.Flat.FlatNode; -import IR.Flat.FlatOpNode; -import IR.Flat.FlatReturnNode; -import IR.Flat.FlatSESEEnterNode; -import IR.Flat.FlatSESEExitNode; -import IR.Flat.FlatSetElementNode; -import IR.Flat.FlatSetFieldNode; -import IR.Flat.FlatWriteDynamicVarNode; -import IR.Flat.TempDescriptor; - - -public class MLPAnalysis { - - // data from the compiler - private State state; - private TypeUtil typeUtil; - private CallGraph callGraph; - private OwnershipAnalysis ownAnalysis; - - - // an implicit SESE is automatically spliced into - // the IR graph around the C main before this analysis--it - // is nothing special except that we can make assumptions - // about it, such as the whole program ends when it ends - private FlatSESEEnterNode mainSESE; - - // SESEs that are the root of an SESE tree belong to this - // set--the main SESE is always a root, statically SESEs - // inside methods are a root because we don't know how they - // will fit into the runtime tree of SESEs - private Set rootSESEs; - - // simply a set of every reachable SESE in the program, not - // including caller placeholder SESEs - private Set allSESEs; - - - // A mapping of flat nodes to the stack of SESEs for that node, where - // an SESE is the child of the SESE directly below it on the stack. - // These stacks do not reflect the heirarchy over methods calls--whenever - // there is an empty stack it means all variables are available. - private Hashtable< FlatNode, Stack > seseStacks; - - private Hashtable< FlatNode, Set > livenessRootView; - private Hashtable< FlatNode, Set > livenessVirtualReads; - private Hashtable< FlatNode, VarSrcTokTable > variableResults; - private Hashtable< FlatNode, Set > notAvailableResults; - private Hashtable< FlatNode, CodePlan > codePlans; - - private Hashtable< FlatSESEEnterNode, Set > notAvailableIntoSESE; - - private Hashtable< FlatEdge, FlatWriteDynamicVarNode > wdvNodesToSpliceIn; - - private Hashtable< MethodContext, HashSet> mapMethodContextToLiveInAllocationSiteSet; - - private Hashtable < FlatNode, ParentChildConflictsMap > conflictsResults; - private Hashtable< FlatMethod, MethodSummary > methodSummaryResults; - private OwnershipAnalysis ownAnalysisForSESEConflicts; - private Hashtable conflictGraphResults; - - // temporal data structures to track analysis progress. - private MethodSummary currentMethodSummary; - private HashSet preeffectsSet; - private Hashtable isAfterChildSESEIndicatorMap; - private Hashtable seseSummaryMap; - private Hashtable> conflictGraphLockMap; - static private int uniqueLockSetId = 0; - - public static int maxSESEage = -1; - - - // use these methods in BuildCode to have access to analysis results - public FlatSESEEnterNode getMainSESE() { - return mainSESE; - } - - public Set getRootSESEs() { - return rootSESEs; - } - - public Set getAllSESEs() { - return allSESEs; - } - - public int getMaxSESEage() { - return maxSESEage; - } - - // may be null - public CodePlan getCodePlan( FlatNode fn ) { - CodePlan cp = codePlans.get( fn ); - return cp; - } - - - public MLPAnalysis( State state, - TypeUtil tu, - CallGraph callGraph, - OwnershipAnalysis ownAnalysis - ) { - - double timeStartAnalysis = (double) System.nanoTime(); - - this.state = state; - this.typeUtil = tu; - this.callGraph = callGraph; - this.ownAnalysis = ownAnalysis; - this.maxSESEage = state.MLP_MAXSESEAGE; - - rootSESEs = new HashSet(); - allSESEs = new HashSet(); - - seseStacks = new Hashtable< FlatNode, Stack >(); - livenessRootView = new Hashtable< FlatNode, Set >(); - livenessVirtualReads = new Hashtable< FlatNode, Set >(); - variableResults = new Hashtable< FlatNode, VarSrcTokTable >(); - notAvailableResults = new Hashtable< FlatNode, Set >(); - codePlans = new Hashtable< FlatNode, CodePlan >(); - wdvNodesToSpliceIn = new Hashtable< FlatEdge, FlatWriteDynamicVarNode >(); - - notAvailableIntoSESE = new Hashtable< FlatSESEEnterNode, Set >(); - - mapMethodContextToLiveInAllocationSiteSet = new Hashtable< MethodContext, HashSet>(); - - conflictsResults = new Hashtable < FlatNode, ParentChildConflictsMap >(); - methodSummaryResults=new Hashtable(); - conflictGraphResults=new Hashtable(); - - seseSummaryMap= new Hashtable(); - isAfterChildSESEIndicatorMap= new Hashtable(); - conflictGraphLockMap=new Hashtable>(); - - FlatMethod fmMain = state.getMethodFlat( typeUtil.getMain() ); - - mainSESE = (FlatSESEEnterNode) fmMain.getNext(0); - mainSESE.setfmEnclosing( fmMain ); - mainSESE.setmdEnclosing( fmMain.getMethod() ); - mainSESE.setcdEnclosing( fmMain.getMethod().getClassDesc() ); - - - // 1st pass - // run analysis on each method that is actually called - // reachability analysis already computed this so reuse - Iterator methItr = ownAnalysis.descriptorsToAnalyze.iterator(); - while( methItr.hasNext() ) { - Descriptor d = methItr.next(); - FlatMethod fm = state.getMethodFlat( d ); - - // find every SESE from methods that may be called - // and organize them into roots and children - buildForestForward( fm ); - } - - - // 2nd pass, results are saved in FlatSESEEnterNode, so - // intermediate results, for safety, are discarded - Iterator rootItr = rootSESEs.iterator(); - while( rootItr.hasNext() ) { - FlatSESEEnterNode root = rootItr.next(); - livenessAnalysisBackward( root, - true, - null ); - } - - - // 3rd pass - methItr = ownAnalysis.descriptorsToAnalyze.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 ); - } - - // 4th pass, compute liveness contribution from - // virtual reads discovered in variable pass - rootItr = rootSESEs.iterator(); - while( rootItr.hasNext() ) { - FlatSESEEnterNode root = rootItr.next(); - livenessAnalysisBackward( root, - true, - null ); - } - - - /* - SOMETHING IS WRONG WITH THIS, DON'T USE IT UNTIL IT CAN BE FIXED - - // 5th pass - methItr = ownAnalysis.descriptorsToAnalyze.iterator(); - while( methItr.hasNext() ) { - Descriptor d = methItr.next(); - FlatMethod fm = state.getMethodFlat( d ); - - // prune variable results in one traversal - // by removing reference variables that are not live - pruneVariableResultsWithLiveness( fm ); - } - */ - - - // 6th pass - methItr = ownAnalysis.descriptorsToAnalyze.iterator(); - while( methItr.hasNext() ) { - Descriptor d = methItr.next(); - FlatMethod fm = state.getMethodFlat( d ); - - // compute what is not available at every program - // point, in a forward fixed-point pass - notAvailableForward( fm ); - } - - if(state.METHODEFFECTS){ - // new pass, sese effects analysis - methItr = ownAnalysis.descriptorsToAnalyze.iterator(); - JavaCallGraph javaCallGraph = new JavaCallGraph(state,tu); - while( methItr.hasNext() ) { - Descriptor d = methItr.next(); - FlatMethod fm = state.getMethodFlat( d ); - methodEffects(fm,javaCallGraph); - } - - // Parent/child memory conflicts analysis - seseConflictsForward(javaCallGraph); - - Set keySet=mapMethodContextToLiveInAllocationSiteSet.keySet(); - for (Iterator iterator = keySet.iterator(); iterator.hasNext();) { - MethodContext methodContext = (MethodContext) iterator.next(); - HashSet asSet=mapMethodContextToLiveInAllocationSiteSet.get(methodContext); - for (Iterator iterator2 = asSet.iterator(); iterator2.hasNext();) { - AllocationSite allocationSite = (AllocationSite) iterator2.next(); - } - } - - // disjoint analysis with a set of flagged allocation sites of live-in variables & stall sites - try { - ownAnalysisForSESEConflicts = new OwnershipAnalysis(state, - tu, - callGraph, - ownAnalysis.liveness, - ownAnalysis.arrayReferencees, - state.OWNERSHIPALLOCDEPTH, false, - false, state.OWNERSHIPALIASFILE, - state.METHODEFFECTS, - mapMethodContextToLiveInAllocationSiteSet); - // debug - methItr = ownAnalysisForSESEConflicts.descriptorsToAnalyze.iterator(); - while (methItr.hasNext()) { - Descriptor d = methItr.next(); - FlatMethod fm = state.getMethodFlat(d); - debugFunction(ownAnalysisForSESEConflicts, fm); - } - // - } catch (IOException e) { - System.err.println(e); - } - - // postSESEConflictsForward(javaCallGraph); - // another pass for making graph - makeConflictGraph(); - - // lock synthesis - synthesizeLocks(); - /* - methItr = ownAnalysis.descriptorsToAnalyze.iterator(); - while (methItr.hasNext()) { - Descriptor d = methItr.next(); - FlatMethod fm = state.getMethodFlat(d); - makeConflictGraph2(fm); - } - - Enumeration keyEnum1=conflictGraphResults.keys(); - while (keyEnum1.hasMoreElements()) { - FlatNode flatNode = (FlatNode) keyEnum1.nextElement(); - ConflictGraph conflictGraph=conflictGraphResults.get(flatNode); - conflictGraph.analyzeConflicts(); - conflictGraphResults.put(flatNode, conflictGraph); - } - */ - - Enumeration keyEnum=conflictGraphResults.keys(); - while (keyEnum.hasMoreElements()) { - FlatNode key = (FlatNode) keyEnum.nextElement(); - ConflictGraph cg=conflictGraphResults.get(key); - try { - if(cg.hasConflictEdge()){ - cg.writeGraph("ConflictGraphFor"+key, false); - } - } catch (IOException e) { - System.out.println("Error writing"); - System.exit(0); - } - } - } - - - // 7th pass - methItr = ownAnalysis.descriptorsToAnalyze.iterator(); - while( methItr.hasNext() ) { - Descriptor d = methItr.next(); - FlatMethod fm = state.getMethodFlat( d ); - - // compute a plan for code injections - codePlansForward( fm ); - } - - - // splice new IR nodes into graph after all - // analysis passes are complete - Iterator spliceItr = wdvNodesToSpliceIn.entrySet().iterator(); - while( spliceItr.hasNext() ) { - Map.Entry me = (Map.Entry) spliceItr.next(); - FlatWriteDynamicVarNode fwdvn = (FlatWriteDynamicVarNode) me.getValue(); - fwdvn.spliceIntoIR(); - } - - - double timeEndAnalysis = (double) System.nanoTime(); - double dt = (timeEndAnalysis - timeStartAnalysis)/(Math.pow( 10.0, 9.0 ) ); - String treport = String.format( "The mlp analysis took %.3f sec.", dt ); - System.out.println( treport ); - - if( state.MLPDEBUG ) { - try { - writeReports( treport ); - } catch( IOException e ) {} - } - } - - - private void buildForestForward( FlatMethod fm ) { - - // start from flat method top, visit every node in - // method exactly once, find SESEs and remember - // roots and child relationships - Set flatNodesToVisit = new HashSet(); - flatNodesToVisit.add( fm ); - - Set visited = new HashSet(); - - Stack seseStackFirst = new Stack(); - seseStacks.put( fm, seseStackFirst ); - - while( !flatNodesToVisit.isEmpty() ) { - Iterator fnItr = flatNodesToVisit.iterator(); - FlatNode fn = fnItr.next(); - - Stack seseStack = seseStacks.get( fn ); - assert seseStack != null; - - flatNodesToVisit.remove( fn ); - visited.add( fn ); - - buildForest_nodeActions( fn, seseStack, fm ); - - for( int i = 0; i < fn.numNext(); i++ ) { - FlatNode nn = fn.getNext( i ); - - if( !visited.contains( nn ) ) { - flatNodesToVisit.add( nn ); - - // clone stack and send along each analysis path - seseStacks.put( nn, (Stack)seseStack.clone() ); - } - } - } - } - - private void buildForest_nodeActions( FlatNode fn, - Stack seseStack, - FlatMethod fm ) { - switch( fn.kind() ) { - - case FKind.FlatSESEEnterNode: { - FlatSESEEnterNode fsen = (FlatSESEEnterNode) fn; - - if( !fsen.getIsCallerSESEplaceholder() ) { - allSESEs.add( fsen ); - } - - fsen.setfmEnclosing( fm ); - fsen.setmdEnclosing( fm.getMethod() ); - fsen.setcdEnclosing( fm.getMethod().getClassDesc() ); - - if( seseStack.empty() ) { - rootSESEs.add( fsen ); - fsen.setParent( null ); - } else { - seseStack.peek().addChild( fsen ); - fsen.setParent( seseStack.peek() ); - } - - seseStack.push( fsen ); - } break; - - case FKind.FlatSESEExitNode: { - FlatSESEExitNode fsexn = (FlatSESEExitNode) fn; - assert !seseStack.empty(); - FlatSESEEnterNode fsen = seseStack.pop(); - } break; - - case FKind.FlatReturnNode: { - FlatReturnNode frn = (FlatReturnNode) fn; - if( !seseStack.empty() && - !seseStack.peek().getIsCallerSESEplaceholder() - ) { - throw new Error( "Error: return statement enclosed within SESE "+ - seseStack.peek().getPrettyIdentifier() ); - } - } break; - - } - } - - - private void livenessAnalysisBackward( FlatSESEEnterNode fsen, - boolean toplevel, - Hashtable< FlatSESEExitNode, Set > liveout ) { - - // start from an SESE exit, visit nodes in reverse up to - // SESE enter in a fixed-point scheme, where children SESEs - // should already be analyzed and therefore can be skipped - // because child SESE enter node has all necessary info - Set flatNodesToVisit = new HashSet(); - - if( toplevel ) { - flatNodesToVisit.add( fsen.getfmEnclosing().getFlatExit() ); - } else { - flatNodesToVisit.add( fsen.getFlatExit() ); - } - - Hashtable> livenessResults = - new Hashtable< FlatNode, Set >(); - - if( toplevel ) { - liveout = new Hashtable< FlatSESEExitNode, Set >(); - } - - while( !flatNodesToVisit.isEmpty() ) { - FlatNode fn = (FlatNode) flatNodesToVisit.iterator().next(); - flatNodesToVisit.remove( fn ); - - Set prev = livenessResults.get( fn ); - - // merge sets from control flow joins - Set u = new HashSet(); - for( int i = 0; i < fn.numNext(); i++ ) { - FlatNode nn = fn.getNext( i ); - Set s = livenessResults.get( nn ); - if( s != null ) { - u.addAll( s ); - } - } - - Set curr = liveness_nodeActions( fn, u, fsen, toplevel, liveout); - - // if a new result, schedule backward nodes for analysis - if( !curr.equals( prev ) ) { - livenessResults.put( fn, curr ); - - // don't flow backwards past current SESE enter - if( !fn.equals( fsen ) ) { - for( int i = 0; i < fn.numPrev(); i++ ) { - FlatNode nn = fn.getPrev( i ); - flatNodesToVisit.add( nn ); - } - } - } - } - - Set s = livenessResults.get( fsen ); - if( s != null ) { - fsen.addInVarSet( s ); - } - - // remember liveness per node from the root view as the - // global liveness of variables for later passes to use - if( toplevel ) { - livenessRootView.putAll( livenessResults ); - } - - // post-order traversal, so do children first - Iterator childItr = fsen.getChildren().iterator(); - while( childItr.hasNext() ) { - FlatSESEEnterNode fsenChild = childItr.next(); - livenessAnalysisBackward( fsenChild, false, liveout ); - } - } - - private Set liveness_nodeActions( FlatNode fn, - Set liveIn, - FlatSESEEnterNode currentSESE, - boolean toplevel, - Hashtable< FlatSESEExitNode, Set > liveout - ) { - switch( fn.kind() ) { - - case FKind.FlatSESEExitNode: - if( toplevel ) { - FlatSESEExitNode fsexn = (FlatSESEExitNode) fn; - if( !liveout.containsKey( fsexn ) ) { - liveout.put( fsexn, new HashSet() ); - } - liveout.get( fsexn ).addAll( liveIn ); - } - // no break, sese exits should also execute default actions - - 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] ); - - if( !toplevel ) { - FlatSESEExitNode fsexn = currentSESE.getFlatExit(); - Set livetemps = liveout.get( fsexn ); - if( livetemps != null && - livetemps.contains( writeTemps[i] ) ) { - // write to a live out temp... - // need to put in SESE liveout set - currentSESE.addOutVar( writeTemps[i] ); - } - } - } - - TempDescriptor [] readTemps = fn.readsTemps(); - for( int i = 0; i < readTemps.length; ++i ) { - liveIn.add( readTemps[i] ); - } - - 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(); - flatNodesToVisit.add( fm ); - - while( !flatNodesToVisit.isEmpty() ) { - FlatNode fn = (FlatNode) flatNodesToVisit.iterator().next(); - flatNodesToVisit.remove( fn ); - - Stack seseStack = seseStacks.get( fn ); - assert seseStack != null; - - VarSrcTokTable prev = variableResults.get( fn ); - - // merge sets from control flow joins - VarSrcTokTable curr = new VarSrcTokTable(); - for( int i = 0; i < fn.numPrev(); i++ ) { - FlatNode nn = fn.getPrev( i ); - VarSrcTokTable incoming = variableResults.get( nn ); - curr.merge( incoming ); - } - - if( !seseStack.empty() ) { - variable_nodeActions( fn, curr, seseStack.peek() ); - } - - // if a new result, schedule forward nodes for analysis - if( !curr.equals( prev ) ) { - variableResults.put( fn, curr ); - - for( int i = 0; i < fn.numNext(); i++ ) { - FlatNode nn = fn.getNext( i ); - flatNodesToVisit.add( nn ); - } - } - } - } - - private void variable_nodeActions( FlatNode fn, - VarSrcTokTable vstTable, - FlatSESEEnterNode currentSESE ) { - switch( fn.kind() ) { - - case FKind.FlatSESEEnterNode: { - FlatSESEEnterNode fsen = (FlatSESEEnterNode) fn; - assert fsen.equals( currentSESE ); - - vstTable.age( currentSESE ); - vstTable.assertConsistency(); - } break; - - case FKind.FlatSESEExitNode: { - FlatSESEExitNode fsexn = (FlatSESEExitNode) fn; - FlatSESEEnterNode fsen = fsexn.getFlatEnter(); - assert currentSESE.getChildren().contains( fsen ); - - // remap all of this child's children tokens to be - // from this child as the child exits - vstTable.remapChildTokens( fsen ); - - // liveness virtual reads are things that might be - // 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 = livenessRootView.get( fn ); - Set fsenVirtReads = vstTable.calcVirtReadsAndPruneParentAndSiblingTokens( fsen, liveVars ); - Set fsenVirtReadsOld = livenessVirtualReads.get( fn ); - if( fsenVirtReadsOld != null ) { - fsenVirtReads.addAll( fsenVirtReadsOld ); - } - livenessVirtualReads.put( fn, fsenVirtReads ); - - - // then all child out-set tokens are guaranteed - // to be filled in, so clobber those entries with - // the latest, clean sources - Iterator outVarItr = fsen.getOutVarSet().iterator(); - while( outVarItr.hasNext() ) { - TempDescriptor outVar = outVarItr.next(); - HashSet ts = new HashSet(); - ts.add( outVar ); - VariableSourceToken vst = - new VariableSourceToken( ts, - fsen, - new Integer( 0 ), - outVar - ); - vstTable.remove( outVar ); - vstTable.add( vst ); - } - vstTable.assertConsistency(); - - } break; - - case FKind.FlatOpNode: { - FlatOpNode fon = (FlatOpNode) fn; - - if( fon.getOp().getOp() == Operation.ASSIGN ) { - TempDescriptor lhs = fon.getDest(); - TempDescriptor rhs = fon.getLeft(); - - vstTable.remove( lhs ); - - Set forAddition = new HashSet(); - - Iterator itr = vstTable.get( rhs ).iterator(); - while( itr.hasNext() ) { - VariableSourceToken vst = itr.next(); - - HashSet ts = new HashSet(); - ts.add( lhs ); - - if( currentSESE.getChildren().contains( vst.getSESE() ) ) { - // if the source comes from a child, copy it over - 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 - ) - ); - } - } - - vstTable.addAll( forAddition ); - - // only break if this is an ASSIGN op node, - // otherwise fall through to default case - vstTable.assertConsistency(); - break; - } - } - - // note that FlatOpNode's that aren't ASSIGN - // fall through to this default case - default: { - TempDescriptor [] writeTemps = fn.writesTemps(); - 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 - //assert writeTemps.length == 1; - if( writeTemps.length > 1 ) { - assert fn.kind() == FKind.FlatCall || - fn.kind() == FKind.FlatMethod; - break; - } - - vstTable.remove( writeTemps[0] ); - - HashSet ts = new HashSet(); - ts.add( writeTemps[0] ); - - vstTable.add( new VariableSourceToken( ts, - currentSESE, - new Integer( 0 ), - writeTemps[0] - ) - ); - } - - vstTable.assertConsistency(); - } break; - - } // end switch - } - - - private void pruneVariableResultsWithLiveness( FlatMethod fm ) { - - // start from flat method top, visit every node in - // method exactly once - Set flatNodesToVisit = new HashSet(); - flatNodesToVisit.add( fm ); - - Set visited = new HashSet(); - - while( !flatNodesToVisit.isEmpty() ) { - Iterator fnItr = flatNodesToVisit.iterator(); - FlatNode fn = fnItr.next(); - - flatNodesToVisit.remove( fn ); - visited.add( fn ); - - Set rootLiveSet = livenessRootView.get( fn ); - VarSrcTokTable vstTable = variableResults.get( fn ); - - vstTable.pruneByLiveness( rootLiveSet ); - - for( int i = 0; i < fn.numNext(); i++ ) { - FlatNode nn = fn.getNext( i ); - - if( !visited.contains( nn ) ) { - flatNodesToVisit.add( nn ); - } - } - } - } - - - private void notAvailableForward( FlatMethod fm ) { - - Set flatNodesToVisit = new HashSet(); - flatNodesToVisit.add( fm ); - - while( !flatNodesToVisit.isEmpty() ) { - FlatNode fn = (FlatNode) flatNodesToVisit.iterator().next(); - flatNodesToVisit.remove( fn ); - - Stack seseStack = seseStacks.get( fn ); - assert seseStack != null; - - Set prev = notAvailableResults.get( fn ); - - Set curr = new HashSet(); - for( int i = 0; i < fn.numPrev(); i++ ) { - FlatNode nn = fn.getPrev( i ); - Set notAvailIn = notAvailableResults.get( nn ); - if( notAvailIn != null ) { - curr.addAll( notAvailIn ); - } - } - - if( !seseStack.empty() ) { - notAvailable_nodeActions( fn, curr, seseStack.peek() ); - } - - // if a new result, schedule forward nodes for analysis - if( !curr.equals( prev ) ) { - notAvailableResults.put( fn, curr ); - - for( int i = 0; i < fn.numNext(); i++ ) { - FlatNode nn = fn.getNext( i ); - flatNodesToVisit.add( nn ); - } - } - } - } - - 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 - // as temps to be grabbed at runtime! - - switch( fn.kind() ) { - - case FKind.FlatSESEEnterNode: { - FlatSESEEnterNode fsen = (FlatSESEEnterNode) fn; - assert fsen.equals( currentSESE ); - - // keep a copy of what's not available into the SESE - // and restore it at the matching exit node - Set notAvailCopy = new HashSet(); - Iterator tdItr = notAvailSet.iterator(); - while( tdItr.hasNext() ) { - notAvailCopy.add( tdItr.next() ); - } - notAvailableIntoSESE.put( fsen, notAvailCopy ); - - notAvailSet.clear(); - } break; - - case FKind.FlatSESEExitNode: { - FlatSESEExitNode fsexn = (FlatSESEExitNode) fn; - FlatSESEEnterNode fsen = fsexn.getFlatEnter(); - assert currentSESE.getChildren().contains( fsen ); - - notAvailSet.addAll( fsen.getOutVarSet() ); - - Set notAvailIn = notAvailableIntoSESE.get( fsen ); - assert notAvailIn != null; - notAvailSet.addAll( notAvailIn ); - - } break; - - case FKind.FlatMethod: { - notAvailSet.clear(); - } - - case FKind.FlatOpNode: { - FlatOpNode fon = (FlatOpNode) fn; - - if( fon.getOp().getOp() == Operation.ASSIGN ) { - TempDescriptor lhs = fon.getDest(); - TempDescriptor rhs = fon.getLeft(); - - // copy makes lhs same availability as rhs - if( notAvailSet.contains( rhs ) ) { - notAvailSet.add( lhs ); - } else { - notAvailSet.remove( lhs ); - } - - // only break if this is an ASSIGN op node, - // otherwise fall through to default case - break; - } - } - - // note that FlatOpNode's that aren't ASSIGN - // fall through to this default case - default: { - TempDescriptor [] writeTemps = fn.writesTemps(); - for( int i = 0; i < writeTemps.length; i++ ) { - TempDescriptor wTemp = writeTemps[i]; - notAvailSet.remove( wTemp ); - } - TempDescriptor [] readTemps = fn.readsTemps(); - for( int i = 0; i < readTemps.length; i++ ) { - TempDescriptor rTemp = readTemps[i]; - notAvailSet.remove( rTemp ); - - // if this variable has exactly one source, potentially - // get other things from this source as well - VarSrcTokTable vstTable = variableResults.get( fn ); - - VSTWrapper vstIfStatic = new VSTWrapper(); - Integer srcType = - vstTable.getRefVarSrcType( rTemp, - currentSESE, - vstIfStatic - ); - - if( srcType.equals( VarSrcTokTable.SrcType_STATIC ) ) { - - VariableSourceToken vst = vstIfStatic.vst; - - Iterator availItr = vstTable.get( vst.getSESE(), - vst.getAge() - ).iterator(); - - // look through things that are also available from same source - while( availItr.hasNext() ) { - VariableSourceToken vstAlsoAvail = availItr.next(); - - Iterator refVarItr = vstAlsoAvail.getRefVars().iterator(); - while( refVarItr.hasNext() ) { - TempDescriptor refVarAlso = refVarItr.next(); - - // if a variable is available from the same source, AND it ALSO - // only comes from one statically known source, mark it available - VSTWrapper vstIfStaticNotUsed = new VSTWrapper(); - Integer srcTypeAlso = - vstTable.getRefVarSrcType( refVarAlso, - currentSESE, - vstIfStaticNotUsed - ); - if( srcTypeAlso.equals( VarSrcTokTable.SrcType_STATIC ) ) { - notAvailSet.remove( refVarAlso ); - } - } - } - } - } - } break; - - } // end switch - } - - private void debugFunction(OwnershipAnalysis oa2, FlatMethod fm) { - - String methodName="SomeWork"; - - MethodDescriptor md=fm.getMethod(); - HashSet mcSet=oa2.getAllMethodContextSetByDescriptor(md); - Iterator mcIter=mcSet.iterator(); - - while(mcIter.hasNext()){ - MethodContext mc=mcIter.next(); - - OwnershipGraph og=oa2.getOwnvershipGraphByMethodContext(mc); - - if(fm.toString().indexOf(methodName)>0){ - try { - og.writeGraph("SECONDGRAPH"+fm.toString(), - true, // write labels (variables) - true, // selectively hide intermediate temp vars - true, // prune unreachable heap regions - false, // show back edges to confirm graph validity - false, // show parameter indices (unmaintained!) - true, // hide subset reachability states - false);// hide edge taints - } catch (IOException e) { - System.out.println("Error writing debug capture."); - System.exit(0); - } - } - } - - } - - private void methodEffects(FlatMethod fm, CallGraph callGraph) { - - MethodDescriptor md=fm.getMethod(); - HashSet mcSet=ownAnalysis.getAllMethodContextSetByDescriptor(md); - Iterator mcIter=mcSet.iterator(); - - while(mcIter.hasNext()){ - MethodContext mc=mcIter.next(); - - Set visited = new HashSet(); - - Set flatNodesToVisit = new HashSet(); - flatNodesToVisit.add(fm); - - Hashtable invarMap=new Hashtable(); - - while (!flatNodesToVisit.isEmpty()) { - FlatNode fn = (FlatNode) flatNodesToVisit.iterator().next(); - flatNodesToVisit.remove(fn); - - Stack seseStack = seseStacks.get(fn); - assert seseStack != null; - - if (!seseStack.empty()) { - effects_nodeActions(mc, fn, seseStack.peek(), callGraph,invarMap); - } - - flatNodesToVisit.remove(fn); - visited.add(fn); - - for (int i = 0; i < fn.numNext(); i++) { - FlatNode nn = fn.getNext(i); - if (!visited.contains(nn)) { - flatNodesToVisit.add(nn); - } - } - - } - - - } - - } - - private void analyzeRelatedAllocationSite(MethodDescriptor callerMD, - MethodContext calleeMC, HashSet paramIndexSet, - HashSet visitedHRN) { - - HashSet mcSet = ownAnalysis - .getAllMethodContextSetByDescriptor(callerMD); - - if (mcSet != null) { - - Iterator mcIter = mcSet.iterator(); - - FlatMethod callerFM = state.getMethodFlat(callerMD); - - while (mcIter.hasNext()) { - MethodContext mc = mcIter.next(); - - Set visited = new HashSet(); - Set flatNodesToVisit = new HashSet(); - flatNodesToVisit.add(callerFM); - - while (!flatNodesToVisit.isEmpty()) { - FlatNode fn = (FlatNode) flatNodesToVisit.iterator().next(); - flatNodesToVisit.remove(fn); - - analyzeRelatedAllocationSite_NodeAction(fn, mc, calleeMC, - paramIndexSet,visitedHRN); - - flatNodesToVisit.remove(fn); - visited.add(fn); - - for (int i = 0; i < fn.numNext(); i++) { - FlatNode nn = fn.getNext(i); - if (!visited.contains(nn)) { - flatNodesToVisit.add(nn); - } - } - } - } - } - - } - - private void analyzeRelatedAllocationSite_NodeAction(FlatNode fn, MethodContext callerMC, - MethodContext calleeMC, - HashSet paramIndexSet, HashSet visitedHRN) { - - OwnershipGraph og = ownAnalysis - .getOwnvershipGraphByMethodContext(callerMC); - - switch (fn.kind()) { - - case FKind.FlatCall: { - - FlatCall fc = (FlatCall) fn; - - - if(fc.numArgs()>0 && fc.getMethod().equals(calleeMC.getDescriptor())){ - MethodContext calleeMCfromOG = ownAnalysis.getCalleeMethodContext( - callerMC, fc); - - // disable below condition. currently collect all possible - // allocation sites without regarding method context - - // if (calleeMC.equals(calleeMCfromOG)) { // in this case, this - // method context calls corresponding callee. - - int base; - if (((MethodDescriptor) calleeMC.getDescriptor()).isStatic()) { - base = 0; - } else { - base = 1; - } - - for (Iterator iterator = paramIndexSet.iterator(); iterator - .hasNext();) { - Integer integer = (Integer) iterator.next(); - - int paramIdx = integer - base; - if (paramIdx >= 0) { - // if paramIdx is less than 0, assumes that it is - // related with wrong method contexts. - TempDescriptor arg = fc.getArg(paramIdx); - LabelNode argLN = og.td2ln.get(arg); - if (argLN != null) { - Iterator iterEdge = argLN - .iteratorToReferencees(); - while (iterEdge.hasNext()) { - ReferenceEdge referenceEdge = (ReferenceEdge) iterEdge - .next(); - - HeapRegionNode dstHRN = referenceEdge.getDst(); - if (dstHRN.isParameter()) { - if (!visitedHRN.contains(dstHRN)) { - setupRelatedAllocSiteAnalysis(og, callerMC, - dstHRN, visitedHRN); - } - } else { -// System.out.println("FLAGGED "+callerMC+":fc="+fc+":arg="+arg+" , paramIdx="+paramIdx); - flagAllocationSite(callerMC, dstHRN - .getAllocationSite()); - } - } - } - } - } - } - - - // } - - } - break; - - } - } - - private void setupRelatedAllocSiteAnalysis(OwnershipGraph og, - MethodContext mc, HeapRegionNode dstHRN, - HashSet visitedHRN) { - - HashSet paramIndexSet = new HashSet(); - - // collect corresponding param index - Set pIndexSet = og.idPrimary2paramIndexSet.get(dstHRN.getID()); - if (pIndexSet != null) { - for (Iterator iterator = pIndexSet.iterator(); iterator.hasNext();) { - Integer integer = (Integer) iterator.next(); - paramIndexSet.add(integer); - } - } - - Set sIndexSet = og.idSecondary2paramIndexSet.get(dstHRN - .getID()); - if (sIndexSet != null) { - for (Iterator iterator = sIndexSet.iterator(); iterator.hasNext();) { - Integer integer = (Integer) iterator.next(); - paramIndexSet.add(integer); - } - } - - if (mc.getDescriptor() instanceof MethodDescriptor) { - Set callerSet = callGraph.getCallerSet((MethodDescriptor) mc - .getDescriptor()); - for (Iterator iterator = callerSet.iterator(); iterator.hasNext();) { - Object obj = (Object) iterator.next(); - if (obj instanceof MethodDescriptor) { - MethodDescriptor callerMD = (MethodDescriptor) obj; - - if(callerMD.equals(mc.getDescriptor())){ - continue; - } - analyzeRelatedAllocationSite(callerMD, mc, paramIndexSet,visitedHRN); - - } - } - } - } - - private void effects_nodeActions(MethodContext mc, FlatNode fn, - FlatSESEEnterNode currentSESE, CallGraph callGraph,Hashtable invarMap) { - - OwnershipGraph og = ownAnalysis.getOwnvershipGraphByMethodContext(mc); - - switch (fn.kind()) { - - case FKind.FlatSESEEnterNode: { - - FlatSESEEnterNode fsen = (FlatSESEEnterNode) fn; - assert fsen.equals(currentSESE); - - if (!fsen.getIsCallerSESEplaceholder()) { - // uniquely taint each live-in variable - Collection set = fsen.getInVarSet(); - Iterator iter = set.iterator(); - int idx = 0; - while (iter.hasNext()) { - TempDescriptor td = iter.next(); - LabelNode ln = og.td2ln.get(td); - - if(currentSESE.getSeseEffectsSet().getMapTempDescToInVarIdx().containsKey(td)){ - idx=currentSESE.getSeseEffectsSet().getInVarIdx(td); - } - - if (ln != null) { - int taint = (int) Math.pow(2, idx); - taintLabelNode(ln, taint,currentSESE.getSeseEffectsSet()); - currentSESE.getSeseEffectsSet().setInVarIdx(idx, td); - - // collects related allocation sites - Iterator referenceeIter = ln - .iteratorToReferencees(); - while (referenceeIter.hasNext()) { - ReferenceEdge referenceEdge = (ReferenceEdge) referenceeIter - .next(); - HeapRegionNode dstHRN = referenceEdge.getDst(); - if (dstHRN.isParameter()) { - - HashSet visitedHRN = new HashSet(); - visitedHRN.add(dstHRN); - setupRelatedAllocSiteAnalysis(og, mc, dstHRN, - visitedHRN); - - } else { -// System.out.println("FLAGGED "+fsen+":"+td); - flagAllocationSite(mc, dstHRN - .getAllocationSite()); - } - } - - } - - idx++; - } - } - - } - break; - - case FKind.FlatSESEExitNode: { - FlatSESEExitNode fsexit = (FlatSESEExitNode) fn; - - if (!fsexit.getFlatEnter().getIsCallerSESEplaceholder()) { - - // clear taint information of live-in variables - Set keySet=og.id2hrn.keySet(); - for (Iterator iterator = keySet.iterator(); iterator.hasNext();) { - Integer hrnID = (Integer) iterator.next(); - HeapRegionNode hrn=og.id2hrn.get(hrnID); - Iterator edgeIter=hrn.iteratorToReferencers(); - while (edgeIter.hasNext()) { - ReferenceEdge refEdge = (ReferenceEdge) edgeIter - .next(); - refEdge.setSESETaintIdentifier(0); - } - } - - FlatSESEEnterNode enterNode = fsexit.getFlatEnter(); - FlatSESEEnterNode parent = enterNode.getParent(); - if (parent != null) { - - SESEEffectsSet set = enterNode.getSeseEffectsSet(); - Hashtable> readTable = set - .getReadTable(); - Hashtable> parentReadTable = parent - .getSeseEffectsSet().getReadTable(); - Set keys = readTable.keySet(); - Iterator keyIter = keys.iterator(); - while (keyIter.hasNext()) { - TempDescriptor td = (TempDescriptor) keyIter.next(); - HashSet effectsSet = readTable.get(td); - HashSet parentEffectsSet = parentReadTable - .get(td); - if (parentEffectsSet == null) { - parentEffectsSet = new HashSet(); - } - - for (Iterator iterator = effectsSet.iterator(); iterator - .hasNext();) { - SESEEffectsKey seseKey = (SESEEffectsKey) iterator - .next(); - parentEffectsSet.add(new SESEEffectsKey(seseKey - .getFieldDescriptor(), seseKey - .getTypeDescriptor(), seseKey.getHRNId(), - seseKey.getHRNUniqueId())); - } - - parentReadTable.put(td, parentEffectsSet); - } - - Hashtable> writeTable = set - .getWriteTable(); - Hashtable> parentWriteTable = parent - .getSeseEffectsSet().getWriteTable(); - keys = writeTable.keySet(); - keyIter = keys.iterator(); - while (keyIter.hasNext()) { - TempDescriptor td = (TempDescriptor) keyIter.next(); - HashSet effectsSet = writeTable.get(td); - HashSet parentEffectsSet = parentWriteTable - .get(td); - if (parentEffectsSet == null) { - parentEffectsSet = new HashSet(); - } - - for (Iterator iterator = effectsSet.iterator(); iterator - .hasNext();) { - SESEEffectsKey seseKey = (SESEEffectsKey) iterator - .next(); - parentEffectsSet.add(new SESEEffectsKey(seseKey - .getFieldDescriptor(), seseKey - .getTypeDescriptor(), seseKey.getHRNId(), - seseKey.getHRNUniqueId())); - } - - parentWriteTable.put(td, parentEffectsSet); - } - - Hashtable> strongUpdateTable = set - .getStrongUpdateTable(); - Hashtable> parentstrongUpdateTable = parent - .getSeseEffectsSet().getStrongUpdateTable(); - keys = strongUpdateTable.keySet(); - keyIter = keys.iterator(); - while (keyIter.hasNext()) { - TempDescriptor td = (TempDescriptor) keyIter.next(); - HashSet effectsSet = strongUpdateTable - .get(td); - HashSet parentEffectsSet = parentstrongUpdateTable - .get(td); - if (parentEffectsSet == null) { - parentEffectsSet = new HashSet(); - } - - for (Iterator iterator = effectsSet.iterator(); iterator - .hasNext();) { - SESEEffectsKey seseKey = (SESEEffectsKey) iterator - .next(); - parentEffectsSet.add(new SESEEffectsKey(seseKey - .getFieldDescriptor(), seseKey - .getTypeDescriptor(), seseKey.getHRNId(), - seseKey.getHRNUniqueId())); - } - - parentstrongUpdateTable.put(td, parentEffectsSet); - } - - } - - } - - } - break; - - case FKind.FlatFieldNode: { - - FlatFieldNode ffn = (FlatFieldNode) fn; - TempDescriptor dst = ffn.getDst(); - TempDescriptor src = ffn.getSrc(); - FieldDescriptor field = ffn.getField(); - - LabelNode srcLN = og.td2ln.get(src); - if(srcLN!=null){ - Iterator edgeIter=srcLN.iteratorToReferencees(); - int taintIdentifier=0; - while (edgeIter.hasNext()) { - ReferenceEdge referenceEdge = (ReferenceEdge) edgeIter - .next(); - HeapRegionNode refHRN=referenceEdge.getDst(); - taintIdentifier=currentSESE.getSeseEffectsSet().getTaint(referenceEdge); -// taintIdentifier=referenceEdge.getSESETaintIdentifier(); - - // figure out which invar has related effects - Hashtable map=currentSESE.getSeseEffectsSet().getMapTempDescToInVarIdx(); - Set keySet=map.keySet(); - for (Iterator iterator = keySet.iterator(); iterator - .hasNext();) { - TempDescriptor inVarTD = (TempDescriptor) iterator - .next(); - int inVarMask=(int) Math.pow(2, map.get(inVarTD).intValue()); - if((inVarMask&taintIdentifier)>0){ - // found related invar, contribute effects - currentSESE.readEffects(inVarTD, field.getSymbol(),src.getType(), refHRN); - } - } - } - - // taint - if(!field.getType().isImmutable()){ - LabelNode dstLN = og.td2ln.get(dst); - edgeIter=dstLN.iteratorToReferencees(); - while (edgeIter.hasNext()) { - ReferenceEdge referenceEdge = (ReferenceEdge) edgeIter - .next(); - currentSESE.getSeseEffectsSet().mapEdgeToTaint(referenceEdge, taintIdentifier); -// referenceEdge.unionSESETaintIdentifier(taintIdentifier); - } - } - } - - - } - break; - - case FKind.FlatOpNode:{ - - FlatOpNode fon=(FlatOpNode)fn; - TempDescriptor dest=fon.getDest(); - TempDescriptor src=fon.getLeft(); - - if(currentSESE.getInVarSet().contains(src)){ - int idx=currentSESE.getSeseEffectsSet().getInVarIdx(src); - if(idx==-1){ - break; - } - - //mark dest's edges for corresponding sese live in-var. - LabelNode srcLN = og.td2ln.get(dest); - if (srcLN != null) { - Iterator refEdgeIter=srcLN.iteratorToReferencees(); - while (refEdgeIter.hasNext()) { - ReferenceEdge edge = refEdgeIter.next(); - int newTaint = (int) Math.pow(2, idx); -// System.out.println("fon="+fon); -// System.out.println(currentSESE+" src:"+src+"->"+"dest:"+dest+" with taint="+newTaint); -// System.out.println("referenceEdge="+edge); - currentSESE.getSeseEffectsSet().mapEdgeToTaint(edge, newTaint); -// System.out.println("after tainting="+edge.getSESETaintIdentifier()); - } - } - } - }break; - - case FKind.FlatElementNode:{ - - FlatElementNode fsen=(FlatElementNode)fn; - TempDescriptor src = fsen.getSrc(); - TempDescriptor dst = fsen.getDst(); - String field="___element_"; - - LabelNode srcLN = og.td2ln.get(src); - int taintIdentifier=0; - if(srcLN!=null){ - Iterator edgeIter=srcLN.iteratorToReferencees(); - while (edgeIter.hasNext()) { - ReferenceEdge referenceEdge = (ReferenceEdge) edgeIter - .next(); - HeapRegionNode dstHRN=referenceEdge.getDst(); - taintIdentifier=currentSESE.getSeseEffectsSet().getTaint(referenceEdge); -// taintIdentifier=referenceEdge.getSESETaintIdentifier(); - - // figure out which invar has related effects - Hashtable map=currentSESE.getSeseEffectsSet().getMapTempDescToInVarIdx(); - Set keySet=map.keySet(); - for (Iterator iterator = keySet.iterator(); iterator - .hasNext();) { - TempDescriptor inVarTD = (TempDescriptor) iterator - .next(); - int inVarMask=(int) Math.pow(2, map.get(inVarTD).intValue()); - if((inVarMask&taintIdentifier)>0){ - // found related invar, contribute effects - currentSESE.readEffects(inVarTD, field,src.getType(), dstHRN); - } - } - - } - } - - // taint - LabelNode dstLN = og.td2ln.get(dst); - if(dstLN!=null){ - Iterator edgeIter=dstLN.iteratorToReferencees(); - while (edgeIter.hasNext()) { - ReferenceEdge referenceEdge = (ReferenceEdge) edgeIter - .next(); - currentSESE.getSeseEffectsSet().mapEdgeToTaint(referenceEdge, taintIdentifier); -// referenceEdge.unionSESETaintIdentifier(taintIdentifier); - } - } - - }break; - - case FKind.FlatSetElementNode: { - - FlatSetElementNode fsen = (FlatSetElementNode) fn; - TempDescriptor dst = fsen.getDst(); - TypeDescriptor tdElement = dst.getType().dereference(); - - String field = "___element_"; - - LabelNode dstLN=og.td2ln.get(dst); - if(dst!=null){ - - Iterator edgeIter=dstLN.iteratorToReferencees(); - while (edgeIter.hasNext()) { - ReferenceEdge referenceEdge = (ReferenceEdge) edgeIter - .next(); - HeapRegionNode dstHRN=referenceEdge.getDst(); - int edgeTaint=currentSESE.getSeseEffectsSet().getTaint(referenceEdge); -// int edgeTaint=referenceEdge.getSESETaintIdentifier(); - - // we can do a strong update here if one of two cases - // holds - boolean strongUpdate=false; - if (field != null && !dst.getType().isImmutable() - && ((dstHRN.getNumReferencers() == 1) || // case 1 - (dstHRN.isSingleObject() && dstLN - .getNumReferencees() == 1) // case 2 - )) { - strongUpdate = true; - } - - - // figure out which invar has related effects - Hashtable map=currentSESE.getSeseEffectsSet().getMapTempDescToInVarIdx(); - Set keySet=map.keySet(); - for (Iterator iterator = keySet.iterator(); iterator - .hasNext();) { - TempDescriptor inVarTD = (TempDescriptor) iterator - .next(); - int inVarMask=(int) Math.pow(2, map.get(inVarTD).intValue()); - if((inVarMask&edgeTaint)>0){ - // found related invar, contribute effects - currentSESE.writeEffects(inVarTD, field, dst.getType(),dstHRN, strongUpdate); - } - } - - - } - - } - - }break; - - case FKind.FlatSetFieldNode: { - - FlatSetFieldNode fsen = (FlatSetFieldNode) fn; - TempDescriptor dst = fsen.getDst(); - FieldDescriptor field = fsen.getField(); - - LabelNode dstLN = og.td2ln.get(dst); - if(dstLN!=null){ - - Iterator edgeIter=dstLN.iteratorToReferencees(); - while (edgeIter.hasNext()) { - ReferenceEdge referenceEdge = (ReferenceEdge) edgeIter - .next(); - HeapRegionNode dstHRN=referenceEdge.getDst(); - int edgeTaint=currentSESE.getSeseEffectsSet().getTaint(referenceEdge); -// int edgeTaint=referenceEdge.getSESETaintIdentifier(); - - // we can do a strong update here if one of two cases - // holds - boolean strongUpdate=false; - if (field != null && !field.getType().isImmutable() - && field != OwnershipAnalysis - .getArrayField(field.getType()) - && ((dstHRN.getNumReferencers() == 1) || // case 1 - (dstHRN.isSingleObject() && dstLN - .getNumReferencees() == 1) // case 2 - )) { - strongUpdate = true; - } - - - // figure out which invar has related effects - Hashtable map = currentSESE - .getSeseEffectsSet().getMapTempDescToInVarIdx(); - Set keySet = map.keySet(); - for (Iterator iterator = keySet.iterator(); iterator - .hasNext();) { - TempDescriptor inVarTD = (TempDescriptor) iterator - .next(); - int inVarMask = (int) Math.pow(2, map.get(inVarTD) - .intValue()); - if ((inVarMask & edgeTaint) > 0) { - // found related invar, contribute effects - currentSESE.writeEffects(inVarTD, - field.getSymbol(), dst.getType(), dstHRN, - strongUpdate); - } - } - - - } - } - } - break; - - case FKind.FlatCall: { - FlatCall fc = (FlatCall) fn; - - MethodContext calleeMC = ownAnalysis.getCalleeMethodContext(mc, fc); - - MethodEffects me = ownAnalysis.getMethodEffectsAnalysis() - .getMethodEffectsByMethodContext(calleeMC); - - OwnershipGraph calleeOG = ownAnalysis - .getOwnvershipGraphByMethodContext(calleeMC); - - - FlatMethod fm = state.getMethodFlat(fc.getMethod()); - ParameterDecomposition decomp = new ParameterDecomposition( - ownAnalysis, fc, fm, calleeMC, calleeOG, og); - - int base=0; - if (((MethodDescriptor) calleeMC.getDescriptor()).isStatic()) { - base = 0; - } else { - base = 1; - } - - for (int i = 0; i < fc.numArgs()+base; i++) { - - TempDescriptor arg ; - Set readSet; - Set writeSet; - Set strongUpdateSet; - - int paramIdx=0; - - boolean isThis=false; - if(i==fc.numArgs()){ - paramIdx=0; - arg = fc.getThis(); - Integer hrnPrimaryID = calleeOG.paramIndex2idPrimary.get(paramIdx); - Integer hrnSecondaryID = calleeOG.paramIndex2idSecondary.get(paramIdx); - readSet = me.getEffects().getReadingSet( - 0); - writeSet = me.getEffects().getWritingSet( - 0); - strongUpdateSet = me.getEffects() - .getStrongUpdateSet(0); - isThis=true; - }else{ - paramIdx=i + base; - arg = fc.getArg(i); - readSet = me.getEffects().getReadingSet( - i + base); - writeSet = me.getEffects().getWritingSet( - i + base); - strongUpdateSet = me.getEffects() - .getStrongUpdateSet(i + base); - } - - LabelNode argLN = og.td2ln.get(arg); - if( argLN!=null){ - Iterator edgeIter=argLN.iteratorToReferencees(); - while (edgeIter.hasNext()) { - ReferenceEdge referenceEdge = (ReferenceEdge) edgeIter - .next(); - HeapRegionNode dstHRN=referenceEdge.getDst(); - int edgeTaint=currentSESE.getSeseEffectsSet().getTaint(referenceEdge); -// int edgeTaint=referenceEdge.getSESETaintIdentifier(); - - // figure out which invar has related effects - Hashtable map = currentSESE - .getSeseEffectsSet().getMapTempDescToInVarIdx(); - Set keySet = map.keySet(); - for (Iterator iterator = keySet.iterator(); iterator - .hasNext();) { - TempDescriptor inVarTD = (TempDescriptor) iterator - .next(); - int inVarMask = (int) Math.pow(2, map.get(inVarTD) - .intValue()); - - if ((inVarMask & edgeTaint) > 0) { - // found related invar, contribute effects - - if (readSet != null) { - Iterator readIter = readSet - .iterator(); - while (readIter.hasNext()) { - EffectsKey key = readIter.next(); - Set hrnSet = getCallerHRNId( - new Integer(paramIdx), calleeOG, - key.getHRNId(), decomp); - Iterator hrnIter = hrnSet - .iterator(); - while (hrnIter.hasNext()) { - Integer hrnID = (Integer) hrnIter - .next(); - - HeapRegionNode refHRN = og.id2hrn - .get(hrnID); - - currentSESE.readEffects(inVarTD, key - .getFieldDescriptor(), key - .getTypeDescriptor(), refHRN); - - } - } - } - - if (writeSet != null) { - Iterator writeIter = writeSet - .iterator(); - while (writeIter.hasNext()) { - EffectsKey key = writeIter.next(); - - Set hrnSet = getCallerHRNId( - new Integer(paramIdx), calleeOG, - key.getHRNId(), decomp); - Iterator hrnIter = hrnSet - .iterator(); - while (hrnIter.hasNext()) { - Integer hrnID = (Integer) hrnIter - .next(); - - HeapRegionNode refHRN = og.id2hrn - .get(hrnID); - - currentSESE.writeEffects(inVarTD, - key.getFieldDescriptor(), key - .getTypeDescriptor(), - refHRN, false); - } - - } - } - - if (strongUpdateSet != null) { - Iterator strongUpdateIter = strongUpdateSet - .iterator(); - while (strongUpdateIter.hasNext()) { - EffectsKey key = strongUpdateIter - .next(); - - Set hrnSet = getCallerHRNId( - new Integer(paramIdx), - calleeOG, key.getHRNId(), - decomp); - Iterator hrnIter = hrnSet - .iterator(); - while (hrnIter.hasNext()) { - Integer hrnID = (Integer) hrnIter - .next(); - - HeapRegionNode refHRN = og.id2hrn - .get(hrnID); - - currentSESE.writeEffects(inVarTD, - key.getFieldDescriptor(), - key.getTypeDescriptor(), - refHRN, true); - } - } - } // end of if (strongUpdateSet != null) - - } // end of if ((inVarMask & edgeTaint) > 0) - } - - } - } - - } - - } - break; - - } - } - - private void flagAllocationSite(MethodContext mc, AllocationSite ac){ - HashSet set=mapMethodContextToLiveInAllocationSiteSet.get(mc); - if(set==null){ - set=new HashSet(); - } - set.add(ac); - mapMethodContextToLiveInAllocationSiteSet.put(mc, set); - } - - private void followReference(HeapRegionNode hrn,HashSet tdSet, HashSet visited, FlatSESEEnterNode currentSESE){ - - Iterator referIter=hrn.iteratorToReferencers(); - // check whether hrn is referenced by TD - while (referIter.hasNext()) { - ReferenceEdge referEdge = (ReferenceEdge) referIter.next(); - if(referEdge.getSrc() instanceof LabelNode){ - LabelNode ln=(LabelNode)referEdge.getSrc(); - if(currentSESE.getInVarSet().contains(ln.getTempDescriptor())){ - tdSet.add(ln.getTempDescriptor()); - } - }else if(referEdge.getSrc() instanceof HeapRegionNode){ - HeapRegionNode nextHRN=(HeapRegionNode)referEdge.getSrc(); - if(!visited.contains(nextHRN)){ - visited.add(nextHRN); - followReference(nextHRN,tdSet,visited,currentSESE); - } - - } - } - - } - - private Set getCallerHRNId(Integer paramIdx, - OwnershipGraph calleeOG, Integer calleeHRNId, - ParameterDecomposition paramDecom) { - - Integer hrnPrimaryID = calleeOG.paramIndex2idPrimary.get(paramIdx); - Integer hrnSecondaryID = calleeOG.paramIndex2idSecondary.get(paramIdx); - - if (calleeHRNId.equals(hrnPrimaryID)) { - // it references to primary param heap region - return paramDecom.getParamObject_hrnIDs(paramIdx); - } else if (calleeHRNId.equals(hrnSecondaryID)) { - // it references to secondary param heap region - return paramDecom.getParamReachable_hrnIDs(paramIdx); - } - - return new HashSet(); - } - - private void taintLabelNode(LabelNode ln, int identifier, SESEEffectsSet effectSet) { - - Iterator edgeIter = ln.iteratorToReferencees(); - while (edgeIter.hasNext()) { - ReferenceEdge edge = edgeIter.next(); - effectSet.mapEdgeToTaint(edge, identifier); - } - - } - - private HashSet getReferenceHeapIDSet(OwnershipGraph og, TempDescriptor td){ - - HashSet returnSet=new HashSet(); - - LabelNode ln=og.td2ln.get(td); - if(ln!=null){ - Iterator edgeIter=ln.iteratorToReferencees(); - while(edgeIter.hasNext()){ - ReferenceEdge edge=edgeIter.next(); - HeapRegionNode hrn=edge.getDst(); - returnSet.add(hrn); - } - } - return returnSet; - } - - - private HashSet getRefEdgeSetReferenceToSameHRN( - OwnershipGraph og, TempDescriptor td) { - - HashSet returnSet = new HashSet(); - - HashSet heapIDs = getReferenceHeapIDSet(og, td); - for (Iterator iterator = heapIDs.iterator(); iterator - .hasNext();) { - HeapRegionNode heapRegionNode = (HeapRegionNode) iterator.next(); - Iterator referenceeIter = heapRegionNode - .iteratorToReferencees(); - while (referenceeIter.hasNext()) { - ReferenceEdge edge = (ReferenceEdge) referenceeIter.next(); - if (edge.getSrc() instanceof HeapRegionNode) { - returnSet.add(edge); - } - } - } - return returnSet; - } - - private HashSet getTempDescSetReferenceToSameHRN( - OwnershipGraph og, TempDescriptor td) { - - HashSet returnSet = new HashSet(); - - HashSet heapIDs = getReferenceHeapIDSet(og, td); - for (Iterator iterator = heapIDs.iterator(); iterator - .hasNext();) { - HeapRegionNode heapRegionNode = (HeapRegionNode) iterator.next(); - Iterator referencerIter = heapRegionNode - .iteratorToReferencers(); - while (referencerIter.hasNext()) { - ReferenceEdge edge = (ReferenceEdge) referencerIter.next(); - if (edge.getSrc() instanceof LabelNode) { - LabelNode ln = (LabelNode) edge.getSrc(); - returnSet.add(ln.getTempDescriptor()); - } - } - } - return returnSet; - } - - private void DFSVisit( MethodDescriptor md, - LinkedList sorted, - HashSet discovered, JavaCallGraph javaCallGraph) { - - discovered.add(md); - - Iterator itr = javaCallGraph.getCallerSet(md).iterator(); - while (itr.hasNext()) { - MethodDescriptor mdCaller = (MethodDescriptor) itr.next(); - - if (!discovered.contains(mdCaller)) { - DFSVisit(mdCaller, sorted, discovered, javaCallGraph); - } - } - - sorted.addFirst(md); - } - - - private LinkedList topologicalSort(Set set, - JavaCallGraph javaCallGraph) { - HashSet discovered = new HashSet(); - LinkedList sorted = new LinkedList(); - - Iterator itr = set.iterator(); - while (itr.hasNext()) { - MethodDescriptor md = itr.next(); - - if (!discovered.contains(md)) { - DFSVisit(md, sorted, discovered, javaCallGraph); - } - } - - return sorted; - } - - private void calculateCovering(ConflictGraph conflictGraph){ - uniqueLockSetId=0; // reset lock counter for every new conflict graph - HashSet fineToCover = new HashSet(); - HashSet coarseToCover = new HashSet(); - HashSet lockSet=new HashSet(); - - HashSet tempCover = conflictGraph.getEdgeSet(); - for (Iterator iterator = tempCover.iterator(); iterator.hasNext();) { - ConflictEdge conflictEdge = (ConflictEdge) iterator.next(); - if(conflictEdge.getType()==ConflictEdge.FINE_GRAIN_EDGE){ - fineToCover.add(conflictEdge); - }else if(conflictEdge.getType()==ConflictEdge.COARSE_GRAIN_EDGE){ - coarseToCover.add(conflictEdge); - } - } - - HashSet toCover=new HashSet(); - toCover.addAll(fineToCover); - toCover.addAll(coarseToCover); - - while (!toCover.isEmpty()) { - - SESELock seseLock = new SESELock(); - seseLock.setID(uniqueLockSetId++); - - boolean changed; - - do{ // fine-grained edge - - changed=false; - - for (Iterator iterator = fineToCover.iterator(); iterator - .hasNext();) { - - int type; - ConflictEdge edge = (ConflictEdge) iterator.next(); - if(seseLock.getConflictNodeSet().size()==0){ - //initial setup - if(seseLock.isWriteNode(edge.getVertexU())){ - // mark as fine_write - if(edge.getVertexU() instanceof StallSiteNode){ - type=ConflictNode.PARENT_WRITE; - }else{ - type=ConflictNode.FINE_WRITE; - } - seseLock.addConflictNode(edge.getVertexU(), type); - }else{ - // mark as fine_read - if(edge.getVertexU() instanceof StallSiteNode){ - type=ConflictNode.PARENT_READ; - }else{ - type=ConflictNode.FINE_READ; - } - seseLock.addConflictNode(edge.getVertexU(), type); - } - if(edge.getVertexV()!=edge.getVertexU()){ - if(seseLock.isWriteNode(edge.getVertexV())){ - // mark as fine_write - if(edge.getVertexV() instanceof StallSiteNode){ - type=ConflictNode.PARENT_WRITE; - }else{ - type=ConflictNode.FINE_WRITE; - } - seseLock.addConflictNode(edge.getVertexV(), type); - }else{ - // mark as fine_read - if(edge.getVertexV() instanceof StallSiteNode){ - type=ConflictNode.PARENT_READ; - }else{ - type=ConflictNode.FINE_READ; - } - seseLock.addConflictNode(edge.getVertexV(), type); - } - } - changed=true; - seseLock.addConflictEdge(edge); - fineToCover.remove(edge); - break;// exit iterator loop - }// end of initial setup - - ConflictNode newNode; - if((newNode=seseLock.getNewNodeConnectedWithGroup(edge))!=null){ - // new node has a fine-grained edge to all current node - // If there is a coarse grained edge where need a fine edge, it's okay to add the node - // but the edge must remain uncovered. - - changed=true; - - if(seseLock.isWriteNode(newNode)){ - if(newNode instanceof StallSiteNode){ - type=ConflictNode.PARENT_WRITE; - }else{ - type=ConflictNode.FINE_WRITE; - } - seseLock.setNodeType(newNode,type); - }else{ - if(newNode instanceof StallSiteNode){ - type=ConflictNode.PARENT_READ; - }else{ - type=ConflictNode.FINE_READ; - } - seseLock.setNodeType(newNode,type); - } - - seseLock.addEdge(edge); - HashSet edgeSet=newNode.getEdgeSet(); - for (Iterator iterator2 = edgeSet.iterator(); iterator2 - .hasNext();) { - ConflictEdge conflictEdge = (ConflictEdge) iterator2 - .next(); - - - // mark all fine edges between new node and nodes in the group as covered - if(!conflictEdge.getVertexU().equals(newNode)){ - if(seseLock.containsConflictNode(conflictEdge.getVertexU())){ - changed=true; - seseLock.addConflictEdge(conflictEdge); - fineToCover.remove(conflictEdge); - } - }else if(!conflictEdge.getVertexV().equals(newNode)){ - if(seseLock.containsConflictNode(conflictEdge.getVertexV())){ - changed=true; - seseLock.addConflictEdge(conflictEdge); - fineToCover.remove(conflictEdge); - } - } - - } - - break;// exit iterator loop - } - } - - }while(changed); - do{ // coarse - changed=false; - int type; - for (Iterator iterator = coarseToCover.iterator(); iterator - .hasNext();) { - - ConflictEdge edge = (ConflictEdge) iterator.next(); - - if(seseLock.getConflictNodeSet().size()==0){ - //initial setup - if(seseLock.hasSelfCoarseEdge(edge.getVertexU())){ - // node has a coarse-grained edge with itself - if(!(edge.getVertexU() instanceof StallSiteNode)){ - // and it is not parent - type=ConflictNode.SCC; - }else{ - type=ConflictNode.PARENT_COARSE; - } - seseLock.addConflictNode(edge.getVertexU(), type); - }else{ - if(edge.getVertexU() instanceof StallSiteNode){ - type=ConflictNode.PARENT_COARSE; - }else{ - type=ConflictNode.COARSE; - } - seseLock.addConflictNode(edge.getVertexU(), type); - } - if(seseLock.hasSelfCoarseEdge(edge.getVertexV())){ - // node has a coarse-grained edge with itself - if(!(edge.getVertexV() instanceof StallSiteNode)){ - // and it is not parent - type=ConflictNode.SCC; - }else{ - type=ConflictNode.PARENT_COARSE; - } - seseLock.addConflictNode(edge.getVertexV(), type); - }else{ - if(edge.getVertexV() instanceof StallSiteNode){ - type=ConflictNode.PARENT_COARSE; - }else{ - type=ConflictNode.COARSE; - } - seseLock.addConflictNode(edge.getVertexV(), type); - } - changed=true; - coarseToCover.remove(edge); - seseLock.addConflictEdge(edge); - break;// exit iterator loop - }// end of initial setup - - - ConflictNode newNode; - if((newNode=seseLock.getNewNodeConnectedWithGroup(edge))!=null){ - // new node has a coarse-grained edge to all fine-read, fine-write, parent - changed=true; - - if(seseLock.hasSelfCoarseEdge(newNode)){ - //SCC - if(newNode instanceof StallSiteNode){ - type=ConflictNode.PARENT_COARSE; - }else{ - type=ConflictNode.SCC; - } - seseLock.setNodeType(newNode, type); - }else{ - if(newNode instanceof StallSiteNode){ - type=ConflictNode.PARENT_COARSE; - }else{ - type=ConflictNode.COARSE; - } - seseLock.setNodeType(newNode, type); - } - - seseLock.addEdge(edge); - HashSet edgeSet=newNode.getEdgeSet(); - for (Iterator iterator2 = edgeSet.iterator(); iterator2 - .hasNext();) { - ConflictEdge conflictEdge = (ConflictEdge) iterator2 - .next(); - // mark all coarse edges between new node and nodes in the group as covered - if(!conflictEdge.getVertexU().equals(newNode)){ - if(seseLock.containsConflictNode(conflictEdge.getVertexU())){ - changed=true; - seseLock.addConflictEdge(conflictEdge); - coarseToCover.remove(conflictEdge); - } - }else if(!conflictEdge.getVertexV().equals(newNode)){ - if(seseLock.containsConflictNode(conflictEdge.getVertexV())){ - changed=true; - seseLock.addConflictEdge(conflictEdge); - coarseToCover.remove(conflictEdge); - } - } - - } - break;// exit iterator loop - } - - } - - }while(changed); - lockSet.add(seseLock); - - toCover.clear(); - toCover.addAll(fineToCover); - toCover.addAll(coarseToCover); - - } - - conflictGraphLockMap.put(conflictGraph, lockSet); - } - - private void synthesizeLocks(){ - Set> graphEntrySet=conflictGraphResults.entrySet(); - for (Iterator iterator = graphEntrySet.iterator(); iterator.hasNext();) { - Entry graphEntry = (Entry) iterator - .next(); - FlatNode sese=graphEntry.getKey(); - ConflictGraph conflictGraph=graphEntry.getValue(); - calculateCovering(conflictGraph); - } - } - - private void makeConflictGraph() { - Iterator methItr = ownAnalysis.descriptorsToAnalyze - .iterator(); - while (methItr.hasNext()) { - Descriptor d = methItr.next(); - FlatMethod fm = state.getMethodFlat(d); - - HashSet mcSet = ownAnalysisForSESEConflicts - .getAllMethodContextSetByDescriptor(fm.getMethod()); - Iterator mcIter = mcSet.iterator(); - - while (mcIter.hasNext()) { - MethodContext mc = mcIter.next(); - OwnershipGraph og=ownAnalysisForSESEConflicts.getOwnvershipGraphByMethodContext(mc); - - Set flatNodesToVisit = new HashSet(); - flatNodesToVisit.add(fm); - - Set visited = new HashSet(); - - SESESummary summary = new SESESummary(null, fm); - seseSummaryMap.put(fm, summary); - - Hashtable invarMap=new Hashtable(); - - while (!flatNodesToVisit.isEmpty()) { - Iterator fnItr = flatNodesToVisit.iterator(); - FlatNode fn = fnItr.next(); - - flatNodesToVisit.remove(fn); - visited.add(fn); - - // Adding Stall Node of current program statement - ParentChildConflictsMap currentConflictsMap = conflictsResults - .get(fn); - - Hashtable stallMap = currentConflictsMap - .getStallMap(); - - Set> entrySet = stallMap - .entrySet(); - - SESESummary seseSummary = seseSummaryMap.get(fn); - - ConflictGraph conflictGraph = null; - conflictGraph = conflictGraphResults.get(seseSummary - .getCurrentSESE()); - - if (conflictGraph == null) { - conflictGraph = new ConflictGraph(og); - } - for (Iterator> iterator2 = entrySet - .iterator(); iterator2.hasNext();) { - Entry entry = iterator2 - .next(); - TempDescriptor td = entry.getKey(); - StallSite stallSite = entry.getValue(); - - // reachability set - og = ownAnalysisForSESEConflicts - .getOwnvershipGraphByMethodContext(mc); - Set reachabilitySet = calculateReachabilitySet(og, - td); - conflictGraph.addStallNode(td, fm, stallSite, - reachabilitySet); - - } - - if (conflictGraph.id2cn.size() > 0) { - conflictGraphResults.put(seseSummary.getCurrentSESE(), - conflictGraph); - } - - conflictGraph_nodeAction(mc, fm, fn,invarMap); - - for (int i = 0; i < fn.numNext(); i++) { - FlatNode nn = fn.getNext(i); - if (!visited.contains(nn)) { - flatNodesToVisit.add(nn); - } - } - } // end of while(flatNodesToVisit) - - } // end of while(mcIter) - - } - - // decide fine-grain edge or coarse-grain edge among all vertexes by pair-wise comparison - Enumeration keyEnum1=conflictGraphResults.keys(); - while (keyEnum1.hasMoreElements()) { - FlatNode flatNode = (FlatNode) keyEnum1.nextElement(); - ConflictGraph conflictGraph=conflictGraphResults.get(flatNode); - conflictGraph.analyzeConflicts(); - conflictGraphResults.put(flatNode, conflictGraph); - } - - } - - private Set calculateReachabilitySet(OwnershipGraph og, - TempDescriptor tempDescriptor) { - // reachability set - Set reachabilitySet = new HashSet(); - LabelNode ln = og.td2ln.get(tempDescriptor); - if(ln!=null){ - Iterator refEdgeIter = ln.iteratorToReferencees(); - while (refEdgeIter.hasNext()) { - ReferenceEdge referenceEdge = (ReferenceEdge) refEdgeIter.next(); - - ReachabilitySet set = referenceEdge.getBeta(); - Iterator ttsIter = set.iterator(); - while (ttsIter.hasNext()) { - TokenTupleSet tokenTupleSet = (TokenTupleSet) ttsIter.next(); - - HashSet newTokenTupleSet = new HashSet(); - // reachabilitySet.add(tokenTupleSet); - - Iterator iter = tokenTupleSet.iterator(); - while (iter.hasNext()) { - TokenTuple tt = (TokenTuple) iter.next(); - int token = tt.getToken(); - String uniqueID = og.id2hrn.get(new Integer(token)) - .getGloballyUniqueIdentifier(); - GloballyUniqueTokenTuple gtt = new GloballyUniqueTokenTuple( - uniqueID, tt); - newTokenTupleSet.add(gtt); - } - - reachabilitySet.add(newTokenTupleSet); - } - } - } - - return reachabilitySet; - } - - private ReachabilitySet packupStates(OwnershipGraph og, HeapRegionNode hrn) { - - ReachabilitySet betaSet = new ReachabilitySet().makeCanonical(); - - Iterator itrEdge = hrn.iteratorToReferencers(); - while (itrEdge.hasNext()) { - ReferenceEdge edge = itrEdge.next(); - betaSet = betaSet.union(edge.getBeta()); - } - - return betaSet; - - } - - private ReachabilitySet packupStates(OwnershipGraph og, AllocationSite as) { - - ReachabilitySet betaSet = new ReachabilitySet().makeCanonical(); - assert as!=null; - HeapRegionNode hrnSummary = og.id2hrn.get(as.getSummary()); - if(hrnSummary!=null){ - Iterator itrEdge = hrnSummary.iteratorToReferencers(); - while (itrEdge.hasNext()) { - ReferenceEdge edge = itrEdge.next(); - betaSet = betaSet.union(edge.getBeta()); - } - } - - // check for other nodes - for (int i = 0; i < as.getAllocationDepth(); ++i) { - - HeapRegionNode hrnIthOldest = og.id2hrn.get(as.getIthOldest(i)); -// betaSet = new ReachabilitySet().makeCanonical(); -// itrEdge = hrnIthOldest.iteratorToReferencees(); - Iterator itrEdge = hrnIthOldest.iteratorToReferencers(); - while (itrEdge.hasNext()) { - ReferenceEdge edge = itrEdge.next(); - betaSet = betaSet.union(edge.getBeta()); - } - } - - Iterator ttSetIter = betaSet.iterator(); - while (ttSetIter.hasNext()) { - TokenTupleSet tokenTupleSet = (TokenTupleSet) ttSetIter.next(); - Iterator iter = tokenTupleSet.iterator(); - while (iter.hasNext()) { - TokenTuple tt = (TokenTuple) iter.next(); - int token = tt.getToken(); - String uniqueID = og.id2hrn.get(new Integer(token)) - .getGloballyUniqueIdentifier(); - GloballyUniqueTokenTuple gtt = new GloballyUniqueTokenTuple( - uniqueID, tt); - } - } - return betaSet; - } - - private void conflictGraph_nodeAction(MethodContext mc, FlatMethod fm, - FlatNode fn,Hashtable invarMap) { - - switch (fn.kind()) { - - case FKind.FlatSESEEnterNode: { - - FlatSESEEnterNode fsen = (FlatSESEEnterNode) fn; - OwnershipGraph og = ownAnalysisForSESEConflicts - .getOwnvershipGraphByMethodContext(mc); - - if (!fsen.getIsCallerSESEplaceholder()) { - Collection invar_set = fsen.getInVarSet(); - - SESESummary seseSummary=seseSummaryMap.get(fsen); - ConflictGraph conflictGraph=null; - conflictGraph=conflictGraphResults.get(seseSummary.getCurrentParent()); - - if(conflictGraph==null){ - conflictGraph = new ConflictGraph(og); - } - - - for (Iterator iterator = invar_set.iterator(); iterator - .hasNext();) { - TempDescriptor tempDescriptor = (TempDescriptor) iterator - .next(); - - if(!tempDescriptor.getType().isArray() && tempDescriptor.getType().isImmutable()){ - continue; - } - - // effects set - SESEEffectsSet seseEffectsSet = fsen.getSeseEffectsSet(); - Set readEffectsSet = seseEffectsSet - .getReadingSet(tempDescriptor); - - if (readEffectsSet != null) { - for (Iterator iterator2 = readEffectsSet.iterator(); iterator2 - .hasNext();) { - SESEEffectsKey seseEffectsKey = (SESEEffectsKey) iterator2 - .next(); - String uniqueID = seseEffectsKey.getHRNUniqueId(); - HeapRegionNode node = og.gid2hrn.get(uniqueID); - if(node.isParameter()){ - seseEffectsKey.setRSet(packupStates(og,node)); - }else{ - AllocationSite as = node.getAllocationSite(); - seseEffectsKey.setRSet(packupStates(og,as)); - } - } - } - - if (readEffectsSet != null) { - for (Iterator iterator2 = readEffectsSet.iterator(); iterator2 - .hasNext();) { - SESEEffectsKey seseEffectsKey = (SESEEffectsKey) iterator2 - .next(); - } - } - Set writeEffectsSet = seseEffectsSet - .getWritingSet(tempDescriptor); - - if (writeEffectsSet != null) { - for (Iterator iterator2 = writeEffectsSet.iterator(); iterator2 - .hasNext();) { - SESEEffectsKey seseEffectsKey = (SESEEffectsKey) iterator2 - .next(); - String uniqueID = seseEffectsKey.getHRNUniqueId(); - HeapRegionNode node = og.gid2hrn.get(uniqueID); - - if(node.isParameter()){ - seseEffectsKey.setRSet(packupStates(og,node)); - }else{ - AllocationSite as = node.getAllocationSite(); - seseEffectsKey.setRSet(packupStates(og,as)); - } - } - } - - Set strongUpdateSet = seseEffectsSet.getStrongUpdateSet(tempDescriptor); - - Set reachabilitySet = calculateReachabilitySet(og, - tempDescriptor); - - // add new live-in node - - OwnershipGraph lastOG = ownAnalysis - .getOwnvershipGraphByMethodContext(mc); - LabelNode ln = lastOG.td2ln.get(tempDescriptor); - - - Set hrnSet = new HashSet(); - Iterator refIter = ln - .iteratorToReferencees(); - while (refIter.hasNext()) { - ReferenceEdge referenceEdge = (ReferenceEdge) refIter - .next(); - // - SESEEffectsSet seseEffects=fsen.getSeseEffectsSet(); - int taintIdentifier=fsen.getSeseEffectsSet().getTaint(referenceEdge); - int invarIdx=fsen.getSeseEffectsSet().getInVarIdx(tempDescriptor); - int inVarMask=(int) Math.pow(2,invarIdx); - if((inVarMask&taintIdentifier)>0){ - // find tainted edge, add heap root to live-in node - hrnSet.add(referenceEdge.getDst()); - } - // - } - - conflictGraph.addLiveInNode(tempDescriptor, hrnSet, fsen, - readEffectsSet, writeEffectsSet, strongUpdateSet, reachabilitySet); - } - - - if(conflictGraph.id2cn.size()>0){ - conflictGraphResults.put(seseSummary.getCurrentParent(),conflictGraph); - } - - } - - } - - break; - - } - - } - - private void seseConflictsForward(JavaCallGraph javaCallGraph) { - - Set methodCallSet = javaCallGraph.getAllMethods(typeUtil.getMain()); - - // topologically sort java call chain so that leaf calls are ordered - // first - LinkedList sortedMethodCalls = topologicalSort( - methodCallSet, javaCallGraph); - - for (Iterator iterator = sortedMethodCalls.iterator(); iterator - .hasNext();) { - - MethodDescriptor md = (MethodDescriptor) iterator.next(); - - FlatMethod fm = state.getMethodFlat(md); - - HashSet mcSet = ownAnalysis - .getAllMethodContextSetByDescriptor(md); - Iterator mcIter = mcSet.iterator(); - - currentMethodSummary = new MethodSummary(); - preeffectsSet = new HashSet(); - - // iterates over all possible method context - while (mcIter.hasNext()) { - MethodContext mc = mcIter.next(); - - LinkedList flatNodesToVisit=new LinkedList(); - flatNodesToVisit.add(fm); - - SESESummary summary = new SESESummary(null, fm); - seseSummaryMap.put(fm, summary); - - Hashtable invarMap=new Hashtable(); - - while (!flatNodesToVisit.isEmpty()) { - FlatNode fn = (FlatNode) flatNodesToVisit.iterator().next(); - flatNodesToVisit.remove(fn); - ParentChildConflictsMap prevResult = conflictsResults - .get(fn); - - // merge sets from control flow - Boolean prevSESE=null; - ParentChildConflictsMap currentConflictsMap = new ParentChildConflictsMap(); - for (int i = 0; i < fn.numPrev(); i++) { - FlatNode prevFlatNode = fn.getPrev(i); - ParentChildConflictsMap incoming = conflictsResults - .get(prevFlatNode); - if (incoming != null) { - currentConflictsMap.merge(incoming); - } - - if(prevFlatNode instanceof FlatCondBranch){ - prevSESE=isAfterChildSESEIndicatorMap.get(prevFlatNode); - } - } - SESESummary currentSummary = seseSummaryMap.get(fn); - //if (currentSummary == null) { - if(!(fn instanceof FlatMethod)){ - FlatNode current = null; - FlatNode currentParent = null; - // calculate sese summary info from previous flat nodes - - for (int i = 0; i < fn.numPrev(); i++) { - FlatNode prevFlatNode = fn.getPrev(i); - SESESummary prevSummary = seseSummaryMap - .get(prevFlatNode); - if (prevSummary != null) { - if (prevFlatNode instanceof FlatSESEExitNode - && !((FlatSESEExitNode) prevFlatNode) - .getFlatEnter() - .getIsCallerSESEplaceholder()) { - current = prevSummary.getCurrentParent(); - SESESummary temp = seseSummaryMap - .get(current); - currentParent = temp.getCurrentParent(); - } else { - current = prevSummary.getCurrentSESE(); - currentParent = prevSummary - .getCurrentParent(); - } - - break; - } - } - - currentSummary = new SESESummary(currentParent, current); - seseSummaryMap.put(fn, currentSummary); - } - - if(prevSESE!=null){ - if(fn instanceof FlatSESEEnterNode){ - isAfterChildSESEIndicatorMap.put(currentSummary.getCurrentSESE(), currentConflictsMap.isAfterSESE()); - }else{ - isAfterChildSESEIndicatorMap.put(currentSummary.getCurrentSESE(), prevSESE); - } - } - - Boolean b=isAfterChildSESEIndicatorMap.get(currentSummary.getCurrentSESE());; - if(b==null){ - currentConflictsMap.setIsAfterSESE(false); - }else{ - currentConflictsMap.setIsAfterSESE(b.booleanValue()); - } - - FlatNode tempP=currentSummary.getCurrentParent(); - FlatNode tempS=currentSummary.getCurrentSESE(); - - conflicts_nodeAction(mc, fn, callGraph, preeffectsSet, - currentConflictsMap, currentSummary,invarMap); - - - // if we have a new result, schedule forward nodes for - // analysis - if (!currentConflictsMap.equals(prevResult)) { - seseSummaryMap.put(fn, currentSummary); - conflictsResults.put(fn, currentConflictsMap); - for (int i = 0; i < fn.numNext(); i++) { - FlatNode nn = fn.getNext(i); - flatNodesToVisit.addFirst(nn); - } - } - - } - - } - - } - - } - - - private void conflicts_nodeAction(MethodContext mc, FlatNode fn, - CallGraph callGraph, HashSet preeffectsSet, - ParentChildConflictsMap currentConflictsMap, - SESESummary currentSummary, - Hashtable invarMap) { - - OwnershipGraph og = ownAnalysis.getOwnvershipGraphByMethodContext(mc); - - currentConflictsMap.clearStallMap(); - - switch (fn.kind()) { - - case FKind.FlatSESEEnterNode: { - - FlatSESEEnterNode fsen = (FlatSESEEnterNode) fn; - - if (!fsen.getIsCallerSESEplaceholder()) { - FlatNode parentNode = currentSummary.getCurrentSESE(); - currentSummary.setCurrentParent(parentNode); - currentSummary.setCurrentSESE(fsen); -// seseSummaryMap.put(fsen, currentSummary); - } - - if (!fsen.getIsCallerSESEplaceholder()) { - currentMethodSummary.increaseChildSESECount(); - } - if (currentMethodSummary.getChildSESECount() == 1) { - // need to store pre-effects - currentMethodSummary.getEffectsSet().addAll(preeffectsSet); - for (Iterator iterator = currentMethodSummary.getEffectsSet() - .iterator(); iterator.hasNext();) { - PreEffectsKey preEffectsKey = (PreEffectsKey) iterator - .next(); - } - preeffectsSet.clear(); - } - } - break; - - case FKind.FlatSESEExitNode: { - - FlatSESEExitNode fsen = (FlatSESEExitNode) fn; - - if (!fsen.getFlatEnter().getIsCallerSESEplaceholder()) { - // all object variables are inaccessible. - isAfterChildSESEIndicatorMap.put(currentSummary - .getCurrentParent(), new Boolean(true)); - } -// currentConflictsMap = new ParentChildConflictsMap(); - currentConflictsMap.clear(); - - } - break; - - case FKind.FlatCondBranch: { - boolean isAfterChildSESE = false; - FlatNode current = currentSummary.getCurrentSESE(); - Boolean isAfter = isAfterChildSESEIndicatorMap.get(current); - if (isAfter != null && isAfter.booleanValue()) { - isAfterChildSESE = true; - } - isAfterChildSESEIndicatorMap.put(fn, new Boolean(isAfterChildSESE)); - } - break; - - case FKind.FlatNew: { - - FlatNew fnew = (FlatNew) fn; - - boolean isAfterChildSESE = false; - FlatNode current = currentSummary.getCurrentSESE(); - Boolean isAfter = isAfterChildSESEIndicatorMap.get(current); - if (isAfter != null && isAfter.booleanValue()) { - isAfterChildSESE = true; - } - - if (isAfterChildSESE) { - TempDescriptor dst = fnew.getDst(); - currentConflictsMap.addAccessibleVar(dst); - } - - } - break; - - case FKind.FlatElementNode:{ - - - FlatElementNode fen = (FlatElementNode) fn; - TempDescriptor src=fen.getSrc(); - - boolean isAfterChildSESE = false; - FlatNode current = currentSummary.getCurrentSESE(); - Boolean isAfter = isAfterChildSESEIndicatorMap.get(current); - if (isAfter != null && isAfter.booleanValue()) { - isAfterChildSESE = true; - } - - if(isAfterChildSESE){ - - if (!currentConflictsMap.isAccessible(src)) { - if(invarMap.containsKey(src)){ - currentConflictsMap.addStallSite(src, new HashSet(), - new StallTag(fn),invarMap.get(src)); - }else{ - currentConflictsMap.addStallSite(src, new HashSet(), - new StallTag(fn),null); - } - } - currentConflictsMap.addAccessibleVar(src); - - // contribute read effect on source's stall site - currentConflictsMap.contributeEffect(src, "", "", - StallSite.READ_EFFECT); - - } - - if (currentMethodSummary.getChildSESECount() == 0) { - // analyze preeffects - preEffectAnalysis(og, src, null, PreEffectsKey.READ_EFFECT); - } - - - } break; - - case FKind.FlatFieldNode: { - - FlatFieldNode ffn = (FlatFieldNode) fn; - TempDescriptor dst = ffn.getDst(); - TempDescriptor src = ffn.getSrc(); - FieldDescriptor field = ffn.getField(); - - boolean isAfterChildSESE = false; - FlatNode current = currentSummary.getCurrentSESE(); - Boolean isAfter = isAfterChildSESEIndicatorMap.get(current); - if (isAfter != null && isAfter.booleanValue()) { - isAfterChildSESE = true; - } - - if (isAfterChildSESE) { - - if (!currentConflictsMap.isAccessible(src)) { - HashSet refHRN = getReferenceHeapIDSet( - og, src); - currentConflictsMap.addStallSite(src, refHRN, - new StallTag(fn),null); - - // flag stall site for disjoint analysis - for (Iterator iterator2 = refHRN.iterator(); iterator2 - .hasNext();) { - HeapRegionNode hrn = (HeapRegionNode) iterator2 - .next(); - if (hrn.isParameter()) { - // if stall site is paramter heap region, need - // to decompose into caller's - HashSet visitedHRN = new HashSet(); - visitedHRN.add(hrn); - setupRelatedAllocSiteAnalysis(og, mc, hrn, - visitedHRN); - } else { -// System.out.println("FLAGGED "+mc+":"+ffn); - flagAllocationSite(mc, hrn.getAllocationSite()); - } - } - - } - currentConflictsMap.addAccessibleVar(src); - - // contribute read effect on source's stall site - currentConflictsMap.contributeEffect(src, field - .getType().getSafeSymbol(), field.getSymbol(), - StallSite.READ_EFFECT); - - if(field.getType().isImmutable()){ - currentConflictsMap.addAccessibleVar(dst); - } - - } - - if (currentMethodSummary.getChildSESECount() == 0) { - // analyze preeffects - preEffectAnalysis(og, src, field, PreEffectsKey.READ_EFFECT); - } - - } - break; - - case FKind.FlatSetElementNode:{ - - FlatSetElementNode fsen=(FlatSetElementNode)fn; - TempDescriptor dst = fsen.getDst(); - TempDescriptor src = fsen.getSrc(); - - boolean isAfterChildSESE = false; - FlatNode current = currentSummary.getCurrentSESE(); - Boolean isAfter = isAfterChildSESEIndicatorMap.get(current); - if (isAfter != null && isAfter.booleanValue()) { - isAfterChildSESE = true; - } - - if (isAfterChildSESE) { - - if (!currentConflictsMap.isAccessible(src)) { - HashSet refHRN = getReferenceHeapIDSet(og, - src); - currentConflictsMap.addStallSite(src, refHRN , new StallTag( - fn),null); - } - currentConflictsMap.addAccessibleVar(src); - - if (!currentConflictsMap.isAccessible(dst)) { - if(invarMap.containsKey(dst)){ - currentConflictsMap.addStallSite(dst, new HashSet(), - new StallTag(fn),invarMap.get(dst)); - }else{ - currentConflictsMap.addStallSite(dst, new HashSet(), - new StallTag(fn),null); - } - } - currentConflictsMap.addAccessibleVar(dst); - // contribute write effect on destination's stall site - currentConflictsMap.contributeEffect(dst, "","", - StallSite.WRITE_EFFECT); - - } - - if (currentMethodSummary.getChildSESECount() == 0) { - // analyze preeffects - preEffectAnalysis(og, dst, null, PreEffectsKey.WRITE_EFFECT); - } - - } break; - - case FKind.FlatSetFieldNode: { - - FlatSetFieldNode fsen = (FlatSetFieldNode) fn; - TempDescriptor dst = fsen.getDst(); - FieldDescriptor field = fsen.getField(); - TempDescriptor src = fsen.getSrc(); - - boolean isAfterChildSESE = false; - FlatNode current = currentSummary.getCurrentSESE(); - Boolean isAfter = isAfterChildSESEIndicatorMap.get(current); - if (isAfter != null && isAfter.booleanValue()) { - isAfterChildSESE = true; - } - - if (isAfterChildSESE) { - - if (!currentConflictsMap.isAccessible(src)) { - HashSet refHRN = getReferenceHeapIDSet(og, - src); - currentConflictsMap.addStallSite(src, refHRN, new StallTag( - fn),null); - - // flag stall site for disjoint analysis - for (Iterator iterator2 = refHRN.iterator(); iterator2 - .hasNext();) { - HeapRegionNode hrn = (HeapRegionNode) iterator2.next(); - - if (hrn.isParameter()) { - // if stall site is paramter heap region, need - // to decompose into caller's - HashSet visitedHRN = new HashSet(); - visitedHRN.add(hrn); - setupRelatedAllocSiteAnalysis(og, mc, hrn, - visitedHRN); - } else { - flagAllocationSite(mc, hrn.getAllocationSite()); - } - - } - - } - currentConflictsMap.addAccessibleVar(src); - - - if (!currentConflictsMap.isAccessible(dst)) { - HashSet refHRN = getReferenceHeapIDSet( - og, dst); - currentConflictsMap.addStallSite(dst, refHRN, - new StallTag(fn),null); - - // flag stall site for disjoint analysis - for (Iterator iterator2 = refHRN.iterator(); iterator2 - .hasNext();) { - HeapRegionNode hrn = (HeapRegionNode) iterator2 - .next(); - if (hrn.isParameter()) { - // if stall site is paramter heap region, need - // to decompose into caller's - HashSet visitedHRN = new HashSet(); - visitedHRN.add(hrn); - setupRelatedAllocSiteAnalysis(og, mc, hrn, - visitedHRN); - } else { - flagAllocationSite(mc, hrn.getAllocationSite()); - } - } - } - - currentConflictsMap.addAccessibleVar(dst); - // contribute write effect on destination's stall site - currentConflictsMap.contributeEffect(dst, field - .getType().getSafeSymbol(), field.getSymbol(), - StallSite.WRITE_EFFECT); - - - // TODO need to create edge mapping for newly created edge - HashSet edges = getRefEdgeSetReferenceToSameHRN( - og, dst); - - StallSite ss = currentConflictsMap.getStallMap().get(dst); - if (ss != null) { - for (Iterator iterator = edges.iterator(); iterator - .hasNext();) { - ReferenceEdge referenceEdge = (ReferenceEdge) iterator - .next(); - if (!(referenceEdge.getSrc() instanceof LabelNode)) { - currentConflictsMap.addStallEdge(referenceEdge, - new StallTag(fn)); - } - } - } - } - - if (currentMethodSummary.getChildSESECount() == 0) { - // analyze preeffects - preEffectAnalysis(og, dst, field, PreEffectsKey.WRITE_EFFECT); - } - - } - break; - - case FKind.FlatOpNode: { - - FlatOpNode fon = (FlatOpNode) fn; - - boolean isAfterChildSESE = false; - FlatNode current = currentSummary.getCurrentSESE(); - Boolean isAfter = isAfterChildSESEIndicatorMap.get(current); - - - if( fon.getOp().getOp() ==Operation.ASSIGN){ - invarMap.put(fon.getDest(), fon.getLeft()); - } - - if (isAfter != null && isAfter.booleanValue()) { - isAfterChildSESE = true; - } - - if (isAfterChildSESE) { - - // destination variable gets the status of source. - - if (fon.getOp().getOp() == Operation.ASSIGN) { - - TempDescriptor dst = fon.getDest(); - TempDescriptor src = fon.getLeft(); - - Integer sourceStatus = currentConflictsMap - .getAccessibleMap().get(src); - if (sourceStatus == null) { - sourceStatus = ParentChildConflictsMap.INACCESSIBLE; - } - - HashSet dstTempSet = getTempDescSetReferenceToSameHRN( - og, dst); - - for (Iterator iterator = dstTempSet - .iterator(); iterator.hasNext();) { - TempDescriptor possibleDst = iterator.next(); - - if (sourceStatus - .equals(ParentChildConflictsMap.ACCESSIBLE)) { - currentConflictsMap.addAccessibleVar(possibleDst); - } else { - currentConflictsMap.addInaccessibleVar(possibleDst); - - } - - } - } - - } - } - break; - - case FKind.FlatCall: { - - FlatCall fc = (FlatCall) fn; - - boolean isAfterChildSESE = false; - FlatNode current = currentSummary.getCurrentSESE(); - Boolean isAfter = isAfterChildSESEIndicatorMap.get(current); - if (isAfter != null && isAfter.booleanValue()) { - isAfterChildSESE = true; - } - - int base = 0; - if (!fc.getMethod().isStatic()) { - base = 1; - } - - FlatMethod calleeFM = state.getMethodFlat(fc.getMethod()); - - // retrieve callee's method summary - MethodSummary calleeMethodSummary = methodSummaryResults - .get(calleeFM); - - if (calleeMethodSummary != null - && calleeMethodSummary.getChildSESECount() > 0) { - - // when parameter variable is accessible, - // use callee's preeffects to figure out about how it affects - // caller's stall site - - for (int i = 0; i < fc.numArgs(); i++) { - TempDescriptor paramTemp = fc.getArg(i); - - if (isAfterChildSESE) { - if (currentConflictsMap.isAccessible(paramTemp) - && currentConflictsMap.hasStallSite(paramTemp)) { - // preeffect contribute its effect to caller's stall - // site - - int offset = 0; - if (!fc.getMethod().isStatic()) { - offset = 1; - } - - HashSet preeffectSet = calleeMethodSummary - .getEffectsSetByParamIdx(i + offset); - - for (Iterator iterator = preeffectSet.iterator(); iterator - .hasNext();) { - PreEffectsKey preEffectsKey = (PreEffectsKey) iterator - .next(); - currentConflictsMap.contributeEffect(paramTemp, - preEffectsKey.getType(), preEffectsKey - .getField(), preEffectsKey - .getEffectType()); - } - } - } - // in other cases, child SESE has not been discovered, - // assumes that all variables are accessible - - } - - // If callee has at least one child sese, all parent object - // is going to be inaccessible. - // currentConflictsMap = new ParentChildConflictsMap(); - currentConflictsMap.makeAllInaccessible(); - isAfterChildSESEIndicatorMap.put(currentSummary - .getCurrentSESE(), new Boolean(true)); - - TempDescriptor returnTemp = fc.getReturnTemp(); - - if (calleeMethodSummary.getReturnValueAccessibility().equals( - MethodSummary.ACCESSIBLE)) { - // when return value is accessible, associate with its - // stall site - currentConflictsMap.addAccessibleVar(returnTemp); - - StallSite returnStallSite = calleeMethodSummary - .getReturnStallSite().copy(); - // handling parameter regions - HashSet stallParamIdx = returnStallSite - .getCallerParamIdxSet(); - for (Iterator iterator = stallParamIdx.iterator(); iterator - .hasNext();) { - Integer idx = (Integer) iterator.next(); - - int paramIdx = idx.intValue() - base; - TempDescriptor paramTD = fc.getArg(paramIdx); - - // TODO: resolve callee's parameter heap regions by - // following call chain - - } - - // flag stall site's allocation sites for disjointness - // analysis - HashSet hrnSet = returnStallSite - .getHRNSet(); - for (Iterator iterator = hrnSet.iterator(); iterator - .hasNext();) { - HeapRegionNode hrn = (HeapRegionNode) iterator.next(); - if (hrn.isParameter()) { - // if stall site is paramter heap region, need to - // decompose into caller's - HashSet visitedHRN = new HashSet(); - visitedHRN.add(hrn); - setupRelatedAllocSiteAnalysis(og, mc, hrn, - visitedHRN); - } else { - flagAllocationSite(mc, hrn.getAllocationSite()); - } - } - - currentConflictsMap.addStallSite(returnTemp, - returnStallSite); - - } else if (calleeMethodSummary.getReturnValueAccessibility() - .equals(MethodSummary.INACCESSIBLE)) { - // when return value is inaccessible - currentConflictsMap.addInaccessibleVar(returnTemp); - } - - // TODO: need to handle edge mappings from callee - Set stallParamIdx = calleeMethodSummary - .getStallParamIdxSet(); - for (Iterator iterator = stallParamIdx.iterator(); iterator - .hasNext();) { - Integer paramIdx = (Integer) iterator.next(); - HashSet stallTagSet = calleeMethodSummary - .getStallTagByParamIdx(paramIdx); - - int argIdx = paramIdx.intValue() - base; - TempDescriptor argTD = fc.getArg(argIdx); - - putStallTagOnReferenceEdges(og, argTD, stallTagSet, - currentConflictsMap); - } - } - - } - break; - - /* - * do we need this case? case FKind.FlatLiteralNode: { - * - * if (currentConflictsMap.isAfterChildSESE()) { FlatLiteralNode fln = - * (FlatLiteralNode) fn; TempDescriptor dst = fln.getDst(); - * currentConflictsMap.addAccessibleVar(dst); } - * - * } break; - */ - - case FKind.FlatReturnNode: { - - FlatReturnNode frn = (FlatReturnNode) fn; - TempDescriptor returnTD = frn.getReturnTemp(); - - boolean isAfterChildSESE = false; - FlatNode current = currentSummary.getCurrentSESE(); - Boolean isAfter = isAfterChildSESEIndicatorMap.get(current); - if (isAfter != null && isAfter.booleanValue()) { - isAfterChildSESE = true; - } - - if (returnTD != null) { - if (!isAfterChildSESE) { - // in this case, all variables are accessible. There are no - // child SESEs. - } else { - if (currentConflictsMap.isAccessible(returnTD)) { - - currentMethodSummary - .setReturnValueAccessibility(MethodSummary.ACCESSIBLE); - StallSite returnStallSite = currentConflictsMap - .getStallMap().get(returnTD); - - HashSet stallSiteHRNSet = returnStallSite - .getHRNSet(); - for (Iterator iterator = stallSiteHRNSet.iterator(); iterator - .hasNext();) { - HeapRegionNode stallSiteHRN = (HeapRegionNode) iterator - .next(); - Set paramSet = og.idPrimary2paramIndexSet - .get(stallSiteHRN.getID()); - returnStallSite.addCallerParamIdxSet(paramSet); - paramSet = og.idSecondary2paramIndexSet - .get(stallSiteHRN.getID()); - returnStallSite.addCallerParamIdxSet(paramSet); - } - - currentMethodSummary - .setReturnStallSite(returnStallSite); - - } else { - currentMethodSummary - .setReturnValueAccessibility(MethodSummary.INACCESSIBLE); - } - } - } - } - break; - - case FKind.FlatExit: { - - // store method summary when it has at least one child SESE - if (currentMethodSummary.getChildSESECount() > 0) { - // current flat method - FlatMethod fm = state.getMethodFlat(mc.getDescriptor()); - Set stallTempSet = currentConflictsMap - .getStallMap().keySet(); - for (Iterator iterator = stallTempSet.iterator(); iterator - .hasNext();) { - TempDescriptor stallTD = (TempDescriptor) iterator.next(); - StallSite stallSite = currentConflictsMap.getStallMap() - .get(stallTD); - - HashSet stallSiteHRNSet = stallSite - .getHRNSet(); - for (Iterator iterator2 = stallSiteHRNSet.iterator(); iterator2 - .hasNext();) { - HeapRegionNode stallSiteHRN = (HeapRegionNode) iterator2 - .next(); - - if (stallSiteHRN.isParameter()) { - - Set paramSet = og.idPrimary2paramIndexSet - .get(stallSiteHRN.getID()); - currentMethodSummary.addStallParamIdxSet(paramSet, - stallSite.getStallTagSet()); - - paramSet = og.idSecondary2paramIndexSet - .get(stallSiteHRN.getID()); - currentMethodSummary.addStallParamIdxSet(paramSet, - stallSite.getStallTagSet()); - } - - } - - } - methodSummaryResults.put(fm, currentMethodSummary); - } - } - break; - - } - -// seseSummaryMap.put(fn, currentSummary); - - } - - private void putStallTagOnReferenceEdges(OwnershipGraph og, - TempDescriptor argTD, HashSet stallTagSet, - ParentChildConflictsMap currentConflictsMap) { - - LabelNode ln=og.td2ln.get(argTD); - if(ln!=null){ - - Iterator refrenceeIter=ln.iteratorToReferencees(); - while (refrenceeIter.hasNext()) { - ReferenceEdge refEdge = (ReferenceEdge) refrenceeIter.next(); - HeapRegionNode stallHRN=refEdge.getDst(); - - Iterator referencerIter=stallHRN.iteratorToReferencers(); - while (referencerIter.hasNext()) { - ReferenceEdge referencer = (ReferenceEdge) referencerIter - .next(); - for (Iterator iterator = stallTagSet.iterator(); iterator - .hasNext();) { - StallTag stallTag = (StallTag) iterator.next(); - currentConflictsMap.addStallEdge(referencer, stallTag); - } - } - } - } - } - - private void preEffectAnalysis(OwnershipGraph og, TempDescriptor td, - FieldDescriptor field, Integer effectType) { - - // analyze preeffects - HashSet hrnSet = getReferenceHeapIDSet(og, td); - for (Iterator iterator = hrnSet.iterator(); iterator.hasNext();) { - HeapRegionNode hrn = (HeapRegionNode) iterator.next(); - if (hrn.isParameter()) { - // effects on param heap region - - Set paramSet = og.idPrimary2paramIndexSet.get(hrn - .getID()); - - if (paramSet != null) { - Iterator paramIter = paramSet.iterator(); - while (paramIter.hasNext()) { - Integer paramID = paramIter.next(); - PreEffectsKey effectKey=null; - if(field!=null){ - effectKey = new PreEffectsKey(paramID, - field.getSymbol(), field.getType() - .getSafeSymbol(), effectType); - }else{ - effectKey = new PreEffectsKey(paramID, - "", "", effectType); - } - preeffectsSet.add(effectKey); - } - } - - // check weather this heap region is parameter - // reachable... - - paramSet = og.idSecondary2paramIndexSet.get(hrn.getID()); - if (paramSet != null) { - Iterator paramIter = paramSet.iterator(); - - while (paramIter.hasNext()) { - Integer paramID = paramIter.next(); - PreEffectsKey effectKey=null; - if(field!=null){ - effectKey = new PreEffectsKey(paramID, - field.getSymbol(), field.getType() - .getSafeSymbol(), effectType); - }else{ - effectKey = new PreEffectsKey(paramID, - "", "", effectType); - } - preeffectsSet.add(effectKey); - } - } - - } - } - } - - private void codePlansForward( FlatMethod fm ) { - - // start from flat method top, visit every node in - // method exactly once - Set flatNodesToVisit = new HashSet(); - flatNodesToVisit.add( fm ); - - Set visited = new HashSet(); - - while( !flatNodesToVisit.isEmpty() ) { - Iterator fnItr = flatNodesToVisit.iterator(); - FlatNode fn = fnItr.next(); - - flatNodesToVisit.remove( fn ); - visited.add( fn ); - - Stack seseStack = seseStacks.get( fn ); - assert seseStack != null; - - // use incoming results as "dot statement" or just - // before the current statement - VarSrcTokTable dotSTtable = new VarSrcTokTable(); - for( int i = 0; i < fn.numPrev(); i++ ) { - FlatNode nn = fn.getPrev( i ); - dotSTtable.merge( variableResults.get( nn ) ); - } - - // find dt-st notAvailableSet also - Set dotSTnotAvailSet = new HashSet(); - for( int i = 0; i < fn.numPrev(); i++ ) { - FlatNode nn = fn.getPrev( i ); - Set notAvailIn = notAvailableResults.get( nn ); - if( notAvailIn != null ) { - dotSTnotAvailSet.addAll( notAvailIn ); - } - } - - Set dotSTlive = livenessRootView.get( fn ); - - if( !seseStack.empty() ) { - codePlans_nodeActions( fn, - dotSTlive, - dotSTtable, - dotSTnotAvailSet, - seseStack.peek() - ); - } - - for( int i = 0; i < fn.numNext(); i++ ) { - FlatNode nn = fn.getNext( i ); - - if( !visited.contains( nn ) ) { - flatNodesToVisit.add( nn ); - } - } - } - } - - private void codePlans_nodeActions( FlatNode fn, - Set liveSetIn, - VarSrcTokTable vstTableIn, - Set notAvailSetIn, - FlatSESEEnterNode currentSESE ) { - - CodePlan plan = new CodePlan( currentSESE); - - switch( fn.kind() ) { - - case FKind.FlatSESEEnterNode: { - FlatSESEEnterNode fsen = (FlatSESEEnterNode) fn; - assert fsen.equals( currentSESE ); - - // track the source types of the in-var set so generated - // code at this SESE issue can compute the number of - // dependencies properly - Iterator inVarItr = fsen.getInVarSet().iterator(); - while( inVarItr.hasNext() ) { - TempDescriptor inVar = inVarItr.next(); - - // when we get to an SESE enter node we change the - // currentSESE variable of this analysis to the - // child that is declared by the enter node, so - // in order to classify in-vars correctly, pass - // the parent SESE in--at other FlatNode types just - // use the currentSESE - VSTWrapper vstIfStatic = new VSTWrapper(); - Integer srcType = - vstTableIn.getRefVarSrcType( inVar, - fsen.getParent(), - vstIfStatic - ); - - // the current SESE needs a local space to track the dynamic - // variable and the child needs space in its SESE record - if( srcType.equals( VarSrcTokTable.SrcType_DYNAMIC ) ) { - fsen.addDynamicInVar( inVar ); - fsen.getParent().addDynamicVar( inVar ); - - } else if( srcType.equals( VarSrcTokTable.SrcType_STATIC ) ) { - fsen.addStaticInVar( inVar ); - VariableSourceToken vst = vstIfStatic.vst; - fsen.putStaticInVar2src( inVar, vst ); - fsen.addStaticInVarSrc( new SESEandAgePair( vst.getSESE(), - vst.getAge() - ) - ); - } else { - assert srcType.equals( VarSrcTokTable.SrcType_READY ); - fsen.addReadyInVar( inVar ); - } - } - - } break; - - case FKind.FlatSESEExitNode: { - FlatSESEExitNode fsexn = (FlatSESEExitNode) fn; - } break; - - case FKind.FlatOpNode: { - FlatOpNode fon = (FlatOpNode) fn; - - if( fon.getOp().getOp() == Operation.ASSIGN ) { - TempDescriptor lhs = fon.getDest(); - TempDescriptor rhs = fon.getLeft(); - - // if this is an op node, don't stall, copy - // source and delay until we need to use value - - // ask whether lhs and rhs sources are dynamic, static, etc. - VSTWrapper vstIfStatic = new VSTWrapper(); - Integer lhsSrcType - = vstTableIn.getRefVarSrcType( lhs, - currentSESE, - vstIfStatic - ); - Integer rhsSrcType - = vstTableIn.getRefVarSrcType( rhs, - currentSESE, - vstIfStatic - ); - - 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 ); - currentSESE.addDynamicVar( lhs ); - currentSESE.addDynamicVar( rhs ); - - } else if( lhsSrcType.equals( VarSrcTokTable.SrcType_DYNAMIC ) ) { - // otherwise, if the lhs is dynamic, but the rhs is not, we - // need to update the variable's dynamic source as "current SESE" - plan.addDynAssign( lhs ); - } - - // only break if this is an ASSIGN op node, - // otherwise fall through to default case - break; - } - } - - // note that FlatOpNode's that aren't ASSIGN - // fall through to this default case - default: { - - // a node with no live set has nothing to stall for - if( liveSetIn == null ) { - break; - } - - TempDescriptor[] readarray = fn.readsTemps(); - for( int i = 0; i < readarray.length; i++ ) { - TempDescriptor readtmp = readarray[i]; - - // ignore temps that are definitely available - // when considering to stall on it - if( !notAvailSetIn.contains( readtmp ) ) { - continue; - } - - // check the source type of this variable - VSTWrapper vstIfStatic = new VSTWrapper(); - Integer srcType - = vstTableIn.getRefVarSrcType( readtmp, - currentSESE, - vstIfStatic - ); - - if( srcType.equals( VarSrcTokTable.SrcType_DYNAMIC ) ) { - // 1) It is not clear statically where this variable will - // 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 ); - currentSESE.addDynamicVar( readtmp ); - - } else if( srcType.equals( VarSrcTokTable.SrcType_STATIC ) ) { - // 2) Single token/age pair: Stall for token/age pair, and copy - // all live variables with same token/age pair at the same - // time. This is the same stuff that the notavaialable analysis - // marks as now available. - VariableSourceToken vst = vstIfStatic.vst; - - Iterator availItr = - vstTableIn.get( vst.getSESE(), vst.getAge() ).iterator(); - - while( availItr.hasNext() ) { - VariableSourceToken vstAlsoAvail = availItr.next(); - - // only grab additional stuff that is live - Set copySet = new HashSet(); - - Iterator refVarItr = vstAlsoAvail.getRefVars().iterator(); - while( refVarItr.hasNext() ) { - TempDescriptor refVar = refVarItr.next(); - if( liveSetIn.contains( refVar ) ) { - copySet.add( refVar ); - } - } - - if( !copySet.isEmpty() ) { - plan.addStall2CopySet( vstAlsoAvail, copySet ); - } - } - - } else { - // the other case for srcs is READY, so do nothing - } - - // assert that everything being stalled for is in the - // "not available" set coming into this flat node and - // that every VST identified is in the possible "stall set" - // that represents VST's from children SESE's - - } - } break; - - } // end switch - - - // identify sese-age pairs that are statically useful - // and should have an associated SESE variable in code - // JUST GET ALL SESE/AGE NAMES FOR NOW, PRUNE LATER, - // AND ALWAYS GIVE NAMES TO PARENTS - Set staticSet = vstTableIn.get(); - Iterator vstItr = staticSet.iterator(); - while( vstItr.hasNext() ) { - VariableSourceToken vst = vstItr.next(); - - // placeholder source tokens are useful results, but - // the placeholder static name is never needed - if( vst.getSESE().getIsCallerSESEplaceholder() ) { - continue; - } - - FlatSESEEnterNode sese = currentSESE; - while( sese != null ) { - sese.addNeededStaticName( - new SESEandAgePair( vst.getSESE(), vst.getAge() ) - ); - sese.mustTrackAtLeastAge( vst.getAge() ); - - sese = sese.getParent(); - } - } - - - codePlans.put( fn, plan ); - - - // 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 - VarSrcTokTable thisVstTable = variableResults.get( fn ); - for( int i = 0; i < fn.numNext(); i++ ) { - FlatNode nn = fn.getNext( i ); - VarSrcTokTable nextVstTable = variableResults.get( nn ); - Set nextLiveIn = livenessRootView.get( nn ); - - // the table can be null if it is one of the few IR nodes - // completely outside of the root SESE scope - if( nextVstTable != null && nextLiveIn != null ) { - - Hashtable readyOrStatic2dynamicSet = - thisVstTable.getReadyOrStatic2DynamicSet( nextVstTable, - nextLiveIn, - currentSESE - ); - - if( !readyOrStatic2dynamicSet.isEmpty() ) { - - // either add these results to partial fixed-point result - // or make a new one if we haven't made any here yet - FlatEdge fe = new FlatEdge( fn, nn ); - FlatWriteDynamicVarNode fwdvn = wdvNodesToSpliceIn.get( fe ); - - if( fwdvn == null ) { - fwdvn = new FlatWriteDynamicVarNode( fn, - nn, - readyOrStatic2dynamicSet, - currentSESE - ); - wdvNodesToSpliceIn.put( fe, fwdvn ); - } else { - fwdvn.addMoreVar2Src( readyOrStatic2dynamicSet ); - } - } - } - } - } - - - public void writeReports( String timeReport ) throws java.io.IOException { - - BufferedWriter bw = new BufferedWriter( new FileWriter( "mlpReport_summary.txt" ) ); - bw.write( "MLP Analysis Results\n\n" ); - bw.write( timeReport+"\n\n" ); - printSESEHierarchy( bw ); - bw.write( "\n" ); - printSESEInfo( bw ); - bw.close(); - - Iterator methItr = ownAnalysis.descriptorsToAnalyze.iterator(); - while( methItr.hasNext() ) { - MethodDescriptor md = (MethodDescriptor) methItr.next(); - FlatMethod fm = state.getMethodFlat( md ); - bw = new BufferedWriter( new FileWriter( "mlpReport_"+ - md.getClassMethodName()+ - md.getSafeMethodDescriptor()+ - ".txt" ) ); - bw.write( "MLP Results for "+md+"\n-------------------\n"); - - FlatSESEEnterNode implicitSESE = (FlatSESEEnterNode) fm.getNext(0); - if( !implicitSESE.getIsCallerSESEplaceholder() && - implicitSESE != mainSESE - ) { - System.out.println( implicitSESE+" is not implicit?!" ); - System.exit( -1 ); - } - bw.write( "Dynamic vars to manage:\n "+implicitSESE.getDynamicVarSet()); - - bw.write( "\n\nLive-In, Root View\n------------------\n" +fm.printMethod( livenessRootView ) ); - 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\nCode Plans\n----------\n" +fm.printMethod( codePlans ) ); - bw.write("\n\nSESE Effects\n----------------------\n"+printSESEEffects()); - bw.close(); - } - } - - private String printSESEEffects() { - - StringWriter writer = new StringWriter(); - - Iterator keyIter = allSESEs.iterator(); - - while (keyIter.hasNext()) { - FlatSESEEnterNode seseEnter = keyIter.next(); - String result = seseEnter.getSeseEffectsSet().printSet(); - if (result.length() > 0) { - writer.write("\nSESE " + seseEnter + "\n"); - writer.write(result); - } - } - keyIter = rootSESEs.iterator(); - while (keyIter.hasNext()) { - FlatSESEEnterNode seseEnter = keyIter.next(); - if (seseEnter.getIsCallerSESEplaceholder()) { - if (!seseEnter.getChildren().isEmpty()) { - String result = seseEnter.getSeseEffectsSet().printSet(); - if (result.length() > 0) { - writer.write("\nSESE " + seseEnter + "\n"); - writer.write(result); - } - } - } - } - - return writer.toString(); - - } - - private void printSESEHierarchy( BufferedWriter bw ) throws java.io.IOException { - bw.write( "SESE Hierarchy\n--------------\n" ); - Iterator rootItr = rootSESEs.iterator(); - while( rootItr.hasNext() ) { - FlatSESEEnterNode root = rootItr.next(); - if( root.getIsCallerSESEplaceholder() ) { - if( !root.getChildren().isEmpty() ) { - printSESEHierarchyTree( bw, root, 0 ); - } - } else { - printSESEHierarchyTree( bw, root, 0 ); - } - } - } - - private void printSESEHierarchyTree( BufferedWriter bw, - FlatSESEEnterNode fsen, - int depth - ) throws java.io.IOException { - for( int i = 0; i < depth; ++i ) { - bw.write( " " ); - } - bw.write( "- "+fsen.getPrettyIdentifier()+"\n" ); - - Iterator childItr = fsen.getChildren().iterator(); - while( childItr.hasNext() ) { - FlatSESEEnterNode fsenChild = childItr.next(); - printSESEHierarchyTree( bw, fsenChild, depth + 1 ); - } - } - - - private void printSESEInfo( BufferedWriter bw ) throws java.io.IOException { - bw.write("\nSESE info\n-------------\n" ); - Iterator rootItr = rootSESEs.iterator(); - while( rootItr.hasNext() ) { - FlatSESEEnterNode root = rootItr.next(); - if( root.getIsCallerSESEplaceholder() ) { - if( !root.getChildren().isEmpty() ) { - printSESEInfoTree( bw, root ); - } - } else { - printSESEInfoTree( bw, root ); - } - } - } - - private void printSESEInfoTree( BufferedWriter bw, - FlatSESEEnterNode fsen - ) throws java.io.IOException { - - if( !fsen.getIsCallerSESEplaceholder() ) { - bw.write( "SESE "+fsen.getPrettyIdentifier()+" {\n" ); - - bw.write( " in-set: "+fsen.getInVarSet()+"\n" ); - Iterator tItr = fsen.getInVarSet().iterator(); - while( tItr.hasNext() ) { - TempDescriptor inVar = tItr.next(); - if( fsen.getReadyInVarSet().contains( inVar ) ) { - bw.write( " (ready) "+inVar+"\n" ); - } - if( fsen.getStaticInVarSet().contains( inVar ) ) { - bw.write( " (static) "+inVar+" from "+ - fsen.getStaticInVarSrc( inVar )+"\n" ); - } - if( fsen.getDynamicInVarSet().contains( inVar ) ) { - bw.write( " (dynamic)"+inVar+"\n" ); - } - } - - bw.write( " Dynamic vars to manage: "+fsen.getDynamicVarSet()+"\n"); - - bw.write( " out-set: "+fsen.getOutVarSet()+"\n" ); - bw.write( "}\n" ); - } - - Iterator childItr = fsen.getChildren().iterator(); - while( childItr.hasNext() ) { - FlatSESEEnterNode fsenChild = childItr.next(); - printSESEInfoTree( bw, fsenChild ); - } - } - - public Hashtable getConflictGraphResults(){ - return conflictGraphResults; - } - - public Hashtable < FlatNode, ParentChildConflictsMap > getConflictsResults(){ - return conflictsResults; - } - - public Hashtable getSeseSummaryMap(){ - return seseSummaryMap; - } - - public Hashtable> getConflictGraphLockMap(){ - return conflictGraphLockMap; - } - -} diff --git a/Robust/src/Analysis/MLP/MemoryStall.java b/Robust/src/Analysis/MLP/MemoryStall.java deleted file mode 100644 index 82be65af..00000000 --- a/Robust/src/Analysis/MLP/MemoryStall.java +++ /dev/null @@ -1,162 +0,0 @@ -package Analysis.MLP; - -public class MemoryStall { - JavaCallGraph callgraph; - State state; - TypeUtil typeutil; - SESETree sesetree; - - public MemoryStall(State state, TypeUtil typeutil, JavaCallGraph callgraph, SESETree sesetree) { - this.state=state; - this.typeutil=typeutil; - this.callgraph=callgraph; - this.sesetree=sesetree; - } - - private boolean isOnlyLeaf(MethodDescriptor md) { - Set seseset=sesetree.getSESE(md); - for(Iterator seseit=seseset.iterator();seseit.hasNext();) { - SESENode sese=seseit.next(); - if (!sese.isLeaf()) - return false; - } - return true; - } - - HashSet toanalyze=new HashSet(); - - public void doAnalysis() { - MethodDescriptor main=typeutil.getMain(); - toanalyze.addAll(callGraph.getAllMethods(main)); - - while(!toanalyze.isEmpty()) { - MethodDescriptor md=(MethodDescriptor)toanalyze.iterator().next(); - toanalyze.remove(md); - if (isOnlyLeaf(md)) - continue; - analyzeMethod(md); - } - } - - private void analyzeMethod(MethodDescriptor md) { - FlatMethod fm=state.getMethodFlat(md); - Hashtable> nodetosese=sesetree.analyzeMethod(md); - HashSet tovisit=new HashSet(); - tovisit.add(fm); - Hashtable> dirtytemps=new Hashtable>(); - - while(!tovisit.isEmpty()) { - FlatNode fn=tovisit.iterator().next(); - tovisit.remove(fn); - HashSet newset=new HashSet(); - for(int i=0;i(); - break; - } - case FKind.FlatElementNode: { - FlatElementNode fen=(FlatElementNode) fn; - newset.remove(fen.getSrc()); - newset.remove(fen.getDst()); - break; - } - case FKind.FlatFieldNode: { - FlatFieldNode ffn=(FlatFieldNode) fn; - newset.remove(ffn.getSrc()); - newset.remove(ffn.getDst()); - break; - } - case FKind.FlatSetFieldNode: { - FlatSetFieldNode fsfn=(FlatSetFieldNode) fn; - newset.remove(fsfn.getSrc()); - newset.remove(fsfn.getDst()); - break; - } - case FKind.FlatSetElementNode: { - FlatSetElementNode fsen=(FlatSetElementNode) fn; - newset.remove(fsen.getSrc()); - newset.remove(fsen.getDst()); - break; - } - case FKind.FlatLiteralNode: { - FlatLiteralNode fln=(FlatLiteralNode) fn; - newset.remove(fln.getDst()); - break; - } - case FKind.FlatMethodNode: { - - break; - } - case FKind.FlatOpNode: { - FlatOpNode fon=(FlatOpNode)fn; - if (fon.getOp().getOp()==Operation.ASSIGN) { - if (newset.contains(getLeft())) - newset.add(getDest()); - else if (!newset.contains(getLeft())) - newset.remove(getDest()); - break; - } - } - case FKind.FlatCastNode: { - FlatCastNode fcn=(FlatOpNode)fn; - if (newset.contains(getSrc())) - newset.add(getDst()); - else if (!newset.contains(getSrc())) - newset.remove(getDst()); - break; - } - case FKind.FlatNew: { - FlatNew fnew=(FlatNew) fn; - newset.remove(fnew.getDst()); - break; - } - case FKind.FlatReturnNode: { - FlatReturnNode frn=(FlatReturnNode) fn; - - break; - } - case FKind.FlatCall: { - FlatCall fc=(FlatCall)fn; - - break; - } - } - - } - - - - } - - private MethodDescriptor getBase(MethodDescriptor md) { - ClassDescriptor cd=md.getClassDesc(); - while (cd.getSuperDesc()!=null) { - cd=cd.getSuperDesc(); - Set methodset=cd.getMethodTable().getSet(md.getSymbol()); - MethodDescriptor mdtemp=null; - for(Iterator mdit=methodset.iterator();mdit.hasNext();) { - MethodDescriptor mdsuper=(MethodDescriptor) mdit.next(); - if (mdsuper.matches(md)) { - mdtemp=mdsuper; - break; - } - } - if (mdtemp!=null) - md=mdtemp; - else - return md; - } - return md; - } - - class MethodContext { - boolean[] parameters; - boolean dirtytemp; - } - -} \ No newline at end of file diff --git a/Robust/src/Analysis/MLP/MethodSummary.java b/Robust/src/Analysis/MLP/MethodSummary.java deleted file mode 100644 index 0a743b1e..00000000 --- a/Robust/src/Analysis/MLP/MethodSummary.java +++ /dev/null @@ -1,160 +0,0 @@ -package Analysis.MLP; - -import java.util.HashSet; -import java.util.Hashtable; -import java.util.Iterator; -import java.util.Set; - -public class MethodSummary { - - public static final Integer VOID=new Integer(0); - public static final Integer ACCESSIBLE = new Integer(1); - public static final Integer INACCESSIBLE=new Integer(2); - - private int childSESECount; - private HashSet effectsSet; - private Integer accessibility; - private StallSite returnStallSite; - - private Hashtable> mapParamIndexToRelatedStallTag; - - public MethodSummary() { - effectsSet = new HashSet(); - accessibility = MethodSummary.VOID; - childSESECount = 0; - returnStallSite=null; - mapParamIndexToRelatedStallTag=new Hashtable>(); - } - - public void addStallParamIdxSet(Set paramIdxSet, HashSet stallTagSet){ - - if(paramIdxSet!=null){ - for (Iterator iterator = paramIdxSet.iterator(); iterator.hasNext();) { - Integer paramIdx = (Integer) iterator.next(); - mapParamIndexToRelatedStallTag.put(paramIdx, stallTagSet); - } - } - } - - public HashSet getStallTagByParamIdx(Integer paramIdx){ - return mapParamIndexToRelatedStallTag.get(paramIdx); - } - - - public Set getStallParamIdxSet(){ - return mapParamIndexToRelatedStallTag.keySet(); - } - - public void setReturnStallSite(StallSite ss){ - returnStallSite=ss; - } - - public StallSite getReturnStallSite(){ - return returnStallSite; - } - - public void increaseChildSESECount() { - childSESECount++; - } - - public int getChildSESECount() { - return childSESECount; - } - - public Integer getReturnValueAccessibility() { - return accessibility; - } - - public void setReturnValueAccessibility(Integer accessibility) { - this.accessibility = accessibility; - } - - public HashSet getEffectsSet() { - return effectsSet; - } - - @Override - public String toString() { - return "MethodSummary [accessibility=" + accessibility - + ", childSESECount=" + childSESECount + ", effectsSet=" - + effectsSet + "]"; - } - - public HashSet getEffectsSetByParamIdx(int paramIdx){ - - HashSet returnSet=new HashSet(); - - for (Iterator iterator = effectsSet.iterator(); iterator.hasNext();) { - PreEffectsKey preEffectsKey = (PreEffectsKey) iterator.next(); - if(preEffectsKey.getParamIndex().equals(new Integer(paramIdx))){ - returnSet.add(preEffectsKey); - } - } - - return returnSet; - } - -} - -class PreEffectsKey { - - public static final Integer READ_EFFECT = new Integer(1); - public static final Integer WRITE_EFFECT = new Integer(2); - - private String type; - private String field; - private Integer effectType; - private Integer paramIndex; - - public PreEffectsKey(Integer paramIndex, String field, String type, - Integer effectType) { - this.paramIndex = paramIndex; - this.field = field; - this.type = type; - this.effectType = effectType; - } - - public String getType() { - return type; - } - - public String getField() { - return field; - } - - public Integer getEffectType() { - return effectType; - } - - public Integer getParamIndex() { - return paramIndex; - } - - public String toString() { - return "PreEffectsKey [effectType=" + effectType + ", field=" + field - + ", paramIndex=" + paramIndex + ", type=" + type + "]"; - } - - public boolean equals(Object o) { - - if (o == null) { - return false; - } - - if (!(o instanceof PreEffectsKey)) { - return false; - } - - PreEffectsKey in = (PreEffectsKey) o; - - if (paramIndex.equals(in.getParamIndex()) - && field.equals(in.getField()) && type.equals(in.getType()) - && effectType.equals(in.getEffectType())) { - return true; - } else { - return false; - } - - } - -} diff --git a/Robust/src/Analysis/MLP/ParentChildConflictsMap.java b/Robust/src/Analysis/MLP/ParentChildConflictsMap.java deleted file mode 100644 index ff102088..00000000 --- a/Robust/src/Analysis/MLP/ParentChildConflictsMap.java +++ /dev/null @@ -1,293 +0,0 @@ -package Analysis.MLP; - -import java.util.Enumeration; -import java.util.HashSet; -import java.util.Hashtable; -import java.util.Iterator; -import java.util.Set; - -import Analysis.OwnershipAnalysis.AllocationSite; -import Analysis.OwnershipAnalysis.HeapRegionNode; -import Analysis.OwnershipAnalysis.ReferenceEdge; -import Analysis.OwnershipAnalysis.TokenTupleSet; -import IR.Flat.TempDescriptor; - -public class ParentChildConflictsMap { - - public static final Integer ACCESSIBLE = new Integer(1); - public static final Integer INACCESSIBLE = new Integer(2); - - private Hashtable accessibleMap; - private Hashtable stallMap; - private Hashtable < ReferenceEdge, HashSet > stallEdgeMap; - private boolean isAfterSESE; - - public ParentChildConflictsMap() { - - accessibleMap = new Hashtable(); - stallMap = new Hashtable(); - stallEdgeMap= new Hashtable < ReferenceEdge, HashSet >(); - isAfterSESE=false; - } - - public void setIsAfterSESE(boolean after){ - this.isAfterSESE=after; - } - - public boolean isAfterSESE(){ - return isAfterSESE; - } - - public void clear(){ - accessibleMap.clear(); - stallMap.clear(); - stallEdgeMap.clear(); - } - - public void clearStallMap(){ - stallMap.clear(); - } - - public void makeAllInaccessible(){ - - Set keySet=accessibleMap.keySet(); - for (Iterator iterator = keySet.iterator(); iterator.hasNext();) { - TempDescriptor key = (TempDescriptor) iterator.next(); - accessibleMap.put(key, INACCESSIBLE); - } - - } - - public Hashtable < ReferenceEdge, HashSet > getStallEdgeMap(){ - return stallEdgeMap; - } - - public void addStallEdge(ReferenceEdge edge, StallTag sTag){ - - HashSet tagSet=stallEdgeMap.get(edge); - if(tagSet==null){ - tagSet=new HashSet(); - } - tagSet.add(sTag); - stallEdgeMap.put(edge, tagSet); - } - - public HashSet getStallTagByEdge(ReferenceEdge edge){ - return stallEdgeMap.get(edge); - } - - public Hashtable getAccessibleMap() { - return accessibleMap; - } - - public Hashtable getStallMap() { - return stallMap; - } - - public void addAccessibleVar(TempDescriptor td) { - accessibleMap.put(td, ACCESSIBLE); - } - - public void addInaccessibleVar(TempDescriptor td) { - accessibleMap.put(td, INACCESSIBLE); - } - - public void addStallSite(TempDescriptor td, HashSet heapSet, StallTag sTag, TempDescriptor tdA) { - StallSite stallSite=new StallSite(heapSet,sTag); - if(tdA!=null){ - stallSite.setTdA(tdA); - } - stallMap.put(td, stallSite); - } - - public void addStallSite(TempDescriptor td, StallSite stallSite) { - stallMap.put(td, stallSite); - } - - public boolean hasStallSite(TempDescriptor td){ - return stallMap.containsKey(td); - } - - public boolean isAccessible(TempDescriptor td) { - if (accessibleMap.containsKey(td) - && accessibleMap.get(td).equals(ACCESSIBLE)) { - return true; - } - return false; - } - - public void contributeEffect(TempDescriptor td, String type, String field, - int effect) { - - StallSite stallSite = stallMap.get(td); - if (stallSite != null) { - stallSite.addEffect(type, field, effect); - } - - } - - public void merge(ParentChildConflictsMap newConflictsMap) { - - Hashtable newAccessibleMap = newConflictsMap - .getAccessibleMap(); - Hashtable newStallMap = newConflictsMap - .getStallMap(); - - Set keySet = newAccessibleMap.keySet(); - for (Iterator iterator = keySet.iterator(); iterator - .hasNext();) { - TempDescriptor key = iterator.next(); - - Integer newStatus = newAccessibleMap.get(key); - - // inaccessible is prior to accessible - Integer currentStatus = getAccessibleMap().get(key); - if (currentStatus != null && currentStatus == ACCESSIBLE - && newStatus == INACCESSIBLE) { - getAccessibleMap().put(key, INACCESSIBLE); - }else if(currentStatus == null && newStatus == ACCESSIBLE){ - getAccessibleMap().put(key, ACCESSIBLE); - } - } - - keySet = newStallMap.keySet(); - for (Iterator iterator = keySet.iterator(); iterator - .hasNext();) { - TempDescriptor key = iterator.next(); - - StallSite newStallSite = newStallMap.get(key); - StallSite currentStallSite = getStallMap().get(key); - - if(currentStallSite==null){ - currentStallSite=new StallSite(); - } - - // handle effects - HashSet currentEffectSet = currentStallSite.getEffectSet(); - HashSet newEffectSet = newStallSite.getEffectSet(); - for (Iterator iterator2 = newEffectSet.iterator(); iterator2 - .hasNext();) { - Effect effect = (Effect) iterator2.next(); - if (!currentEffectSet.contains(effect)) { - currentEffectSet.add(effect); - } - } - - // handle heap region - HashSet currentHRNSet = currentStallSite.getHRNSet(); - HashSet newHRNSet = newStallSite.getHRNSet(); - for (Iterator iterator2 = newHRNSet.iterator(); iterator2.hasNext();) { - HeapRegionNode hrnID = (HeapRegionNode) iterator2.next(); - if (!currentHRNSet.contains(hrnID)) { - currentHRNSet.add(hrnID); - } - } - - // handle reachabilitySet - HashSet currentRSet=currentStallSite.getReachabilitySet(); - HashSet newRSet=newStallSite.getReachabilitySet(); - Iterator ttsIter=newRSet.iterator(); - while(ttsIter.hasNext()){ - TokenTupleSet tokenTupleSet=(TokenTupleSet) ttsIter.next(); - currentRSet.add(tokenTupleSet); - } -// ReachabilitySet currentRSet = currentStallSite.getReachabilitySet(); -// ReachabilitySet newRSet = newStallSite.getReachabilitySet(); -// Iterator ttsIter = newRSet.iterator(); -// while (ttsIter.hasNext()) { -// TokenTupleSet tokenTupleSet = (TokenTupleSet) ttsIter.next(); -// currentRSet.add(tokenTupleSet); -// } - - //handle allocationsite - HashSet currentAloc=currentStallSite.getAllocationSiteSet(); - HashSet newAloc=newStallSite.getAllocationSiteSet(); - currentAloc.addAll(newAloc); - - // handle related stall tags - HashSet currentStallTagSet=currentStallSite.getStallTagSet(); - HashSet newStallTagSet=newStallSite.getStallTagSet(); - currentStallTagSet.addAll(newStallTagSet); - - // reaching param idxs - HashSet currentParamIdx=currentStallSite.getCallerParamIdxSet(); - HashSet newParamIdx=newStallSite.getCallerParamIdxSet(); - currentParamIdx.addAll(newParamIdx); - - StallSite merged=new StallSite(currentEffectSet, currentHRNSet, - currentRSet, currentAloc, currentStallTagSet,currentParamIdx); - - - getStallMap() - .put( - key, - merged); - - } - - // merge edge mapping - - Hashtable> newStallEdgeMapping=newConflictsMap.getStallEdgeMap(); - Set edgeSet=newStallEdgeMapping.keySet(); - - for (Iterator iterator = edgeSet.iterator(); iterator.hasNext();) { - ReferenceEdge stallEdge = (ReferenceEdge) iterator.next(); - HashSet newStallTagSet=newStallEdgeMapping.get(stallEdge); - HashSetcurrentStallTagSet=getStallEdgeMap().get(stallEdge); - - if(currentStallTagSet==null){ - currentStallTagSet=new HashSet(); - } - currentStallTagSet.addAll(newStallTagSet); - getStallEdgeMap().put(stallEdge,currentStallTagSet); - } - - } - - public Set getAllocationSiteIDSetofStallSite() { - - HashSet returnSet=new HashSet(); - - Enumeration stallSiteEnum=stallMap.elements(); - while (stallSiteEnum.hasMoreElements()) { - StallSite stallSite = (StallSite) stallSiteEnum.nextElement(); - HashSet hrnSet=stallSite.getHRNSet(); - for (Iterator iterator = hrnSet.iterator(); iterator.hasNext();) { - HeapRegionNode hrn = (HeapRegionNode) iterator.next(); - // allocSiteIDSet.add(hrn.getGloballyUniqueIdentifier()); - returnSet.add(new Long(hrn - .getGloballyUniqueIntegerIdentifier())); - } - } - return returnSet; - - } - - public boolean equals(Object o) { - - if (o == null) { - return false; - } - - if (!(o instanceof ParentChildConflictsMap)) { - return false; - } - - ParentChildConflictsMap in = (ParentChildConflictsMap) o; - - if ( accessibleMap.equals(in.getAccessibleMap()) - && stallMap.equals(in.getStallMap()) && isAfterSESE()==in.isAfterSESE()) { - return true; - } else { - return false; - } - - } - - public String toString() { - return "ParentChildConflictsMap [accessibleMap=" + accessibleMap - + ", stallMap=" - + stallMap + "]"; - } - -} diff --git a/Robust/src/Analysis/MLP/SESEEffectsKey.java b/Robust/src/Analysis/MLP/SESEEffectsKey.java deleted file mode 100644 index d26e5ebd..00000000 --- a/Robust/src/Analysis/MLP/SESEEffectsKey.java +++ /dev/null @@ -1,100 +0,0 @@ -package Analysis.MLP; - -import Analysis.OwnershipAnalysis.ReachabilitySet; -import IR.TypeDescriptor; - -public class SESEEffectsKey { - - private String fd; - private TypeDescriptor td; - private Integer hrnId; - private String hrnUniqueId; - private ReachabilitySet rset; - private boolean wStrong=false; - - public SESEEffectsKey(String fd, TypeDescriptor td, Integer hrnId, String hrnUniqueId) { - this.fd = fd; - this.td = td; - this.hrnId = hrnId; - this.hrnUniqueId=hrnUniqueId; - } - - public void setRSet(ReachabilitySet rset){ - this.rset=rset; - } - - public ReachabilitySet getRSet(){ - return rset; - } - - public void setStrong(boolean wStrong){ - this.wStrong=wStrong; - } - - public boolean isStrong(){ - return wStrong; - } - - public String getFieldDescriptor() { - return fd; - } - - public TypeDescriptor getTypeDescriptor() { - return td; - } - - public Integer getHRNId() { - return hrnId; - } - - public String getHRNUniqueId(){ - return hrnUniqueId; - } - - public String toString() { - return "(" + td + ")" + fd + "#" + hrnId+":"+hrnUniqueId; - } - - public int hashCode() { - - int hash = 1; - - if (fd != null) { - hash = hash * 31 + fd.hashCode(); - } - - if (td != null) { - hash += td.getSymbol().hashCode(); - } - - if (hrnId != null) { - hash += hrnId.hashCode(); - } - - return hash; - - } - - public boolean equals(Object o) { - - if (o == null) { - return false; - } - - if (!(o instanceof SESEEffectsKey)) { - return false; - } - - SESEEffectsKey in = (SESEEffectsKey) o; - - if (fd.equals(in.getFieldDescriptor()) - && td.getSymbol().equals(in.getTypeDescriptor().getSymbol()) - && hrnId.equals(in.getHRNId())) { - return true; - } else { - return false; - } - - } - -} diff --git a/Robust/src/Analysis/MLP/SESEEffectsSet.java b/Robust/src/Analysis/MLP/SESEEffectsSet.java deleted file mode 100644 index 91a0cfa8..00000000 --- a/Robust/src/Analysis/MLP/SESEEffectsSet.java +++ /dev/null @@ -1,228 +0,0 @@ -package Analysis.MLP; - -import java.io.StringWriter; -import java.util.HashSet; -import java.util.Hashtable; -import java.util.Iterator; -import java.util.Set; - -import Analysis.OwnershipAnalysis.ReferenceEdge; -import IR.Flat.TempDescriptor; - -public class SESEEffectsSet { - private Hashtable> readTable; - private Hashtable> writeTable; - private Hashtable> strongUpdateTable; - private Hashtable mapTempDescToInVarIdx; - private Hashtable mapEdgeToTaint; - - public SESEEffectsSet() { - readTable = new Hashtable>(); - writeTable = new Hashtable>(); - strongUpdateTable = new Hashtable>(); - mapTempDescToInVarIdx = new Hashtable(); - mapEdgeToTaint = new Hashtable(); - } - - public int getTaint(ReferenceEdge edge){ - int taint=0; - if(mapEdgeToTaint.containsKey(edge)){ - taint=mapEdgeToTaint.get(edge).intValue(); - } - return taint; - } - - public void mapEdgeToTaint(ReferenceEdge edge, int newTaint){ - int taint=0; - if(mapEdgeToTaint.containsKey(edge)){ - taint=mapEdgeToTaint.get(edge).intValue(); - } - taint=taint | newTaint; - mapEdgeToTaint.put(edge, new Integer(taint)); - } - - public void setInVarIdx(int idx, TempDescriptor td){ - mapTempDescToInVarIdx.put(td,new Integer(idx)); - } - - public int getInVarIdx(TempDescriptor td){ - Integer idx=mapTempDescToInVarIdx.get(td); - if(idx==null){ - // if invar is from SESE placeholder, it is going to be ignored. - return -1; - } - return idx.intValue(); - } - - public Hashtable getMapTempDescToInVarIdx(){ - return mapTempDescToInVarIdx; - } - - public void addReadingVar(TempDescriptor td, SESEEffectsKey access) { - HashSet aSet = readTable.get(td); - if (aSet == null) { - aSet = new HashSet(); - } - - aSet.add(access); - readTable.put(td, aSet); - } - - public void addReadingEffectsSet(TempDescriptor td, - HashSet newSet) { - - if (newSet != null) { - HashSet aSet = readTable.get(td); - if (aSet == null) { - aSet = new HashSet(); - } - aSet.addAll(newSet); - readTable.put(td, aSet); - } - - } - - public void addWritingEffectsSet(TempDescriptor td, - HashSet newSet) { - - if (newSet != null) { - HashSet aSet = writeTable.get(td); - if (aSet == null) { - aSet = new HashSet(); - } - aSet.addAll(newSet); - writeTable.put(td, aSet); - } - - } - - public Hashtable> getReadTable() { - return readTable; - } - - public Hashtable> getWriteTable() { - return writeTable; - } - - public Hashtable> getStrongUpdateTable() { - return strongUpdateTable; - } - - public void addWritingVar(TempDescriptor td, SESEEffectsKey access) { - HashSet aSet = writeTable.get(td); - if (aSet == null) { - aSet = new HashSet(); - } - aSet.add(access); - writeTable.put(td, aSet); - } - - public void addStrongUpdateVar(TempDescriptor td, SESEEffectsKey access) { - HashSet aSet = strongUpdateTable.get(td); - if (aSet == null) { - aSet = new HashSet(); - } - aSet.add(access); - strongUpdateTable.put(td, aSet); - } - - public Set getReadingSet(TempDescriptor td) { - return readTable.get(td); - } - - public Set getWritingSet(TempDescriptor td) { - return writeTable.get(td); - } - - public Set getStrongUpdateSet(TempDescriptor td){ - return strongUpdateTable.get(td); - } - - public String printSet() { - - StringWriter writer=new StringWriter(); - - Set keySet = readTable.keySet(); - Iterator iter = keySet.iterator(); - while (iter.hasNext()) { - TempDescriptor td = iter.next(); - Set effectSet = readTable.get(td); - String keyStr = "{"; - if (effectSet != null) { - Iterator effectIter = effectSet.iterator(); - while (effectIter.hasNext()) { - SESEEffectsKey key = effectIter.next(); - keyStr += " " + key; - } - } - keyStr+=" }"; - writer.write("Live-in Var " + td + " Read=" + keyStr+"\n"); - } - - keySet = writeTable.keySet(); - iter = keySet.iterator(); - while (iter.hasNext()) { - TempDescriptor td = iter.next(); - Set effectSet = writeTable.get(td); - String keyStr = "{"; - if (effectSet != null) { - Iterator effectIter = effectSet.iterator(); - while (effectIter.hasNext()) { - SESEEffectsKey key = effectIter.next(); - keyStr += " " + key; - } - } - keyStr+=" }"; - writer.write("Live-in Var " + td + " Write=" + keyStr+"\n"); - } - - keySet = strongUpdateTable.keySet(); - iter = keySet.iterator(); - while (iter.hasNext()) { - TempDescriptor td = iter.next(); - Set effectSet = strongUpdateTable.get(td); - String keyStr = "{"; - if (effectSet != null) { - Iterator effectIter = effectSet.iterator(); - while (effectIter.hasNext()) { - SESEEffectsKey key = effectIter.next(); - keyStr += " " + key; - } - } - keyStr+=" }"; - writer.write("Live-in Var " + td + " StrongUpdate=" + keyStr+"\n"); - } - - return writer.toString(); - - } - - public boolean equals(Object o) { - if (o == null) { - return false; - } - - if (!(o instanceof SESEEffectsSet)) { - return false; - } - - SESEEffectsSet in = (SESEEffectsSet) o; - - if (getReadTable().equals(in.getReadTable()) - && getWriteTable().equals(in.getWriteTable()) - && getStrongUpdateTable().equals(in.getStrongUpdateTable())) { - return true; - } else { - return false; - } - - } - - public int hashCode() { - int hash = 1; - - hash += getReadTable().hashCode() + getWriteTable().hashCode() * 31 +getStrongUpdateTable().hashCode(); - - return hash; - } -} diff --git a/Robust/src/Analysis/MLP/SESELock.java b/Robust/src/Analysis/MLP/SESELock.java deleted file mode 100644 index e8119066..00000000 --- a/Robust/src/Analysis/MLP/SESELock.java +++ /dev/null @@ -1,221 +0,0 @@ -package Analysis.MLP; - -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; - -public class SESELock { - - private HashSet conflictNodeSet; - private HashSet conflictEdgeSet; - private HashMap nodeTypeMap; - private int id; - - public SESELock(){ - conflictNodeSet=new HashSet(); - conflictEdgeSet=new HashSet(); - nodeTypeMap=new HashMap(); - } - - public void addConflictNode(ConflictNode node, int type){ - conflictNodeSet.add(node); - setNodeType(node, type); - } - - public void setNodeType(ConflictNode node, int type){ - nodeTypeMap.put(node, new Integer(type)); - } - - public int getNodeType(ConflictNode node){ - return nodeTypeMap.get(node).intValue(); - } - - public void addConflictEdge(ConflictEdge e){ - conflictEdgeSet.add(e); - } - - public boolean containsConflictEdge(ConflictEdge e){ - return conflictEdgeSet.contains(e); - } - - public HashSet getConflictNodeSet(){ - return conflictNodeSet; - } - - public boolean isWriteNode(ConflictNode node){ - if (node instanceof StallSiteNode) { - StallSiteNode stallSiteNode = (StallSiteNode) node; - HashSet effectSet = stallSiteNode.getStallSite() - .getEffectSet(); - for (Iterator iterator = effectSet.iterator(); iterator.hasNext();) { - Effect effect = (Effect) iterator.next(); - if (effect.getEffectType().equals(StallSite.WRITE_EFFECT)) { - return true; - } - } - } else { - LiveInNode liveInNode = (LiveInNode) node; - Set writeEffectSet = liveInNode - .getWriteEffectsSet(); - if (writeEffectSet != null && writeEffectSet.size() > 0) { - return true; - } - } - - return false; - - } - - - public boolean hasSelfCoarseEdge(ConflictNode node){ - - HashSet set=node.getEdgeSet(); - for (Iterator iterator = set.iterator(); iterator.hasNext();) { - ConflictEdge conflictEdge = (ConflictEdge) iterator.next(); - if(conflictEdge.getType()!=ConflictEdge.FINE_GRAIN_EDGE&&conflictEdge.getVertexU()==conflictEdge.getVertexV()){ - return true; - } - } - return false; - } - - private boolean isFineNode(ConflictNode node){ - - if(node.getType()<4){ - return true; - } - - return false; - - } - - public ConflictNode getNewNodeCoarseConnectedWithGroup(ConflictEdge newEdge) { - - // check whether or not the new node has a fine-grained edges to all - // current nodes. - - ConflictNode newNode; - if (conflictNodeSet.contains(newEdge.getVertexU())) { - newNode = newEdge.getVertexV(); - } else if(conflictNodeSet.contains(newEdge.getVertexV())) { - newNode = newEdge.getVertexU(); - }else{ - return null; - } - - int count = 0; - HashSet edgeSet = newNode.getEdgeSet(); - for (Iterator iterator = edgeSet.iterator(); iterator.hasNext();) { - ConflictEdge conflictEdge = (ConflictEdge) iterator.next(); - if (!conflictEdge.getVertexU().equals(newNode) - && conflictNodeSet.contains(conflictEdge.getVertexU()) && isFineNode(conflictEdge.getVertexU()) ) { - count++; - } else if (!conflictEdge.getVertexV().equals(newNode) - && conflictNodeSet.contains(conflictEdge.getVertexV()) && isFineNode(conflictEdge.getVertexU()) ) { - count++; - } - } - - if (count == conflictNodeSet.size()) { - // connected to all current nodes in group - return newNode; - } - - return null; - - } - - - public ConflictNode getNewNodeConnectedWithGroup(ConflictEdge newEdge) { - - // check whether or not the new node has a fine-grained edges to all - // current nodes. - - ConflictNode newNode; - if (conflictNodeSet.contains(newEdge.getVertexU())) { - newNode = newEdge.getVertexV(); - } else if(conflictNodeSet.contains(newEdge.getVertexV())){ - newNode = newEdge.getVertexU(); - }else{ - return null; - } - - int count = 0; - HashSet edgeSet = newNode.getEdgeSet(); - for (Iterator iterator = edgeSet.iterator(); iterator.hasNext();) { - ConflictEdge conflictEdge = (ConflictEdge) iterator.next(); - if (!conflictEdge.getVertexU().equals(newNode) - && conflictNodeSet.contains(conflictEdge.getVertexU())) { - count++; - } else if (!conflictEdge.getVertexV().equals(newNode) - && conflictNodeSet.contains(conflictEdge.getVertexV())) { - count++; - } - } - - if (count == conflictNodeSet.size()) { - // connected to all current nodes in group - return newNode; - } - - return null; - - } - - public void addEdge(ConflictEdge edge){ - conflictNodeSet.add(edge.getVertexU()); - conflictNodeSet.add(edge.getVertexV()); - } - - public int getID(){ - return id; - } - - public void setID(int id){ - this.id=id; - } - - public boolean containsConflictNode(ConflictNode node){ - - return conflictNodeSet.contains(node); - - } - - - public boolean testEdge(ConflictEdge newEdge){ - - - if( !conflictNodeSet.contains(newEdge.getVertexU()) && !conflictNodeSet.contains(newEdge.getVertexV()) ){ - return false; - } - - ConflictNode nodeToAdd=conflictNodeSet.contains(newEdge.getVertexU())?newEdge.getVertexV():newEdge.getVertexU(); - - HashSet nodeSet=new HashSet(conflictNodeSet); - - for(Iterator edgeIter=nodeToAdd.getEdgeSet().iterator();edgeIter.hasNext();){ - ConflictEdge edge=(ConflictEdge)edgeIter.next(); - if(nodeSet.contains(edge.getVertexU())){ - nodeSet.remove(edge.getVertexU()); - }else if(nodeSet.contains(edge.getVertexV())){ - nodeSet.remove(edge.getVertexV()); - } - } - - return nodeSet.isEmpty(); - - } - - public String toString(){ - String rtr=""; - - for (Iterator iterator = conflictNodeSet.iterator(); iterator.hasNext();) { - ConflictNode node = (ConflictNode) iterator.next(); - rtr+=" "+node+"::"+getNodeType(node); - } - - return rtr; - } - -} diff --git a/Robust/src/Analysis/MLP/SESESummary.java b/Robust/src/Analysis/MLP/SESESummary.java deleted file mode 100644 index c0643df1..00000000 --- a/Robust/src/Analysis/MLP/SESESummary.java +++ /dev/null @@ -1,46 +0,0 @@ -package Analysis.MLP; - -import IR.Flat.FlatNode; -import IR.Flat.FlatSESEEnterNode; - -public class SESESummary { - - private FlatNode currentParent; - private FlatNode currentSESE; - - public SESESummary(FlatNode currentParent, FlatNode currentChild) { - this.currentParent = currentParent; - this.currentSESE = currentChild; - } - - public FlatNode getCurrentParent() { - return currentParent; - } - - public FlatNode getCurrentSESE() { - return currentSESE; - } - - public void setCurrentParent(FlatNode parent) { - currentParent = parent; - } - - public void setCurrentSESE(FlatNode current) { - currentSESE = current; - } - - public String toString() { - String rtn; - - rtn = "parent=" + currentParent; - if (currentSESE instanceof FlatSESEEnterNode) { - rtn += " current=" - + ((FlatSESEEnterNode) currentSESE).getPrettyIdentifier(); - } else { - rtn += " current=" + currentSESE; - } - - return rtn; - } - -} diff --git a/Robust/src/Analysis/MLP/SESETree.java b/Robust/src/Analysis/MLP/SESETree.java deleted file mode 100644 index f63e78ab..00000000 --- a/Robust/src/Analysis/MLP/SESETree.java +++ /dev/null @@ -1,173 +0,0 @@ -package Analysis.MLP; -import IR.*; -import IR.Flat.*; -import java.util.*; -import Analysis.CallGraph.*; - -public class SESETree { - State state; - TypeUtil typeutil; - CallGraph callgraph; - SESENode root; - Hashtable> toanalyze=new Hashtable>(); - Hashtable> discovered=new Hashtable>(); - Hashtable sesemap=new Hashtable(); - - public SESETree(State state, TypeUtil typeutil, CallGraph callgraph) { - this.state=state; - this.typeutil=typeutil; - this.callgraph=callgraph; - root=new SESENode(null, true); - doAnalysis(); - } - - public SESENode getRoot() { - return root; - } - - public void doAnalysis() { - MethodDescriptor main=typeutil.getMain(); - add(toanalyze, main, root); - add(discovered, main, root); - - while(!toanalyze.isEmpty()) { - MethodDescriptor md=toanalyze.keySet().iterator().next(); - Set context=toanalyze.get(md); - toanalyze.remove(md); - FlatMethod fm=state.getMethodFlat(md); - analyzeMethod(fm, context); - } - } - - public SESENode getSESE(FlatSESEEnterNode enter) { - if (!sesemap.containsKey(enter)) { - sesemap.put(enter, new SESENode(enter, false)); - } - return sesemap.get(enter); - } - - public Set getSESE(MethodDescriptor md) { - return discovered.get(md); - } - - public Hashtable> analyzeMethod(FlatMethod fm) { - return analyzeMethod(fm, null); - } - - private Hashtable> analyzeMethod(FlatMethod fm, Set context) { - Hashtable> stacks=new Hashtable> (); - stacks.put(fm, new Stack()); - HashSet tovisit=new HashSet(); - HashSet fndiscovered=new HashSet(); - tovisit.add(fm); - fndiscovered.add(fm); - while(!tovisit.isEmpty()) { - FlatNode fn=tovisit.iterator().next(); - tovisit.remove(fn); - Stack instack=stacks.get(fm); - switch(fn.kind()) { - case FKind.FlatCall: { - if (context==null) - break; - FlatCall fc=(FlatCall)fn; - //handle method call - Set parents; - if (instack.isEmpty()) { - parents=context; - } else { - parents=new HashSet(); - parents.add(instack.peek()); - } - for(Iterator parentit=parents.iterator();parentit.hasNext();) { - SESENode parentsese=parentit.next(); - for(Iterator calleeit=(fc.getThis()==null?callgraph.getMethods(fc.getMethod()):callgraph.getMethods(fc.getMethod(), fc.getThis().getType())).iterator(); calleeit.hasNext();) { - MethodDescriptor md=calleeit.next(); - if (add(discovered,md, parentsese)) { - add(toanalyze, md, parentsese); - } - } - } - break; - } - case FKind.FlatSESEEnterNode: { - FlatSESEEnterNode enter=(FlatSESEEnterNode)fn; - - if (context!=null) { - Set parents; - if (instack.isEmpty()) { - parents=context; - } else { - parents=new HashSet(); - parents.add(instack.peek()); - } - SESENode sese=getSESE(enter); - for(Iterator parentit=parents.iterator();parentit.hasNext();) { - SESENode parentsese=parentit.next(); - parentsese.addChild(sese); - } - } - Stack copy=(Stack)instack.clone(); - copy.push(sese); - instack=copy; - break; - } - case FKind.FlatSESEExitNode: { - FlatSESEExitNode exit=(FlatSESEExitNode)fn; - Stack copy=(Stack)instack.clone(); - copy.pop(); - instack=copy; - break; - } - } - for(int i=0;i> discovered, MethodDescriptor md, SESENode sese) { - if (!discovered.containsKey(md)) - discovered.put(md, new HashSet()); - if (discovered.get(md).contains(sese)) - return false; - discovered.get(md).add(sese); - return true; - } - - - class SESENode { - boolean isRoot; - HashSet children; - HashSet parents; - - FlatSESEEnterNode node; - SESENode(FlatSESEEnterNode node, boolean isRoot) { - children=new HashSet(); - this.isRoot=isRoot; - this.node=node; - } - - public boolean isLeaf() { - return children.isEmpty(); - } - - protected void addChild(SESENode child) { - children.add(child); - child.parents.add(this); - } - - public Set getParents() { - return parents; - } - - public Set getChildren() { - return children; - } - } -} \ No newline at end of file diff --git a/Robust/src/Analysis/MLP/SESEWaitingQueue.java b/Robust/src/Analysis/MLP/SESEWaitingQueue.java deleted file mode 100644 index e0457bb3..00000000 --- a/Robust/src/Analysis/MLP/SESEWaitingQueue.java +++ /dev/null @@ -1,53 +0,0 @@ -package Analysis.MLP; - -import java.util.HashMap; -import java.util.Iterator; -import java.util.Set; - -public class SESEWaitingQueue { - public static final int NORMAL= 0; // enqueue all stuff. - public static final int EXCEPTION= 1; // dynamically decide whether a waiting element is enqueued or not. - - private HashMap>mapWaitingElement; - private HashMapmapType; - - public SESEWaitingQueue(){ - mapWaitingElement=new HashMap>(); - mapType=new HashMap(); - } - - public void setType(int queueID, int type){ - mapType.put(new Integer(queueID), new Integer(type)); - } - - public int getType(int queueID){ - Integer type=mapType.get(new Integer(queueID)); - if(type==null){ - return SESEWaitingQueue.NORMAL; - }else{ - return type.intValue(); - } - } - - public void setWaitingElementSet(int queueID, Set set){ - mapWaitingElement.put(new Integer(queueID), set); - } - - public Set getWaitingElementSet(int queueID){ - return mapWaitingElement.get(new Integer(queueID)); - } - - public Set getQueueIDSet(){ - return mapWaitingElement.keySet(); - } - - public int getWaitingElementSize(){ - int size=0; - Set keySet=mapWaitingElement.keySet(); - for (Iterator iterator = keySet.iterator(); iterator.hasNext();) { - Integer key = (Integer) iterator.next(); - size+=mapWaitingElement.get(key).size(); - } - return size; - } -} diff --git a/Robust/src/Analysis/MLP/SESEandAgePair.java b/Robust/src/Analysis/MLP/SESEandAgePair.java deleted file mode 100644 index d82a3c41..00000000 --- a/Robust/src/Analysis/MLP/SESEandAgePair.java +++ /dev/null @@ -1,54 +0,0 @@ -package Analysis.MLP; - -import IR.*; -import IR.Flat.*; -import java.util.*; -import java.io.*; - -public class SESEandAgePair { - - private FlatSESEEnterNode sese; - private Integer age; - - public SESEandAgePair( FlatSESEEnterNode sese, - Integer age ) { - this.sese = sese; - this.age = age; - } - - public FlatSESEEnterNode getSESE() { - return sese; - } - - public Integer getAge() { - return age; - } - - public boolean equals( Object o ) { - if( o == null ) { - return false; - } - - if( !(o instanceof SESEandAgePair) ) { - return false; - } - - SESEandAgePair p = (SESEandAgePair) o; - - return age.equals( p.age ) && - sese.equals( p.sese ); - } - - public int hashCode() { - return (sese.hashCode() << 2)*(age.hashCode() << 5); - } - - - public String toString() { - return "SESE_"+ - sese.getPrettyIdentifier()+ - sese.getIdentifier()+ - "_"+ - age; - } -} diff --git a/Robust/src/Analysis/MLP/SVKey.java b/Robust/src/Analysis/MLP/SVKey.java deleted file mode 100644 index b344e99e..00000000 --- a/Robust/src/Analysis/MLP/SVKey.java +++ /dev/null @@ -1,50 +0,0 @@ -package Analysis.MLP; - -import IR.*; -import IR.Flat.*; -import java.util.*; -import java.io.*; - -public class SVKey { - - private FlatSESEEnterNode sese; - private TempDescriptor var; - - public SVKey( FlatSESEEnterNode sese, - TempDescriptor var ) { - this.sese = sese; - this.var = var; - } - - public FlatSESEEnterNode getSESE() { - return sese; - } - - public TempDescriptor getVar() { - return var; - } - - public boolean equals( Object o ) { - if( o == null ) { - return false; - } - - if( !(o instanceof SVKey) ) { - return false; - } - - SVKey k = (SVKey) o; - - return var.equals( k.var ) && - sese.equals( k.sese ); - } - - public int hashCode() { - return (sese.hashCode() << 2)*(var.hashCode() << 5); - } - - - public String toString() { - return "key["+sese.getPrettyIdentifier()+", "+var+"]"; - } -} diff --git a/Robust/src/Analysis/MLP/StallSite.java b/Robust/src/Analysis/MLP/StallSite.java deleted file mode 100644 index 1b780805..00000000 --- a/Robust/src/Analysis/MLP/StallSite.java +++ /dev/null @@ -1,269 +0,0 @@ -package Analysis.MLP; - -import java.util.HashSet; -import java.util.Iterator; -import java.util.Set; - -import Analysis.OwnershipAnalysis.AllocationSite; -import Analysis.OwnershipAnalysis.HeapRegionNode; -import Analysis.OwnershipAnalysis.TokenTupleSet; -import IR.Flat.FlatNode; -import IR.Flat.TempDescriptor; - -public class StallSite { - - public static final Integer READ_EFFECT = new Integer(1); - public static final Integer WRITE_EFFECT = new Integer(2); - - private HashSet effectSet; - private HashSet hrnSet; - private HashSet allocationSiteSet; -// private ReachabilitySet reachabilitySet; - HashSet reachabilitySet; - private HashSet stallTagSet; - private TempDescriptor tdA; - - // if stall site is caller's parameter heap regtion, store its parameter idx - // for further analysis - private HashSet callerParamIdxSet; - - public StallSite() { - effectSet = new HashSet(); - hrnSet = new HashSet(); - reachabilitySet = new HashSet(); - allocationSiteSet = new HashSet(); - stallTagSet = new HashSet(); - callerParamIdxSet = new HashSet(); - } - - public StallSite(HashSet hrnSet, StallTag tag) { - - this(); - - setHeapRegionNodeSet(hrnSet); - stallTagSet.add(tag); - - for (Iterator iterator = hrnSet.iterator(); iterator.hasNext();) { - HeapRegionNode heapRegionNode = (HeapRegionNode) iterator.next(); - setAllocationSite(heapRegionNode.getAllocationSite()); - } - } - - public StallSite(HashSet effectSet, HashSet hrnSet, - HashSet rechabilitySet, HashSet alocSet, - HashSet tagSet, HashSet paramIdx) { - this(); - this.effectSet.addAll(effectSet); - this.hrnSet.addAll(hrnSet); - this.reachabilitySet = rechabilitySet; - this.allocationSiteSet.addAll(alocSet); - this.stallTagSet.addAll(tagSet); - this.callerParamIdxSet.addAll(paramIdx); - } - - public void addTokenTupleSet(TokenTupleSet newSet){ - reachabilitySet.add(newSet); - } - - public HashSet getCallerParamIdxSet() { - return callerParamIdxSet; - } - - public void addCallerParamIdxSet(Set newParamSet) { - if (newParamSet != null) { - callerParamIdxSet.addAll(newParamSet); - } - } - - public void setStallTagSet(HashSet tags) { - stallTagSet = tags; - } - - public void addRelatedStallTag(StallTag stallTag) { - stallTagSet.add(stallTag); - } - - public void setAllocationSite(AllocationSite allocationSite) { - if (allocationSite != null) { - allocationSiteSet.add(allocationSite); - } - } - - public void setHeapRegionNodeSet(HashSet newSet) { - hrnSet.addAll(newSet); - } - - public HashSet getAllocationSiteSet() { - return allocationSiteSet; - } - - public void addEffect(String type, String field, Integer effect) { - - Effect e = new Effect(type, field, effect, stallTagSet); - effectSet.add(e); - } - - public HashSet getEffectSet() { - return effectSet; - } - - public HashSet getHRNSet() { - return hrnSet; - } - - public HashSet getReachabilitySet() { - return reachabilitySet; - } - - public HashSet getStallTagSet() { - return stallTagSet; - } - - public StallSite copy() { - - StallSite copy = new StallSite(effectSet, hrnSet, reachabilitySet, - allocationSiteSet, stallTagSet, callerParamIdxSet); - return copy; - - } - - public void setTdA(TempDescriptor tdA){ - this.tdA=tdA; - } - - public TempDescriptor getTdA(){ - return tdA; - } - - public boolean equals(Object o) { - - if (o == null) { - return false; - } - - if (!(o instanceof StallSite)) { - return false; - } - - StallSite in = (StallSite) o; - - if (allocationSiteSet.equals(in.getAllocationSiteSet()) - && stallTagSet.equals(in.getStallTagSet()) - && effectSet.equals(in.getEffectSet()) - && hrnSet.equals(in.getHRNSet()) - && reachabilitySet.equals(in.getReachabilitySet())) { - return true; - } else { - return false; - } - - } - - @Override - public String toString() { - return "StallSite [allocationSiteSet=" + allocationSiteSet - + ", callerParamIdxSet=" + callerParamIdxSet + ", effectSet=" - + effectSet + ", hrnSet=" + hrnSet + ", rechabilitySet=" - + reachabilitySet + ", stallTagSet=" + stallTagSet + "]"; - } - -} - -class StallTag { - - private FlatNode fn; - - public StallTag(FlatNode fn) { - this.fn = fn; - } - - public FlatNode getKey() { - return fn; - } - - public boolean equals(Object o) { - - if (o == null) { - return false; - } - - if (!(o instanceof StallTag)) { - return false; - } - - StallTag in = (StallTag) o; - - if (getKey().equals(in.getKey())) { - return true; - } else { - return false; - } - - } - -} - -class Effect { - - private String field; - private String type; - private Integer effect; - private HashSet stallTagSet; - - public Effect() { - stallTagSet = new HashSet(); - } - - public Effect(String type, String field, Integer effect, - HashSet tagSet) { - this(); - this.type = type; - this.field = field; - this.effect = effect; - stallTagSet.addAll(tagSet); - } - - public String getField() { - return field; - } - - public String getType() { - return type; - } - - public Integer getEffectType() { - return effect; - } - - public HashSet getStallTagSet() { - return stallTagSet; - } - - public boolean equals(Object o) { - - if (o == null) { - return false; - } - - if (!(o instanceof Effect)) { - return false; - } - - Effect in = (Effect) o; - - if (stallTagSet.equals(in.getStallTagSet()) - && type.equals(in.getType()) && field.equals(in.getField()) - && effect.equals(in.getEffectType())) { - return true; - } else { - return false; - } - - } - - public String toString() { - return "Effect [effect=" + effect + ", field=" + field - + ", stallTagSet=" + stallTagSet + ", type=" + type + "]"; - } - -} \ No newline at end of file diff --git a/Robust/src/Analysis/MLP/StallSiteNode.java b/Robust/src/Analysis/MLP/StallSiteNode.java deleted file mode 100644 index 6afd0de3..00000000 --- a/Robust/src/Analysis/MLP/StallSiteNode.java +++ /dev/null @@ -1,34 +0,0 @@ -package Analysis.MLP; - -import java.util.HashSet; -import java.util.Set; - -import Analysis.OwnershipAnalysis.HeapRegionNode; -import IR.Flat.TempDescriptor; - -public class StallSiteNode extends ConflictNode { - - protected StallSite stallSite; - - public StallSiteNode(String id, TempDescriptor td, StallSite stallSite, - Set reachabilitySet) { - this.id = id; - this.td = td; - this.stallSite = stallSite; - this.reachabilitySet = reachabilitySet; - } - - public HashSet getHRNSet() { - return stallSite.getHRNSet(); - } - - public StallSite getStallSite() { - return stallSite; - } - - public String toString(){ - String str="StallSiteNode "+id +" type="+type; - return str; - } - -} diff --git a/Robust/src/Analysis/MLP/VSTWrapper.java b/Robust/src/Analysis/MLP/VSTWrapper.java deleted file mode 100644 index 68987f4b..00000000 --- a/Robust/src/Analysis/MLP/VSTWrapper.java +++ /dev/null @@ -1,17 +0,0 @@ -package Analysis.MLP; - -import IR.*; -import IR.Flat.*; -import java.util.*; -import java.io.*; - -// the reason for this class is to allow a VariableSourceToken -// to be null in some circumstances - -public class VSTWrapper { - public VariableSourceToken vst; - - public VSTWrapper() { - vst = null; - } -} diff --git a/Robust/src/Analysis/MLP/VarSrcTokTable.java b/Robust/src/Analysis/MLP/VarSrcTokTable.java deleted file mode 100644 index d30e2334..00000000 --- a/Robust/src/Analysis/MLP/VarSrcTokTable.java +++ /dev/null @@ -1,889 +0,0 @@ -package Analysis.MLP; - -import IR.*; -import IR.Flat.*; -import java.util.*; -import java.io.*; - -// This class formerly had lazy consistency properties, but -// it is being changed so that the full set and the extra -// hash tables to access the full set efficiently by different -// elements will be consistent after EVERY operation. Also, -// a consistent assert method allows a debugger to ask whether -// an operation has produced an inconsistent VarSrcTokTable. - -// in an effort to make sure operations keep the table consistent, -// all public methods that are also used by other methods for -// intermediate results (add and remove are used in other methods) -// there should be a public version that calls the private version -// so consistency is checked after public ops, but not private ops -public class VarSrcTokTable { - - // a set of every token in the table - private HashSet trueSet; - - // these hashtables provide an efficient retreival from the true set - private Hashtable< TempDescriptor, Set > var2vst; - private Hashtable< FlatSESEEnterNode, Set > sese2vst; - private Hashtable< SVKey, Set > sv2vst; - - // maximum age from aging operation - private static final Integer MAX_AGE = new Integer( 2 ); - - public static final Integer SrcType_READY = new Integer( 34 ); - public static final Integer SrcType_STATIC = new Integer( 35 ); - public static final Integer SrcType_DYNAMIC = new Integer( 36 ); - - - public VarSrcTokTable() { - trueSet = new HashSet(); - - sese2vst = new Hashtable< FlatSESEEnterNode, Set >(); - var2vst = new Hashtable< TempDescriptor, Set >(); - sv2vst = new Hashtable< SVKey, Set >(); - - assertConsistency(); - } - - - // make a deep copy of the in table - public VarSrcTokTable( VarSrcTokTable in ) { - this(); - merge( in ); - assertConsistency(); - } - - - public void add( VariableSourceToken vst ) { - addPrivate( vst ); - assertConsistency(); - } - - private void addPrivate( VariableSourceToken vst ) { - - // make sure we aren't clobbering anything! - if( trueSet.contains( vst ) ) { - // if something with the same hashcode is in the true set, they might - // have different reference variable sets because that set is not considered - // in a token's equality, so make sure we smooth that out right here - Iterator vstItr = trueSet.iterator(); - while( vstItr.hasNext() ) { - VariableSourceToken vstAlready = vstItr.next(); - - if( vstAlready.equals( vst ) ) { - - // take out the one that is in (we dont' want collisions in - // any of the other hash map sets either) - removePrivate( vstAlready ); - - // combine reference variable sets - vst.getRefVars().addAll( vstAlready.getRefVars() ); - - // now jump back as we are adding in a brand new token - break; - } - } - } - - trueSet.add( vst ); - - Set s; - - s = sese2vst.get( vst.getSESE() ); - if( s == null ) { - s = new HashSet(); - } - s.add( vst ); - sese2vst.put( vst.getSESE(), s ); - - Iterator refVarItr = vst.getRefVars().iterator(); - while( refVarItr.hasNext() ) { - TempDescriptor refVar = refVarItr.next(); - s = var2vst.get( refVar ); - if( s == null ) { - s = new HashSet(); - } - s.add( vst ); - var2vst.put( refVar, s ); - - SVKey key = new SVKey( vst.getSESE(), refVar ); - s = sv2vst.get( key ); - if( s == null ) { - s = new HashSet(); - } - s.add( vst ); - sv2vst.put( key, s ); - } - } - - public void addAll( Set s ) { - Iterator itr = s.iterator(); - while( itr.hasNext() ) { - addPrivate( itr.next() ); - } - assertConsistency(); - } - - - public Set get() { - return trueSet; - } - - public Set get( FlatSESEEnterNode sese ) { - Set s = sese2vst.get( sese ); - if( s == null ) { - s = new HashSet(); - sese2vst.put( sese, s ); - } - return s; - } - - public Set get( TempDescriptor refVar ) { - Set s = var2vst.get( refVar ); - if( s == null ) { - s = new HashSet(); - var2vst.put( refVar, s ); - } - return s; - } - - public Set get( FlatSESEEnterNode sese, - TempDescriptor refVar ) { - SVKey key = new SVKey( sese, refVar ); - Set s = sv2vst.get( key ); - if( s == null ) { - s = new HashSet(); - sv2vst.put( key, s ); - } - return s; - } - - public Set get( FlatSESEEnterNode sese, - Integer age ) { - - HashSet s0 = (HashSet) sese2vst.get( sese ); - if( s0 == null ) { - s0 = new HashSet(); - sese2vst.put( sese, s0 ); - } - - Set s = (Set) s0.clone(); - Iterator sItr = s.iterator(); - while( sItr.hasNext() ) { - VariableSourceToken vst = sItr.next(); - if( !vst.getAge().equals( age ) ) { - s.remove( vst ); - } - } - - return s; - } - - - // merge now makes a deep copy of incoming stuff because tokens may - // be modified (reference var sets) by later ops that change more - // than one table, causing inconsistency - public void merge( VarSrcTokTable in ) { - - if( in == null ) { - return; - } - - Iterator vstItr = in.trueSet.iterator(); - while( vstItr.hasNext() ) { - VariableSourceToken vst = vstItr.next(); - this.addPrivate( vst.copy() ); - } - - assertConsistency(); - } - - - // remove operations must leave the trueSet - // and the hash maps consistent - public void remove( VariableSourceToken vst ) { - removePrivate( vst ); - assertConsistency(); - } - - private void removePrivate( VariableSourceToken vst ) { - trueSet.remove( vst ); - - Set s; - - s = get( vst.getSESE() ); - if( s != null ) { s.remove( vst ); } - - Iterator refVarItr = vst.getRefVars().iterator(); - while( refVarItr.hasNext() ) { - TempDescriptor refVar = refVarItr.next(); - - s = get( refVar ); - if( s != null ) { - s.remove( vst ); - if( s.isEmpty() ) { - var2vst.remove( refVar ); - } - } - - s = get( vst.getSESE(), refVar ); - if( s != null ) { - s.remove( vst ); - if( s.isEmpty() ) { - sv2vst.remove( new SVKey( vst.getSESE(), refVar ) ); - } - } - } - } - - - public void remove( FlatSESEEnterNode sese ) { - removePrivate( sese ); - assertConsistency(); - } - - public void removePrivate( FlatSESEEnterNode sese ) { - Set s = sese2vst.get( sese ); - if( s == null ) { - return; - } - - Iterator itr = s.iterator(); - while( itr.hasNext() ) { - VariableSourceToken vst = itr.next(); - removePrivate( vst ); - } - - sese2vst.remove( sese ); - } - - - public void remove( TempDescriptor refVar ) { - removePrivate( refVar ); - assertConsistency(); - } - - private void removePrivate( TempDescriptor refVar ) { - Set s = var2vst.get( refVar ); - if( s == null ) { - return; - } - - Set forRemoval = new HashSet(); - - // iterate over tokens that this temp can reference, make a set - // of tokens that need this temp stripped out of them - Iterator itr = s.iterator(); - while( itr.hasNext() ) { - VariableSourceToken vst = itr.next(); - Set refVars = vst.getRefVars(); - assert refVars.contains( refVar ); - forRemoval.add( vst ); - } - - itr = forRemoval.iterator(); - while( itr.hasNext() ) { - - // here's a token marked for removal - VariableSourceToken vst = itr.next(); - Set refVars = vst.getRefVars(); - - // if there was only one one variable - // referencing this token, just take it - // out of the table all together - if( refVars.size() == 1 ) { - removePrivate( vst ); - } - - sv2vst.remove( new SVKey( vst.getSESE(), refVar ) ); - - refVars.remove( refVar ); - } - - var2vst.remove( refVar ); - } - - - public void remove( FlatSESEEnterNode sese, - TempDescriptor var ) { - - // don't seem to need this, don't bother maintaining - // until its clear we need it - assert false; - } - - - // age tokens with respect to SESE curr, where - // any curr tokens increase age by 1 - public void age( FlatSESEEnterNode curr ) { - - Set forRemoval = - new HashSet(); - - Set forAddition = - new HashSet(); - - Iterator itr = trueSet.iterator(); - while( itr.hasNext() ) { - VariableSourceToken vst = itr.next(); - - if( vst.getSESE().equals( curr ) ) { - - // only age if the token isn't already the maximum age - if( vst.getAge() < MAX_AGE ) { - - forRemoval.add( vst ); - - forAddition.add( new VariableSourceToken( vst.getRefVars(), - curr, - vst.getAge() + 1, - vst.getAddrVar() - ) - ); - } - } - } - - itr = forRemoval.iterator(); - while( itr.hasNext() ) { - VariableSourceToken vst = itr.next(); - remove( vst ); - } - - itr = forRemoval.iterator(); - while( itr.hasNext() ) { - VariableSourceToken vst = itr.next(); - add( vst ); - } - - assertConsistency(); - } - - - // at an SESE enter node, all ref vars in the SESE's in-set will - // be copied into the SESE's local scope, change source to itself - public void ownInSet( FlatSESEEnterNode curr ) { - Iterator inVarItr = curr.getInVarSet().iterator(); - while( inVarItr.hasNext() ) { - TempDescriptor inVar = inVarItr.next(); - - remove( inVar ); - assertConsistency(); - - Set refVars = new HashSet(); - refVars.add( inVar ); - add( new VariableSourceToken( refVars, - curr, - new Integer( 0 ), - inVar - ) - ); - assertConsistency(); - } - } - - - // for the given SESE, change child tokens into this parent - public void remapChildTokens( FlatSESEEnterNode curr ) { - - Iterator childItr = curr.getChildren().iterator(); - if( childItr.hasNext() ) { - FlatSESEEnterNode child = childItr.next(); - - // set of VSTs for removal - HashSet removalSet=new HashSet(); - // set of VSTs for additon - HashSet additionSet=new HashSet(); - - Iterator vstItr = get( child ).iterator(); - while( vstItr.hasNext() ) { - VariableSourceToken vst = vstItr.next(); - removalSet.add(vst); - additionSet.add(new VariableSourceToken( vst.getRefVars(), - curr, - new Integer( 0 ), - vst.getAddrVar() - )); - } - - // remove( eah item in forremoval ) - vstItr = removalSet.iterator(); - while( vstItr.hasNext() ) { - VariableSourceToken vst = vstItr.next(); - remove( vst ); - } - // add( each ite inm for additon _ - vstItr = additionSet.iterator(); - while( vstItr.hasNext() ) { - VariableSourceToken vst = vstItr.next(); - add( vst ); - } - } - - assertConsistency(); - } - - - // this method is called at the SESE exit of SESE 'curr' - // if the sources for a variable written by curr can also - // come from curr's parent or curr's siblings then we're not - // sure that curr will actually modify the variable. There are - // many ways to handle this, but for now, mark the variable as - // virtually read so curr insists on having ownership of it - // whether it ends up writing to it or not. It will always, then, - // appear in curr's out-set. - public Set - calcVirtReadsAndPruneParentAndSiblingTokens( FlatSESEEnterNode exiter, - Set liveVars ) { - - Set virtReadSet = new HashSet(); - - FlatSESEEnterNode parent = exiter.getParent(); - if( parent == null ) { - // having no parent means no siblings, too - return virtReadSet; - } - - Set alternateSESEs = new HashSet(); - alternateSESEs.add( parent ); - Iterator childItr = parent.getChildren().iterator(); - while( childItr.hasNext() ) { - FlatSESEEnterNode sibling = childItr.next(); - if( !sibling.equals( exiter ) ) { - alternateSESEs.add( sibling ); - } - } - - // VSTs to remove if they are alternate sources for exiter VSTs - // whose variables will become virtual reads - Set forRemoval = new HashSet(); - - // look at all of this SESE's VSTs at exit... - Iterator vstItr = get( exiter ).iterator(); - while( vstItr.hasNext() ) { - VariableSourceToken vstExiterSrc = vstItr.next(); - - // only interested in tokens that come from our current instance - if( vstExiterSrc.getAge() != 0 ) { - continue; - } - - // for each variable that might come from those sources... - Iterator refVarItr = vstExiterSrc.getRefVars().iterator(); - while( refVarItr.hasNext() ) { - TempDescriptor refVar = refVarItr.next(); - - // only matters for live variables at SESE exit program point - if( !liveVars.contains( refVar ) ) { - continue; - } - - // examine other sources for a variable... - Iterator srcItr = get( refVar ).iterator(); - while( srcItr.hasNext() ) { - VariableSourceToken vstPossibleOtherSrc = srcItr.next(); - - if( vstPossibleOtherSrc.getSESE().equals( exiter ) && - vstPossibleOtherSrc.getAge() > 0 - ) { - // this is an alternate source if its - // an older instance of this SESE - virtReadSet.add( refVar ); - forRemoval.add( vstPossibleOtherSrc ); - - } else if( alternateSESEs.contains( vstPossibleOtherSrc.getSESE() ) ) { - // this is an alternate source from parent or sibling - virtReadSet.add( refVar ); - forRemoval.add( vstPossibleOtherSrc ); - - } else { - if( !vstPossibleOtherSrc.getSESE().equals( exiter ) || - !vstPossibleOtherSrc.getAge().equals( 0 ) - ) { - System.out.println( "For refVar="+refVar+" at exit of "+exiter+ - ", unexpected possible variable source "+vstPossibleOtherSrc ); - assert false; - } - } - } - } - } - - vstItr = forRemoval.iterator(); - while( vstItr.hasNext() ) { - VariableSourceToken vst = vstItr.next(); - remove( vst ); - } - assertConsistency(); - - return virtReadSet; - } - - - // get the set of VST's that come from a child - public Set getChildrenVSTs( FlatSESEEnterNode curr ) { - - Set out = new HashSet(); - - Iterator cItr = curr.getChildren().iterator(); - while( cItr.hasNext() ) { - FlatSESEEnterNode child = cItr.next(); - out.addAll( get( child ) ); - } - - return out; - } - - - // given a table from a subsequent program point, decide - // which variables are going from a non-dynamic to a - // dynamic source and return them - public Hashtable - getReadyOrStatic2DynamicSet( VarSrcTokTable nextTable, - Set nextLiveIn, - FlatSESEEnterNode current - ) { - - Hashtable out = - new Hashtable(); - - Iterator itr = var2vst.entrySet().iterator(); - while( itr.hasNext() ) { - Map.Entry me = (Map.Entry) itr.next(); - TempDescriptor var = (TempDescriptor) me.getKey(); - HashSet s1 = (HashSet) me.getValue(); - - // only worth tracking if live - if( nextLiveIn.contains( var ) ) { - - VSTWrapper vstIfStaticBefore = new VSTWrapper(); - VSTWrapper vstIfStaticAfter = new VSTWrapper(); - - Integer srcTypeBefore = this.getRefVarSrcType( var, current, vstIfStaticBefore ); - Integer srcTypeAfter = nextTable.getRefVarSrcType( var, current, vstIfStaticAfter ); - - if( !srcTypeBefore.equals( SrcType_DYNAMIC ) && - srcTypeAfter.equals( SrcType_DYNAMIC ) - ) { - // remember the variable and a source - // it had before crossing the transition - // 1) if it was ready, vstIfStatic.vst is null - // 2) if is was static, use vstIfStatic.vst - out.put( var, vstIfStaticBefore ); - } - } - } - - return out; - } - - - // for some reference variable, return the type of source - // it might have in this table, which might be: - // 1. Ready -- this variable is - // definitely available when you are issued. - // 2. Static -- there is definitely one child SESE with - // a known age that will produce the value - // 3. Dynamic -- we don't know where the value will come - // from statically, so we'll track it dynamically - public Integer getRefVarSrcType( TempDescriptor refVar, - FlatSESEEnterNode current, - VSTWrapper vstIfStatic ) { - assert refVar != null; - assert vstIfStatic != null; - - vstIfStatic.vst = null; - - // when the current SESE is null, that simply means it is - // an unknown placeholder, in which case the system will - // ensure that any variables are READY - if( current == null ) { - return SrcType_READY; - } - - // if there appear to be no sources, it means this variable - // comes from outside of any statically-known SESE scope, - // which means the system guarantees its READY, so jump over - // while loop - Set srcs = get( refVar ); - Iterator itrSrcs = srcs.iterator(); - while( itrSrcs.hasNext() ) { - VariableSourceToken vst = itrSrcs.next(); - - // to make the refVar non-READY we have to find at least - // one child token - if( current.getChildren().contains( vst.getSESE() ) ) { - - // if we ever have at least one child source with an - // unknown age, have to treat var as dynamic - if( vst.getAge().equals( MLPAnalysis.maxSESEage ) ) { - return SrcType_DYNAMIC; - } - - // if we have a known-age child source, this var is - // either static or dynamic now: it's static if this - // source is the only source, otherwise dynamic - if( srcs.size() > 1 ) { - return SrcType_DYNAMIC; - } - - vstIfStatic.vst = vst; - return SrcType_STATIC; - } - } - - // if we never found a child source, all other - // sources must be READY before we could even - // begin executing! - return SrcType_READY; - } - - - // any reference variables that are not live can be pruned - // from the table, and if any VSTs are then no longer - // referenced, they can be dropped as well - // THIS CAUSES INCONSISTENCY, FIX LATER, NOT REQUIRED - public void pruneByLiveness( Set rootLiveSet ) { - - // the set of reference variables in the table minus the - // live set gives the set of reference variables to remove - Set deadRefVars = new HashSet(); - deadRefVars.addAll( var2vst.keySet() ); - - if( rootLiveSet != null ) { - deadRefVars.removeAll( rootLiveSet ); - } - - // just use the remove operation to prune the table now - Iterator deadItr = deadRefVars.iterator(); - while( deadItr.hasNext() ) { - TempDescriptor dead = deadItr.next(); - removePrivate( dead ); - } - - assertConsistency(); - } - - - - // use as an aid for debugging, where true-set is checked - // against the alternate mappings: assert that nothing is - // missing or extra in the alternates - public void assertConsistency() { - - Iterator itr; - Set s; - - Set trueSetByAlts = new HashSet(); - itr = sese2vst.entrySet().iterator(); - while( itr.hasNext() ) { - Map.Entry me = (Map.Entry) itr.next(); - FlatSESEEnterNode sese = (FlatSESEEnterNode) me.getKey(); - HashSet s1 = (HashSet) me.getValue(); - assert s1 != null; - - // the trueSet should have all entries in s1 - assert trueSet.containsAll( s1 ); - - // s1 should not have anything that doesn't appear in trueset - Set sInt = (Set) s1.clone(); - sInt.removeAll( trueSet ); - - assert sInt.isEmpty(); - - // add s1 to a running union--at the end check if trueSet has extra - trueSetByAlts.addAll( s1 ); - } - // make sure trueSet isn't too big - assert trueSetByAlts.containsAll( trueSet ); - - - trueSetByAlts = new HashSet(); - itr = var2vst.entrySet().iterator(); - while( itr.hasNext() ) { - Map.Entry me = (Map.Entry) itr.next(); - TempDescriptor var = (TempDescriptor) me.getKey(); - HashSet s1 = (HashSet) me.getValue(); - assert s1 != null; - - // the trueSet should have all entries in s1 - assert trueSet.containsAll( s1 ); - - // s1 should not have anything that doesn't appear in trueset - Set sInt = (Set) s1.clone(); - sInt.removeAll( trueSet ); - - assert sInt.isEmpty(); - - // add s1 to a running union--at the end check if trueSet has extra - trueSetByAlts.addAll( s1 ); - } - // make sure trueSet isn't too big - assert trueSetByAlts.containsAll( trueSet ); - - - trueSetByAlts = new HashSet(); - itr = sv2vst.entrySet().iterator(); - while( itr.hasNext() ) { - Map.Entry me = (Map.Entry) itr.next(); - SVKey key = (SVKey) me.getKey(); - HashSet s1 = (HashSet) me.getValue(); - assert s1 != null; - - // the trueSet should have all entries in s1 - assert trueSet.containsAll( s1 ); - - // s1 should not have anything that doesn't appear in trueset - Set sInt = (Set) s1.clone(); - sInt.removeAll( trueSet ); - - assert sInt.isEmpty(); - - // add s1 to a running union--at the end check if trueSet has extra - trueSetByAlts.addAll( s1 ); - } - // make sure trueSet isn't too big - assert trueSetByAlts.containsAll( trueSet ); - - - // also check that the reference var sets are consistent - Hashtable > vst2refVars = - new Hashtable >(); - itr = var2vst.entrySet().iterator(); - while( itr.hasNext() ) { - Map.Entry me = (Map.Entry) itr.next(); - TempDescriptor refVar = (TempDescriptor) me.getKey(); - HashSet s1 = (HashSet) me.getValue(); - Iterator vstItr = s1.iterator(); - while( vstItr.hasNext() ) { - VariableSourceToken vst = vstItr.next(); - assert vst.getRefVars().contains( refVar ); - - Set refVarsPart = vst2refVars.get( vst ); - if( refVarsPart == null ) { - refVarsPart = new HashSet(); - } - refVarsPart.add( refVar ); - vst2refVars.put( vst, refVarsPart ); - } - } - itr = vst2refVars.entrySet().iterator(); - while( itr.hasNext() ) { - Map.Entry me = (Map.Entry) itr.next(); - VariableSourceToken vst = (VariableSourceToken) me.getKey(); - Set s1 = (Set) me.getValue(); - - assert vst.getRefVars().equals( s1 ); - } - } - - - public boolean equals( Object o ) { - if( o == null ) { - return false; - } - - if( !(o instanceof VarSrcTokTable) ) { - return false; - } - - VarSrcTokTable table = (VarSrcTokTable) o; - return trueSet.equals( table.trueSet ); - } - - public int hashCode() { - return trueSet.hashCode(); - } - - public Iterator iterator() { - return trueSet.iterator(); - } - - public String toString() { - return toStringPretty(); - } - - public String toStringVerbose() { - return "trueSet ="+trueSet.toString()+"\n"+ - "sese2vst="+sese2vst.toString()+"\n"+ - "var2vst ="+var2vst.toString()+"\n"+ - "sv2vst ="+sv2vst.toString(); - } - - public String toStringPretty() { - String tokHighlighter = "o"; - - String str = "VarSrcTokTable\n"; - Iterator vstItr = trueSet.iterator(); - while( vstItr.hasNext() ) { - str += " "+tokHighlighter+" "+vstItr.next()+"\n"; - } - return str; - } - - public String toStringPrettyVerbose() { - String tokHighlighter = "o"; - - String str = "VarSrcTokTable\n"; - - Set s; - Iterator itr; - Iterator vstItr; - - str += " trueSet\n"; - vstItr = trueSet.iterator(); - while( vstItr.hasNext() ) { - str += " "+tokHighlighter+" "+vstItr.next()+"\n"; - } - - str += " sese2vst\n"; - itr = sese2vst.entrySet().iterator(); - while( itr.hasNext() ) { - Map.Entry me = (Map.Entry) itr.next(); - FlatSESEEnterNode sese = (FlatSESEEnterNode) me.getKey(); - HashSet s1 = (HashSet) me.getValue(); - assert s1 != null; - - str += " "+sese.getPrettyIdentifier()+" -> \n"; - - vstItr = s1.iterator(); - while( vstItr.hasNext() ) { - str += " "+tokHighlighter+" "+vstItr.next()+"\n"; - } - } - - str += " var2vst\n"; - itr = var2vst.entrySet().iterator(); - while( itr.hasNext() ) { - Map.Entry me = (Map.Entry) itr.next(); - TempDescriptor var = (TempDescriptor) me.getKey(); - Set s1 = (Set) me.getValue(); - assert s1 != null; - - str += " "+var+" -> \n"; - - vstItr = s1.iterator(); - while( vstItr.hasNext() ) { - str += " "+tokHighlighter+" "+vstItr.next()+"\n"; - } - } - - str += " sv2vst\n"; - itr = sv2vst.entrySet().iterator(); - while( itr.hasNext() ) { - Map.Entry me = (Map.Entry) itr.next(); - SVKey key = (SVKey) me.getKey(); - Set s1 = (Set) me.getValue(); - assert s1 != null; - - str += " "+key+" -> \n"; - - vstItr = s1.iterator(); - while( vstItr.hasNext() ) { - str += " "+tokHighlighter+" "+vstItr.next()+"\n"; - } - } - - return str; - } -} diff --git a/Robust/src/Analysis/MLP/VariableSourceToken.java b/Robust/src/Analysis/MLP/VariableSourceToken.java deleted file mode 100644 index b34b88c7..00000000 --- a/Robust/src/Analysis/MLP/VariableSourceToken.java +++ /dev/null @@ -1,82 +0,0 @@ -package Analysis.MLP; - -import IR.*; -import IR.Flat.*; -import java.util.*; -import java.io.*; - -public class VariableSourceToken { - - private Set refVars; - private FlatSESEEnterNode sese; - private Integer seseAge; - private TempDescriptor addrVar; - - public VariableSourceToken( Set refVars, - FlatSESEEnterNode sese, - Integer seseAge, - TempDescriptor addrVar - ) { - this.refVars = refVars; - this.sese = sese; - this.seseAge = seseAge; - this.addrVar = addrVar; - } - - public Set getRefVars() { - return refVars; - } - - public FlatSESEEnterNode getSESE() { - return sese; - } - - public Integer getAge() { - return seseAge; - } - - public TempDescriptor getAddrVar() { - return addrVar; - } - - public VariableSourceToken copy() { - Set refVarsCopy = new HashSet(); - - Iterator rvItr = refVars.iterator(); - while( rvItr.hasNext() ) { - refVarsCopy.add( rvItr.next() ); - } - - return new VariableSourceToken( refVarsCopy, - sese, - new Integer( seseAge ), - addrVar ); - } - - public boolean equals( Object o ) { - if( o == null ) { - return false; - } - - if( !(o instanceof VariableSourceToken) ) { - return false; - } - - VariableSourceToken vst = (VariableSourceToken) o; - - // the reference vars have no bearing on equality - return sese.equals( vst.sese ) && - addrVar.equals( vst.addrVar ) && - seseAge.equals( vst.seseAge ); - } - - public int hashCode() { - // the reference vars have no bearing on hashCode - return (sese.hashCode() << 3) * (addrVar.hashCode() << 4) ^ seseAge.intValue(); - } - - - public String toString() { - return refVars+"\tref "+addrVar+"\t@"+sese.toPrettyString()+"("+seseAge+")"; - } -} diff --git a/Robust/src/Analysis/MLP/WaitingElement.java b/Robust/src/Analysis/MLP/WaitingElement.java deleted file mode 100644 index 3e9f39a8..00000000 --- a/Robust/src/Analysis/MLP/WaitingElement.java +++ /dev/null @@ -1,86 +0,0 @@ -package Analysis.MLP; - -import java.util.HashSet; -import java.util.Iterator; - -import IR.Flat.TempDescriptor; - -public class WaitingElement { - - private int queueID; - private int status; - private String dynID=""; - private TempDescriptor tempDesc; - - public void setTempDesc(TempDescriptor tempDesc){ - this.tempDesc=tempDesc; - } - - public TempDescriptor getTempDesc(){ - return tempDesc; - } - - public void setQueueID(int queueID) { - this.queueID = queueID; - } - - public String getDynID(){ - return dynID; - } - - public void setDynID(String dynID){ - this.dynID=dynID; - } - - public int getQueueID() { - return queueID; - } - - public void setStatus(int status) { - this.status = status; - } - - public int getStatus() { - return status; - } - - public boolean equals(Object o) { - - if (o == null) { - return false; - } - - if (!(o instanceof WaitingElement)) { - return false; - } - - WaitingElement in = (WaitingElement) o; - - if (queueID == in.getQueueID() && status == in.getStatus() && dynID.equals(in.getDynID()) ) { - return true; - } else { - return false; - } - - } - - public String toString() { - return "[waitingID=" + queueID + " status=" + status + " dynID=" - + dynID + "]"; - } - - public int hashCode() { - - int hash = 1; - - hash = hash * 31 + queueID; - - hash += status; - - hash += dynID.hashCode(); - - return hash; - - } - -} \ No newline at end of file diff --git a/Robust/src/Analysis/OoOJava/CodePlan.java b/Robust/src/Analysis/OoOJava/CodePlan.java new file mode 100644 index 00000000..efb82ca0 --- /dev/null +++ b/Robust/src/Analysis/OoOJava/CodePlan.java @@ -0,0 +1,108 @@ +package Analysis.OoOJava; + +import IR.*; +import IR.Flat.*; +import java.util.*; +import java.io.*; + + +// a code plan contains information based on analysis results +// for injecting code before and/or after a flat node +public class CodePlan { + + private Hashtable< VariableSourceToken, Set > stall2copySet; + private Set dynamicStallSet; + private Hashtable dynAssign_lhs2rhs; + private Set dynAssign_lhs2curr; + private FlatSESEEnterNode currentSESE; + + public CodePlan( FlatSESEEnterNode fsen ) { + stall2copySet = new Hashtable< VariableSourceToken, Set >(); + dynamicStallSet = new HashSet(); + dynAssign_lhs2rhs = new Hashtable(); + dynAssign_lhs2curr = new HashSet(); + currentSESE = fsen; + } + + public FlatSESEEnterNode getCurrentSESE() { + return currentSESE; + } + + public void addStall2CopySet( VariableSourceToken stallToken, + Set copySet ) { + + if( stall2copySet.containsKey( stallToken ) ) { + Set priorCopySet = stall2copySet.get( stallToken ); + priorCopySet.addAll( copySet ); + } else { + stall2copySet.put( stallToken, copySet ); + } + } + + public Set getStallTokens() { + return stall2copySet.keySet(); + } + + public Set getCopySet( VariableSourceToken stallToken ) { + return stall2copySet.get( stallToken ); + } + + + public void addDynamicStall( TempDescriptor var ) { + dynamicStallSet.add( var ); + } + + public Set getDynamicStallSet() { + return dynamicStallSet; + } + + public void addDynAssign( TempDescriptor lhs, + TempDescriptor rhs ) { + dynAssign_lhs2rhs.put( lhs, rhs ); + } + + public Hashtable getDynAssigns() { + return dynAssign_lhs2rhs; + } + + public void addDynAssign( TempDescriptor lhs ) { + dynAssign_lhs2curr.add( lhs ); + } + + public Set getDynAssignCurr() { + return dynAssign_lhs2curr; + } + + public String toString() { + String s = " PLAN: "; + + if( !stall2copySet.entrySet().isEmpty() ) { + s += "[STATIC STALLS:"; + } + Iterator cpsItr = stall2copySet.entrySet().iterator(); + while( cpsItr.hasNext() ) { + Map.Entry me = (Map.Entry) cpsItr.next(); + VariableSourceToken stallToken = (VariableSourceToken) me.getKey(); + Set copySet = (Set) me.getValue(); + + s += "("+stallToken+"->"+copySet+")"; + } + if( !stall2copySet.entrySet().isEmpty() ) { + s += "]"; + } + + if( !dynamicStallSet.isEmpty() ) { + s += "[DYN STALLS:"+dynamicStallSet+"]"; + } + + if( !dynAssign_lhs2rhs.isEmpty() ) { + s += "[DYN ASSIGNS:"+dynAssign_lhs2rhs+"]"; + } + + if( !dynAssign_lhs2curr.isEmpty() ) { + s += "[DYN ASS2CURR:"+dynAssign_lhs2curr+"]"; + } + + return s; + } +} diff --git a/Robust/src/Analysis/OoOJava/OoOJavaAnalysis.java b/Robust/src/Analysis/OoOJava/OoOJavaAnalysis.java index 46d7464a..b5da9306 100644 --- a/Robust/src/Analysis/OoOJava/OoOJavaAnalysis.java +++ b/Robust/src/Analysis/OoOJava/OoOJavaAnalysis.java @@ -19,11 +19,6 @@ import Analysis.Disjoint.DisjointAnalysis; import Analysis.Disjoint.Effect; import Analysis.Disjoint.EffectsAnalysis; import Analysis.Disjoint.Taint; -import Analysis.MLP.CodePlan; -import Analysis.MLP.SESEandAgePair; -import Analysis.MLP.VSTWrapper; -import Analysis.MLP.VarSrcTokTable; -import Analysis.MLP.VariableSourceToken; import IR.Descriptor; import IR.MethodDescriptor; import IR.Operation; @@ -52,11 +47,12 @@ public class OoOJavaAnalysis { private TypeUtil typeUtil; private CallGraph callGraph; private RBlockRelationAnalysis rblockRel; - private RBlockStatusAnalysis rblockStatus; private DisjointAnalysis disjointAnalysisTaints; private DisjointAnalysis disjointAnalysisReach; - private Hashtable> livenessRootView; + private Set descriptorsToAnalyze; + + private Hashtable> livenessGlobalView; private Hashtable> livenessVirtualReads; private Hashtable variableResults; private Hashtable> notAvailableResults; @@ -89,26 +85,27 @@ public class OoOJavaAnalysis { return codePlans.keySet(); } - public OoOJavaAnalysis(State state, TypeUtil typeUtil, CallGraph callGraph, Liveness liveness, - ArrayReferencees arrayReferencees) { + public OoOJavaAnalysis(State state, + TypeUtil typeUtil, + CallGraph callGraph, + Liveness liveness, + ArrayReferencees arrayReferencees) { double timeStartAnalysis = (double) System.nanoTime(); this.state = state; this.typeUtil = typeUtil; this.callGraph = callGraph; - this.maxSESEage = state.MLP_MAXSESEAGE; - - livenessRootView = new Hashtable>(); - livenessVirtualReads = new Hashtable>(); - variableResults = new Hashtable(); - notAvailableResults = new Hashtable>(); - codePlans = new Hashtable(); - wdvNodesToSpliceIn = new Hashtable(); - - notAvailableIntoSESE = new Hashtable>(); - - sese2conflictGraph = new Hashtable(); + 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(); conflictGraph2SESELock = new Hashtable>(); // add all methods transitively reachable from the @@ -116,23 +113,27 @@ public class OoOJavaAnalysis { MethodDescriptor mdSourceEntry = typeUtil.getMain(); FlatMethod fmMain = state.getMethodFlat(mdSourceEntry); - Set descriptorsToAnalyze = callGraph.getAllMethods(mdSourceEntry); + descriptorsToAnalyze = callGraph.getAllMethods(mdSourceEntry); descriptorsToAnalyze.add(mdSourceEntry); - // 1st pass, find basic rblock relations & status + // 1st pass, find basic rblock relations & potential stall sites rblockRel = new RBlockRelationAnalysis(state, typeUtil, callGraph); - rblockStatus = new RBlockStatusAnalysis(state, typeUtil, callGraph, rblockRel); // 2nd pass, liveness, in-set out-set (no virtual reads yet!) - Iterator rootItr = rblockRel.getRootSESEs().iterator(); - while (rootItr.hasNext()) { - FlatSESEEnterNode root = rootItr.next(); - livenessAnalysisBackward(root, true, null); + Iterator methItr = descriptorsToAnalyze.iterator(); + while (methItr.hasNext()) { + Descriptor d = methItr.next(); + FlatMethod fm = state.getMethodFlat(d); + + // note we can't use the general liveness analysis already in + // the compiler because this analysis is task-aware + livenessAnalysisBackward(fm); } + /* // 3rd pass, variable analysis - Iterator methItr = descriptorsToAnalyze.iterator(); + methItr = descriptorsToAnalyze.iterator(); while (methItr.hasNext()) { Descriptor d = methItr.next(); FlatMethod fm = state.getMethodFlat(d); @@ -144,17 +145,18 @@ public class OoOJavaAnalysis { // 4th pass, compute liveness contribution from // virtual reads discovered in variable pass - rootItr = rblockRel.getRootSESEs().iterator(); - while (rootItr.hasNext()) { - FlatSESEEnterNode root = rootItr.next(); - livenessAnalysisBackward(root, true, null); + methItr = descriptorsToAnalyze.iterator(); + while (methItr.hasNext()) { + Descriptor d = methItr.next(); + FlatMethod fm = state.getMethodFlat(d); + livenessAnalysisBackward(fm); } // 5th pass, use disjointness with NO FLAGGED REGIONS // to compute taints and effects disjointAnalysisTaints = new DisjointAnalysis(state, typeUtil, callGraph, liveness, arrayReferencees, null, - rblockRel, rblockStatus, + rblockRel, true ); // suppress output--this is an intermediate pass // 6th pass, not available analysis FOR VARIABLES! @@ -176,14 +178,14 @@ public class OoOJavaAnalysis { FlatSESEEnterNode parent = (FlatSESEEnterNode) iterator.next(); if (!parent.getIsLeafSESE()) { - + EffectsAnalysis effectsAnalysis = disjointAnalysisTaints.getEffectsAnalysis(); ConflictGraph conflictGraph = sese2conflictGraph.get(parent); if (conflictGraph == null) { conflictGraph = new ConflictGraph(state); } - Set children = parent.getSESEChildren(); + Set children = parent.getChildren(); for (Iterator iterator2 = children.iterator(); iterator2.hasNext();) { FlatSESEEnterNode child = (FlatSESEEnterNode) iterator2.next(); Hashtable> taint2Effects = effectsAnalysis.get(child); @@ -193,29 +195,14 @@ public class OoOJavaAnalysis { } } - Iterator descItr = disjointAnalysisTaints.getDescriptorsToAnalyze().iterator(); + Iterator descItr = descriptorsToAnalyze.iterator(); while (descItr.hasNext()) { Descriptor d = (Descriptor) descItr.next(); FlatMethod fm = state.getMethodFlat(d); if (fm != null) makeConflictGraph(fm); - } - - + } - // 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()); } } - */ // 8th pass, calculate all possible conflicts without using reachability // info @@ -232,7 +219,6 @@ public class OoOJavaAnalysis { // 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 @@ -258,17 +244,45 @@ public class OoOJavaAnalysis { FlatWriteDynamicVarNode fwdvn = (FlatWriteDynamicVarNode) me.getValue(); fwdvn.spliceIntoIR(); } + */ + /* if (state.OOODEBUG) { try { writeReports(""); disjointAnalysisTaints.getEffectsAnalysis().writeEffects("effects.txt"); writeConflictGraph(); - } catch (IOException e) { - } + } catch (IOException e) {} } - + */ + + System.out.println("\n\n\n##########################################################\n"+ + "Warning, lots of code changes going on, OoOJava and RCR/DFJ\n"+ + "systems are being cleaned up. Until the analyses and code gen\n"+ + "are fully altered and coordinated, these systems will not run\n"+ + "to completion. Partial stable check-ins are necessary to manage\n"+ + "the number of files getting touched.\n"+ + "##########################################################" ); + System.exit( 0 ); } + + + + // 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) { @@ -287,129 +301,97 @@ public class OoOJavaAnalysis { } - private void livenessAnalysisBackward(FlatSESEEnterNode fsen, boolean toplevel, - Hashtable> liveout) { - - // start from an SESE exit, visit nodes in reverse up to - // SESE enter in a fixed-point scheme, where children SESEs - // should already be analyzed and therefore can be skipped - // because child SESE enter node has all necessary info - Set flatNodesToVisit = new HashSet(); - - if (toplevel) { - flatNodesToVisit.add(fsen.getfmEnclosing().getFlatExit()); - } else { - flatNodesToVisit.add(fsen.getFlatExit()); - } - Hashtable> livenessResults = - new Hashtable>(); + private void livenessAnalysisBackward(FlatMethod fm) { - if (toplevel) { - liveout = new Hashtable>(); - } + // 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() ); - while (!flatNodesToVisit.isEmpty()) { + while( !flatNodesToVisit.isEmpty() ) { FlatNode fn = (FlatNode) flatNodesToVisit.iterator().next(); - flatNodesToVisit.remove(fn); + flatNodesToVisit.remove( fn ); - Set prev = livenessResults.get(fn); + Set prev = livenessGlobalView.get( fn ); // merge sets from control flow joins - Set u = new HashSet(); + Set livein = new HashSet(); for (int i = 0; i < fn.numNext(); i++) { - FlatNode nn = fn.getNext(i); - Set s = livenessResults.get(nn); - if (s != null) { - u.addAll(s); + FlatNode nn = fn.getNext( i ); + Set s = livenessGlobalView.get( nn ); + if( s != null ) { + livein.addAll( s ); } } - - Set curr = liveness_nodeActions(fn, u, fsen, toplevel, liveout); + + Set curr = liveness_nodeActions( fn, livein ); // if a new result, schedule backward nodes for analysis - if (!curr.equals(prev)) { - livenessResults.put(fn, curr); + if( !curr.equals( prev ) ) { + livenessGlobalView.put( fn, curr ); - // don't flow backwards past current SESE enter - if (!fn.equals(fsen)) { - for (int i = 0; i < fn.numPrev(); i++) { - FlatNode nn = fn.getPrev(i); - flatNodesToVisit.add(nn); - } + for( int i = 0; i < fn.numPrev(); i++ ) { + FlatNode nn = fn.getPrev( i ); + flatNodesToVisit.add( nn ); } } } - - Set s = livenessResults.get(fsen); - if (s != null) { - fsen.addInVarSet(s); - } - - // remember liveness per node from the root view as the - // global liveness of variables for later passes to use - if (toplevel) { - livenessRootView.putAll(livenessResults); - } - - // post-order traversal, so do children first - Iterator childItr = fsen.getChildren().iterator(); - while (childItr.hasNext()) { - FlatSESEEnterNode fsenChild = childItr.next(); - livenessAnalysisBackward(fsenChild, false, liveout); - } } - private Set liveness_nodeActions(FlatNode fn, Set liveIn, - FlatSESEEnterNode currentSESE, boolean toplevel, - Hashtable> liveout) { - switch (fn.kind()) { + private Set liveness_nodeActions( FlatNode fn, + Set liveIn + ) { + switch( fn.kind() ) { - case FKind.FlatSESEExitNode: - if (toplevel) { - FlatSESEExitNode fsexn = (FlatSESEExitNode) fn; - if (!liveout.containsKey(fsexn)) { - liveout.put(fsexn, new HashSet()); - } - liveout.get(fsexn).addAll(liveIn); + 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 ); } - // no break, sese exits should also execute default actions + // no break, should also execute default actions + } 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]); - - if (!toplevel) { - FlatSESEExitNode fsexn = currentSESE.getFlatExit(); - Set livetemps = liveout.get(fsexn); - if (livetemps != null && livetemps.contains(writeTemps[i])) { - // write to a live out temp... - // need to put in SESE liveout set - currentSESE.addOutVar(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 ) { + // 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(); + Set livetemps = livenessGlobalView.get( 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]); - } - - Set virtualReadTemps = livenessVirtualReads.get(fn); - if (virtualReadTemps != null) { - liveIn.addAll(virtualReadTemps); + for( int i = 0; i < readTemps.length; ++i ) { + liveIn.add( readTemps[i] ); } - } - 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(); @@ -419,9 +401,6 @@ public class OoOJavaAnalysis { FlatNode fn = (FlatNode) flatNodesToVisit.iterator().next(); flatNodesToVisit.remove(fn); - Stack seseStack = rblockRel.getRBlockStacks(fm, fn); - assert seseStack != null; - VarSrcTokTable prev = variableResults.get(fn); // merge sets from control flow joins @@ -432,8 +411,11 @@ public class OoOJavaAnalysis { curr.merge(incoming); } - if (!seseStack.empty()) { - variable_nodeActions(fn, curr, seseStack.peek()); + Set possiblyExecuting = + rblockRel.getPossibleExecutingRBlocks( fn ); + + if (!possiblyExecuting.isEmpty()) { + variable_nodeActions(fn, curr, possiblyExecuting); } // if a new result, schedule forward nodes for analysis @@ -448,23 +430,25 @@ public class OoOJavaAnalysis { } } - private void variable_nodeActions(FlatNode fn, VarSrcTokTable vstTable, - FlatSESEEnterNode currentSESE) { + private void variable_nodeActions(FlatNode fn, + VarSrcTokTable vstTable, + Set currentSESEs) { switch (fn.kind()) { case FKind.FlatSESEEnterNode: { FlatSESEEnterNode fsen = (FlatSESEEnterNode) fn; - assert fsen.equals(currentSESE); - - vstTable.age(currentSESE); + // ignore currently executing SESEs, at this point + // the analysis considers a new instance is becoming + // the current SESE + vstTable.age(fsen); vstTable.assertConsistency(); - } - break; + } break; case FKind.FlatSESEExitNode: { FlatSESEExitNode fsexn = (FlatSESEExitNode) fn; + + // fsen is the child of currently executing tasks FlatSESEEnterNode fsen = fsexn.getFlatEnter(); - assert currentSESE.getChildren().contains(fsen); // remap all of this child's children tokens to be // from this child as the child exits @@ -474,9 +458,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 = livenessRootView.get(fn); + Set liveVars = livenessGlobalView.get(fn); Set fsenVirtReads = - vstTable.calcVirtReadsAndPruneParentAndSiblingTokens(fsen, liveVars); + vstTable.calcVirtReadsAndPruneParentAndSiblingTokens(fsen, liveVars); + Set fsenVirtReadsOld = livenessVirtualReads.get(fn); if (fsenVirtReadsOld != null) { fsenVirtReads.addAll(fsenVirtReadsOld); @@ -496,9 +481,7 @@ public class OoOJavaAnalysis { vstTable.add(vst); } vstTable.assertConsistency(); - - } - break; + } break; case FKind.FlatOpNode: { FlatOpNode fon = (FlatOpNode) fn; @@ -518,14 +501,17 @@ public class OoOJavaAnalysis { HashSet ts = new HashSet(); ts.add(lhs); + ///////////////// TODO !!!!!!!!!!!!!!!!!//////////////// + // @$@$@$@$#%@%$^@%^@$&@#$^&%&*$&*(%^*(%^*()%^*() + /* if (currentSESE.getChildren().contains(vst.getSESE())) { // 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)); } + */ } vstTable.addAll(forAddition); @@ -557,7 +543,9 @@ public class OoOJavaAnalysis { HashSet ts = new HashSet(); ts.add(writeTemps[0]); - vstTable.add(new VariableSourceToken(ts, currentSESE, new Integer(0), writeTemps[0])); + ///////////////// TODO !!!!!!!!!!!!!!!!!//////////////// + // @$@$@$@$#%@%$^@%^@$&@#$^&%&*$&*(%^*(%^*()%^*() + //vstTable.add(new VariableSourceToken(ts, currentSESE, new Integer(0), writeTemps[0])); } vstTable.assertConsistency(); @@ -576,7 +564,7 @@ public class OoOJavaAnalysis { FlatNode fn = (FlatNode) flatNodesToVisit.iterator().next(); flatNodesToVisit.remove(fn); - Stack seseStack = rblockRel.getRBlockStacks(fm, fn); + Stack seseStack = null; //rblockRel.getRBlockStacks(fm, fn); assert seseStack != null; Set prev = notAvailableResults.get(fn); @@ -739,7 +727,7 @@ public class OoOJavaAnalysis { flatNodesToVisit.remove(fn); visited.add(fn); - Stack seseStack = rblockRel.getRBlockStacks(fm, fn); + Stack seseStack = null; //rblockRel.getRBlockStacks(fm, fn); assert seseStack != null; // use incoming results as "dot statement" or just @@ -760,7 +748,7 @@ public class OoOJavaAnalysis { } } - Set dotSTlive = livenessRootView.get(fn); + Set dotSTlive = livenessGlobalView.get(fn); if (!seseStack.empty()) { codePlans_nodeActions(fn, dotSTlive, dotSTtable, dotSTnotAvailSet, seseStack.peek()); @@ -801,13 +789,13 @@ public class OoOJavaAnalysis { // the parent SESE in--at other FlatNode types just // use the currentSESE VSTWrapper vstIfStatic = new VSTWrapper(); - Integer srcType = vstTableIn.getRefVarSrcType(inVar, fsen.getParent(), vstIfStatic); + Integer srcType = null; //vstTableIn.getRefVarSrcType(inVar, fsen.getParent(), vstIfStatic); // the current SESE needs a local space to track the dynamic // variable and the child needs space in its SESE record if (srcType.equals(VarSrcTokTable.SrcType_DYNAMIC)) { fsen.addDynamicInVar(inVar); - fsen.getParent().addDynamicVar(inVar); + // %@%@%@%@%@%@%@% TODO!!!! @%@%@%@%@% fsen.getParent().addDynamicVar(inVar); } else if (srcType.equals(VarSrcTokTable.SrcType_STATIC)) { fsen.addStaticInVar(inVar); @@ -948,16 +936,16 @@ public class OoOJavaAnalysis { // placeholder source tokens are useful results, but // the placeholder static name is never needed - if (vst.getSESE().getIsCallerSESEplaceholder()) { - continue; - } + //if (vst.getSESE().getIsCallerSESEplaceholder()) { + // continue; + //} FlatSESEEnterNode sese = currentSESE; while (sese != null) { sese.addNeededStaticName(new SESEandAgePair(vst.getSESE(), vst.getAge())); sese.mustTrackAtLeastAge(vst.getAge()); - sese = sese.getParent(); + //@%@%@%@%@%@% TODO!!!!! @%@%@%@%@%@% sese = sese.getParent(); } } @@ -971,7 +959,7 @@ public class OoOJavaAnalysis { for (int i = 0; i < fn.numNext(); i++) { FlatNode nn = fn.getNext(i); VarSrcTokTable nextVstTable = variableResults.get(nn); - Set nextLiveIn = livenessRootView.get(nn); + Set nextLiveIn = livenessGlobalView.get(nn); // the table can be null if it is one of the few IR nodes // completely outside of the root SESE scope @@ -1000,6 +988,8 @@ public class OoOJavaAnalysis { private void makeConflictGraph(FlatMethod fm) { + System.out.println( "Creating conflict graph for "+fm ); + Set flatNodesToVisit = new HashSet(); flatNodesToVisit.add(fm); @@ -1010,7 +1000,7 @@ public class OoOJavaAnalysis { flatNodesToVisit.remove(fn); visited.add(fn); - Stack seseStack = rblockRel.getRBlockStacks(fm, fn); + Stack seseStack = null; //rblockRel.getRBlockStacks(fm, fn); assert seseStack != null; if (!seseStack.isEmpty()) { @@ -1037,8 +1027,10 @@ public class OoOJavaAnalysis { EffectsAnalysis effectsAnalysis = disjointAnalysisTaints.getEffectsAnalysis(); + switch (fn.kind()) { + case FKind.FlatFieldNode: case FKind.FlatElementNode: { @@ -1050,40 +1042,20 @@ public class OoOJavaAnalysis { rhs = fen.getSrc(); } - // jjenista - I think the following code is WRONG!!! - // We are looking at some non-task FlatNode fn that is a stall site and - // considering what conflicts it might have with CHILDREN of the CURRENT TASK - // that contains fn. WE SHOULD NOT BE GETTING THE PARENT OF currentSESE - // because in this scenario currentSESE IS the parent in relation to other - // tasks that might conflict with this fn. - // OK, why not fix it? Because code all over the place is built on - // being able to retrieve the correct conflict graph, which is associated - // with the wrong task, but at least consistently, SO LEAVE IT BUT REALIZE - // WHAT IS HAPPENING - - Set parentSet = currentSESE.getSESEParent(); - for (Iterator iterator = parentSet.iterator(); iterator.hasNext();) { - FlatSESEEnterNode parent = (FlatSESEEnterNode) iterator.next(); -// System.out.println("##current="+currentSESE.getmdEnclosing()+" PARENT=" + parent); - conflictGraph = sese2conflictGraph.get(parent); - if (conflictGraph == null) { - conflictGraph = new ConflictGraph(state); - } + conflictGraph = sese2conflictGraph.get(currentSESE); + if (conflictGraph == null) { + conflictGraph = new ConflictGraph(state); + } - // add stall site - Hashtable> taint2Effects = effectsAnalysis.get(fn); - conflictGraph.addStallSite(taint2Effects, rhs); - if (taint2Effects != null) -// System.out.println("add =" + taint2Effects + "currentSESE=" + parent -// + " into conflictGraph=" + conflictGraph); + // add stall site + Hashtable> taint2Effects = effectsAnalysis.get(fn); + conflictGraph.addStallSite(taint2Effects, rhs); - if (conflictGraph.id2cn.size() > 0) { - sese2conflictGraph.put(parent, conflictGraph); - } + if (conflictGraph.id2cn.size() > 0) { + sese2conflictGraph.put(currentSESE, conflictGraph); } + } break; - } - break; case FKind.FlatSetFieldNode: case FKind.FlatSetElementNode: { @@ -1098,37 +1070,19 @@ public class OoOJavaAnalysis { rhs = fsen.getSrc(); } - // jjenista - I think the following code is WRONG!!! - // We are looking at some non-task FlatNode fn that is a stall site and - // considering what conflicts it might have with CHILDREN of the CURRENT TASK - // that contains fn. WE SHOULD NOT BE GETTING THE PARENT OF currentSESE - // because in this scenario currentSESE IS the parent in relation to other - // tasks that might conflict with this fn. - // OK, why not fix it? Because code all over the place is built on - // being able to retrieve the correct conflict graph, which is associated - // with the wrong task, but at least consistently, SO LEAVE IT BUT REALIZE - // WHAT IS HAPPENING - - // collects effects of stall site and generates stall site node - Set parentSet = currentSESE.getSESEParent(); - for (Iterator iterator = parentSet.iterator(); iterator.hasNext();) { - FlatSESEEnterNode parent = (FlatSESEEnterNode) iterator.next(); - conflictGraph = sese2conflictGraph.get(parent); - if (conflictGraph == null) { - conflictGraph = new ConflictGraph(state); - } + conflictGraph = sese2conflictGraph.get(currentSESE); + if (conflictGraph == null) { + conflictGraph = new ConflictGraph(state); + } - Hashtable> taint2Effects = effectsAnalysis.get(fn); - conflictGraph.addStallSite(taint2Effects, rhs); - conflictGraph.addStallSite(taint2Effects, lhs); + Hashtable> taint2Effects = effectsAnalysis.get(fn); + conflictGraph.addStallSite(taint2Effects, rhs); + conflictGraph.addStallSite(taint2Effects, lhs); - if (conflictGraph.id2cn.size() > 0) { - sese2conflictGraph.put(parent, conflictGraph); - } + if (conflictGraph.id2cn.size() > 0) { + sese2conflictGraph.put(currentSESE, conflictGraph); } - - } - break; + } break; case FKind.FlatCall: { conflictGraph = sese2conflictGraph.get(currentSESE); @@ -1142,40 +1096,17 @@ public class OoOJavaAnalysis { // collects effects of stall site and generates stall site node Hashtable> taint2Effects = effectsAnalysis.get(fn); - // jjenista - I think the following code is WRONG!!! - // We are looking at some non-task FlatNode fn that is a stall site and - // considering what conflicts it might have with CHILDREN of the CURRENT TASK - // that contains fn. WE SHOULD NOT BE GETTING THE PARENT OF currentSESE - // because in this scenario currentSESE IS the parent in relation to other - // tasks that might conflict with this fn. - // OK, why not fix it? Because code all over the place is built on - // being able to retrieve the correct conflict graph, which is associated - // with the wrong task, but at least consistently, SO LEAVE IT BUT REALIZE - // WHAT IS HAPPENING - - Set parentSet = currentSESE.getSESEParent(); - for (Iterator iterator = parentSet.iterator(); iterator.hasNext();) { - FlatSESEEnterNode parent = (FlatSESEEnterNode) iterator.next(); - conflictGraph = sese2conflictGraph.get(parent); - if (conflictGraph == null) { - conflictGraph = new ConflictGraph(state); - } - - conflictGraph.addStallSite(taint2Effects, lhs); - if (conflictGraph.id2cn.size() > 0) { - sese2conflictGraph.put(parent, conflictGraph); - } - - } - - } + conflictGraph.addStallSite(taint2Effects, lhs); + if (conflictGraph.id2cn.size() > 0) { + sese2conflictGraph.put(currentSESE, conflictGraph); + } + } break; - break; } - } + private void calculateConflicts(Set sitesToFlag, boolean useReachInfo) { // decide fine-grain edge or coarse-grain edge among all vertexes by // pair-wise comparison @@ -1524,6 +1455,7 @@ public class OoOJavaAnalysis { return rblockRel.getMainSESE(); } + public void writeReports(String timeReport) throws java.io.IOException { BufferedWriter bw = new BufferedWriter(new FileWriter("mlpReport_summary.txt")); @@ -1534,24 +1466,25 @@ public class OoOJavaAnalysis { printSESEInfo(bw); bw.close(); - Iterator methItr = disjointAnalysisTaints.getDescriptorsToAnalyze().iterator(); + Iterator methItr = descriptorsToAnalyze.iterator(); while (methItr.hasNext()) { - MethodDescriptor md = (MethodDescriptor) methItr.next(); + MethodDescriptor md = methItr.next(); FlatMethod fm = state.getMethodFlat(md); if (fm != null) { - bw = - new BufferedWriter(new FileWriter("mlpReport_" + md.getClassMethodName() - + md.getSafeMethodDescriptor() + ".txt")); - bw.write("MLP Results for " + md + "\n-------------------\n"); + bw = new BufferedWriter(new FileWriter("ooojReport_" + + md.getClassMethodName() + + md.getSafeMethodDescriptor() + + ".txt")); + bw.write("OoOJava Results for " + md + "\n-------------------\n"); FlatSESEEnterNode implicitSESE = (FlatSESEEnterNode) fm.getNext(0); - if (!implicitSESE.getIsCallerSESEplaceholder() && implicitSESE != rblockRel.getMainSESE()) { - System.out.println(implicitSESE + " is not implicit?!"); - System.exit(-1); - } + //if (!implicitSESE.getIsCallerSESEplaceholder() && implicitSESE != rblockRel.getMainSESE()) { + // System.out.println(implicitSESE + " is not implicit?!"); + // System.exit(-1); + //} bw.write("Dynamic vars to manage:\n " + implicitSESE.getDynamicVarSet()); - bw.write("\n\nLive-In, Root View\n------------------\n" + fm.printMethod(livenessRootView)); + 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)); @@ -1563,16 +1496,16 @@ public class OoOJavaAnalysis { private void printSESEHierarchy(BufferedWriter bw) throws java.io.IOException { bw.write("SESE Hierarchy\n--------------\n"); - Iterator rootItr = rblockRel.getRootSESEs().iterator(); + Iterator rootItr = rblockRel.getAllSESEs().iterator(); while (rootItr.hasNext()) { FlatSESEEnterNode root = rootItr.next(); - if (root.getIsCallerSESEplaceholder()) { - if (!root.getChildren().isEmpty()) { - printSESEHierarchyTree(bw, root, 0); - } - } else { + //if (root.getIsCallerSESEplaceholder()) { + // if (!root.getChildren().isEmpty()) { + // printSESEHierarchyTree(bw, root, 0); + // } + //} else { printSESEHierarchyTree(bw, root, 0); - } + //} } } @@ -1592,16 +1525,16 @@ public class OoOJavaAnalysis { private void printSESEInfo(BufferedWriter bw) throws java.io.IOException { bw.write("\nSESE info\n-------------\n"); - Iterator rootItr = rblockRel.getRootSESEs().iterator(); + Iterator rootItr = null; //rblockRel.getRootSESEs().iterator(); while (rootItr.hasNext()) { FlatSESEEnterNode root = rootItr.next(); - if (root.getIsCallerSESEplaceholder()) { - if (!root.getChildren().isEmpty()) { - printSESEInfoTree(bw, root); - } - } else { + //if (root.getIsCallerSESEplaceholder()) { + // if (!root.getChildren().isEmpty()) { + // printSESEInfoTree(bw, root); + // } + //} else { printSESEInfoTree(bw, root); - } + //} } } @@ -1612,33 +1545,31 @@ public class OoOJavaAnalysis { private void printSESEInfoTree(BufferedWriter bw, FlatSESEEnterNode fsen) throws java.io.IOException { - if (!fsen.getIsCallerSESEplaceholder()) { - bw.write("SESE " + fsen.getPrettyIdentifier()); - if( fsen.getIsLeafSESE() ) { - bw.write(" (leaf)"); + bw.write("SESE " + fsen.getPrettyIdentifier()); + if( fsen.getIsLeafSESE() ) { + bw.write(" (leaf)"); + } + bw.write(" {\n"); + + bw.write(" in-set: " + fsen.getInVarSet() + "\n"); + Iterator tItr = fsen.getInVarSet().iterator(); + while (tItr.hasNext()) { + TempDescriptor inVar = tItr.next(); + if (fsen.getReadyInVarSet().contains(inVar)) { + bw.write(" (ready) " + inVar + "\n"); } - bw.write(" {\n"); - - bw.write(" in-set: " + fsen.getInVarSet() + "\n"); - Iterator tItr = fsen.getInVarSet().iterator(); - while (tItr.hasNext()) { - TempDescriptor inVar = tItr.next(); - if (fsen.getReadyInVarSet().contains(inVar)) { - bw.write(" (ready) " + inVar + "\n"); - } - if (fsen.getStaticInVarSet().contains(inVar)) { - bw.write(" (static) " + inVar + " from " + fsen.getStaticInVarSrc(inVar) + "\n"); - } - if (fsen.getDynamicInVarSet().contains(inVar)) { - bw.write(" (dynamic)" + inVar + "\n"); - } + if (fsen.getStaticInVarSet().contains(inVar)) { + bw.write(" (static) " + inVar + " from " + fsen.getStaticInVarSrc(inVar) + "\n"); + } + if (fsen.getDynamicInVarSet().contains(inVar)) { + bw.write(" (dynamic)" + inVar + "\n"); } + } - bw.write(" Dynamic vars to manage: " + fsen.getDynamicVarSet() + "\n"); + bw.write(" Dynamic vars to manage: " + fsen.getDynamicVarSet() + "\n"); - bw.write(" out-set: " + fsen.getOutVarSet() + "\n"); - bw.write("}\n"); - } + bw.write(" out-set: " + fsen.getOutVarSet() + "\n"); + bw.write("}\n"); Iterator childItr = fsen.getChildren().iterator(); while (childItr.hasNext()) { diff --git a/Robust/src/Analysis/OoOJava/RBlockRelationAnalysis.java b/Robust/src/Analysis/OoOJava/RBlockRelationAnalysis.java index 9d464e20..99fd2bcf 100644 --- a/Robust/src/Analysis/OoOJava/RBlockRelationAnalysis.java +++ b/Robust/src/Analysis/OoOJava/RBlockRelationAnalysis.java @@ -2,13 +2,50 @@ package Analysis.OoOJava; import IR.State; import IR.TypeUtil; -import Analysis.CallGraph.CallGraph; import IR.MethodDescriptor; +import IR.TypeDescriptor; import IR.Flat.*; +import Analysis.CallGraph.CallGraph; import java.util.*; -// This analysis computes relations between rblocks -// and identifies important rblocks. + +// This analysis finds all reachable rblocks in the +// program and computes parent/child relations +// between those rblocks + +// SPECIAL NOTE! +// There is a distict between parent/child and +// local parent/local child! "Local" means defined +// and nested within a single method context. +// Otherwise, SESE/rblocks/tasks may have many +// parents and many non-method-context-local +// children considering the call graph + +// Also this analysis should identify "critical regions" +// in the context of interprocedural sese/rblock/task relations +// where a statement may conflict with some previously executing +// child task, even if it is in another method context. +// +// Ex: +// +// void main() { +// task a { +// Foo f = new Foo(); +// task achild1 { +// f.z = 1; +// } +// doSomething( f ); +// } +// } +// +// void doSomething( Foo f ) { +// f.z++; <-------- These two statements are in the critical +// f.z--; <-------- region of 'a' after 'c1' and before 'c2' +// task achild2 { +// f.z--; +// } +// } + public class RBlockRelationAnalysis { @@ -23,34 +60,90 @@ public class RBlockRelationAnalysis { // about it, such as the whole program ends when it ends protected FlatSESEEnterNode mainSESE; - // SESEs that are the root of an SESE tree belong to this - // set--the main SESE is always a root, statically SESEs - // inside methods are a root because we don't know how they - // will fit into the runtime tree of SESEs - protected Set rootSESEs; + // this is a special task object, it is not in any IR graph + // and it does not appear to have any children or parents. + // It is a stand-in for whichever task is running when a + // method context starts such that intraprocedural task + // analyses have one static name for "the task who invoked + // this method" to attach facts to. It GREATLY simplifies + // the OoOJava variable analysis, for instance + protected FlatSESEEnterNode callerProxySESE; - // simply a set of every reachable SESE in the program, not - // including caller placeholder SESEs + // simply the set of every reachable SESE in the program protected Set allSESEs; - // a set of every bogus palceholder SESEs - protected Set allBogusSESEs; - - // per method-per node-rblock stacks - protected Hashtable< FlatMethod, - Hashtable< FlatNode, - Stack - > - > fm2relmap; - // to support calculation of leaf SESEs (no children even // through method calls) for optimization during code gen protected Set methodsContainingSESEs; // maps method descriptor to SESE defined inside of it - // only contains top-level SESE definition in corresponding method - protected Hashtable> md2seseSet; + // only contains local root SESE definitions in corresponding method + // (has no parent in the local method context) + protected Hashtable< MethodDescriptor, Set > md2localRootSESEs; + + // the set of every local root SESE in the program (SESE that + // has no parent in the local method context) + protected Set allLocalRootSESEs; + + // if you want to know which rblocks might be executing a given flat + // node it will be in this set + protected Hashtable< FlatNode, Set > fn2currentSESEs; + + // if you want to know the method-local, inner-most nested task that + // is executing a flat node, it is either here or null. + // + // ex: + // void foo() { + // task a { + // bar(); <-- here 'a' is the localInnerSESE + // } + // void bar() { + // baz(); <-- here there is no locally-defined SESE, would be null + // } + protected Hashtable fn2localInnerSESE; + + // indicates whether this statement might occur in a task and + // after some child task definition such that, without looking at + // the flat node itself, the parent might have to stall for child + protected Hashtable fn2isPotentialStallSite; + + + //////////////////////// + // public interface + //////////////////////// + public FlatSESEEnterNode getMainSESE() { + return mainSESE; + } + + public FlatSESEEnterNode getCallerProxySESE() { + return callerProxySESE; + } + + public Set getAllSESEs() { + return allSESEs; + } + + public Set getLocalRootSESEs() { + return allLocalRootSESEs; + } + public Set getPossibleExecutingRBlocks( FlatNode fn ) { + return fn2currentSESEs.get( fn ); + } + + public FlatSESEEnterNode getLocalInnerRBlock( FlatNode fn ) { + return fn2localInnerSESE.get( fn ); + } + + public boolean isPotentialStallSite( FlatNode fn ) { + Boolean ipss = fn2isPotentialStallSite.get( fn ); + if( ipss == null ) { + return false; + } + return ipss; + } + + public RBlockRelationAnalysis( State state, TypeUtil typeUtil, CallGraph callGraph ) { @@ -58,16 +151,15 @@ public class RBlockRelationAnalysis { this.typeUtil = typeUtil; this.callGraph = callGraph; - rootSESEs = new HashSet(); - allSESEs = new HashSet(); - allBogusSESEs = new HashSet(); + callerProxySESE = new FlatSESEEnterNode( null ); - methodsContainingSESEs = new HashSet(); - - fm2relmap = - new Hashtable< FlatMethod, Hashtable< FlatNode, Stack > >(); - - md2seseSet = new Hashtable>(); + allSESEs = new HashSet(); + allLocalRootSESEs = new HashSet(); + methodsContainingSESEs = new HashSet(); + md2localRootSESEs = new Hashtable>(); + fn2currentSESEs = new Hashtable>(); + fn2localInnerSESE = new Hashtable(); + fn2isPotentialStallSite = new Hashtable(); MethodDescriptor mdSourceEntry = typeUtil.getMain(); @@ -78,135 +170,119 @@ public class RBlockRelationAnalysis { mainSESE.setmdEnclosing( fmMain.getMethod() ); mainSESE.setcdEnclosing( fmMain.getMethod().getClassDesc() ); + // add all methods transitively reachable from the - // source's main to set for analysis + // source's main to set to find rblocks Set descriptorsToAnalyze = callGraph.getAllMethods( mdSourceEntry ); descriptorsToAnalyze.add( mdSourceEntry ); - analyzeMethods( descriptorsToAnalyze ); + findRblocksAndLocalParentChildRelations( descriptorsToAnalyze ); - computeLeafSESEs(); - } + findTransitiveParentChildRelations(); + findPossibleExecutingRBlocksAndStallSites(); - public FlatSESEEnterNode getMainSESE() { - return mainSESE; - } - public Set getRootSESEs() { - return rootSESEs; + // Uncomment this phase to debug the marking of potential + // stall sites for parents between/after children tasks. + // After this debug thing runs in calls System.exit() + //debugPrintPotentialStallSites( descriptorsToAnalyze ); } - public Set getAllSESEs() { - return allSESEs; - } - - public Stack getRBlockStacks( FlatMethod fm, - FlatNode fn ) { - if( !fm2relmap.containsKey( fm ) ) { - fm2relmap.put( fm, computeRBlockRelations( fm ) ); - } - return fm2relmap.get( fm ).get( fn ); - } - protected void analyzeMethods( Set descriptorsToAnalyze ) { + + protected void findRblocksAndLocalParentChildRelations( Set descriptorsToAnalyze ) { Iterator mdItr = descriptorsToAnalyze.iterator(); while( mdItr.hasNext() ) { FlatMethod fm = state.getMethodFlat( mdItr.next() ); - - Hashtable< FlatNode, Stack > relmap = - computeRBlockRelations( fm ); - - fm2relmap.put( fm, relmap ); - } - } - - public Hashtable< FlatNode, Stack > - computeRBlockRelations( FlatMethod fm ) { - - Hashtable< FlatNode, Stack > seseStacks = - new Hashtable< FlatNode, Stack >(); - - // start from flat method top, visit every node in - // method exactly once, find SESE stack on every - // control path - Set flatNodesToVisit = new HashSet(); - flatNodesToVisit.add( fm ); + + // start from flat method top, visit every node in + // method exactly once, find SESE stack on every + // control path: this will discover every reachable + // SESE in the program, and define the local parent + // and local children relations + Hashtable< FlatNode, Stack > seseStacks = + new Hashtable< FlatNode, Stack >(); + + Set flatNodesToVisit = new HashSet(); + flatNodesToVisit.add( fm ); - Set visited = new HashSet(); + Set visited = new HashSet(); - Stack seseStackFirst = new Stack(); - seseStacks.put( fm, seseStackFirst ); + Stack seseStackFirst = new Stack(); + seseStacks.put( fm, seseStackFirst ); - while( !flatNodesToVisit.isEmpty() ) { - Iterator fnItr = flatNodesToVisit.iterator(); - FlatNode fn = fnItr.next(); + while( !flatNodesToVisit.isEmpty() ) { + Iterator fnItr = flatNodesToVisit.iterator(); + FlatNode fn = fnItr.next(); - Stack seseStack = seseStacks.get( fn ); - assert seseStack != null; + Stack seseStack = seseStacks.get( fn ); + assert seseStack != null; - flatNodesToVisit.remove( fn ); - visited.add( fn ); - - nodeActions( fn, seseStack, fm ); + flatNodesToVisit.remove( fn ); + visited.add( fn ); - for( int i = 0; i < fn.numNext(); i++ ) { - FlatNode nn = fn.getNext( i ); - - if( !visited.contains( nn ) ) { - flatNodesToVisit.add( nn ); + if( !seseStack.isEmpty() ) { + fn2localInnerSESE.put( fn, seseStack.peek() ); + } - // clone stack and send along each control path - seseStacks.put( nn, (Stack)seseStack.clone() ); - } - } - } + nodeActions( fn, seseStack, fm ); + + for( int i = 0; i < fn.numNext(); i++ ) { + FlatNode nn = fn.getNext( i ); + + if( !visited.contains( nn ) ) { + flatNodesToVisit.add( nn ); - return seseStacks; + // clone stack and send along each control path + seseStacks.put( nn, (Stack)seseStack.clone() ); + } + } + } + } } - + protected void nodeActions( FlatNode fn, Stack seseStack, FlatMethod fm ) { switch( fn.kind() ) { - + case FKind.FlatSESEEnterNode: { FlatSESEEnterNode fsen = (FlatSESEEnterNode) fn; - if( !fsen.getIsCallerSESEplaceholder() ) { - allSESEs.add( fsen ); - methodsContainingSESEs.add( fm.getMethod() ); - }else{ - allBogusSESEs.add(fsen); - } + allSESEs.add( fsen ); + methodsContainingSESEs.add( fm.getMethod() ); fsen.setfmEnclosing( fm ); fsen.setmdEnclosing( fm.getMethod() ); fsen.setcdEnclosing( fm.getMethod().getClassDesc() ); - if(!fsen.getIsCallerSESEplaceholder() && fsen.getParent()==null ){ - Set seseSet=md2seseSet.get(fm.getMethod()); - if(seseSet==null){ - seseSet=new HashSet(); - } - seseSet.add(fsen); - md2seseSet.put(fm.getMethod(), seseSet); - } - if( seseStack.empty() ) { - rootSESEs.add( fsen ); - fsen.setParent( null ); + // no local parent + fsen.setLocalParent( null ); + + allLocalRootSESEs.add( fsen ); + + Set seseSet = md2localRootSESEs.get( fm.getMethod() ); + if( seseSet == null ) { + seseSet = new HashSet(); + } + seseSet.add( fsen ); + md2localRootSESEs.put( fm.getMethod(), seseSet ); + } else { - seseStack.peek().addChild( fsen ); - fsen.setParent( seseStack.peek() ); - // if the top of stack is not bogus one, it should be a non-bogus parent to the current sese - if(!seseStack.peek().getIsCallerSESEplaceholder()){ - fsen.addSESEParent(seseStack.peek()); - } + // otherwise a local parent/child relation + // which is also the broader parent/child + // relation as well + seseStack.peek().addLocalChild( fsen ); + fsen.setLocalParent( seseStack.peek() ); + + seseStack.peek().addChild( fsen ); + fsen.addParent( seseStack.peek() ); } seseStack.push( fsen ); @@ -220,9 +296,7 @@ public class RBlockRelationAnalysis { case FKind.FlatReturnNode: { FlatReturnNode frn = (FlatReturnNode) fn; - if( !seseStack.empty() && - !seseStack.peek().getIsCallerSESEplaceholder() - ) { + if( !seseStack.empty() ) { throw new Error( "Error: return statement enclosed within SESE "+ seseStack.peek().getPrettyIdentifier() ); } @@ -232,102 +306,270 @@ public class RBlockRelationAnalysis { } - protected void computeLeafSESEs() { - - Set all=new HashSet(); - all.addAll(allSESEs); - all.addAll(allBogusSESEs); - - for (Iterator itr = all.iterator(); itr.hasNext();) { + + protected void findTransitiveParentChildRelations() { + + for (Iterator itr = allSESEs.iterator(); itr.hasNext();) { FlatSESEEnterNode fsen = itr.next(); - boolean hasNoNestedChildren = fsen.getChildren().isEmpty(); - boolean hasNoChildrenByCall = !hasChildrenByCall(fsen); + boolean hasNoNestedChildren = fsen.getLocalChildren().isEmpty(); + boolean hasNoChildrenByCall = !hasChildrenByCall( fsen ); - fsen.setIsLeafSESE(hasNoNestedChildren && hasNoChildrenByCall); + fsen.setIsLeafSESE( hasNoNestedChildren && hasNoChildrenByCall ); } - - // for( Iterator itr = allSESEs.iterator(); - // itr.hasNext(); - // ) { - // FlatSESEEnterNode fsen = itr.next(); - // - // boolean hasNoNestedChildren = fsen.getChildren().isEmpty(); - // boolean hasNoChildrenByCall = !hasChildrenByCall( fsen ); - // - // fsen.setIsLeafSESE( hasNoNestedChildren && - // hasNoChildrenByCall ); - // } } + protected boolean hasChildrenByCall( FlatSESEEnterNode fsen ) { - protected boolean hasChildrenByCall(FlatSESEEnterNode fsen) { - boolean hasChildrenByCall=false; + boolean hasChildrenByCall = false; // visit every flat node in SESE body, find method calls that // may transitively call methods with SESEs enclosed Set flatNodesToVisit = new HashSet(); - flatNodesToVisit.add(fsen); + flatNodesToVisit.add( fsen ); Set visited = new HashSet(); - - while (!flatNodesToVisit.isEmpty()) { + + while( !flatNodesToVisit.isEmpty() ) { Iterator fnItr = flatNodesToVisit.iterator(); FlatNode fn = fnItr.next(); - flatNodesToVisit.remove(fn); - visited.add(fn); + flatNodesToVisit.remove( fn ); + visited.add( fn ); - if (fn.kind() == FKind.FlatCall) { - FlatCall fc = (FlatCall) fn; - MethodDescriptor mdCallee = fc.getMethod(); - Set reachable = new HashSet(); - - reachable.add(mdCallee); - reachable.addAll(callGraph.getAllMethods(mdCallee)); + if( fn.kind() == FKind.FlatCall ) { + FlatCall fc = (FlatCall) fn; + MethodDescriptor mdCallee = fc.getMethod(); + Set reachable = new HashSet(); - reachable.retainAll(methodsContainingSESEs); + reachable.add( mdCallee ); + reachable.addAll( callGraph.getAllMethods( mdCallee ) ); + reachable.retainAll( methodsContainingSESEs ); - if (!reachable.isEmpty()) { + if( !reachable.isEmpty() ) { hasChildrenByCall = true; - if (!fsen.getIsCallerSESEplaceholder()) { - Set reachableSESEMethodSet = - callGraph.getFirstReachableMethodContainingSESE(mdCallee, methodsContainingSESEs); - - reachableSESEMethodSet.add(mdCallee); - - for (Iterator iterator = reachableSESEMethodSet.iterator(); iterator.hasNext();) { - MethodDescriptor md = (MethodDescriptor) iterator.next(); - FlatMethod fm = state.getMethodFlat(md); - FlatSESEEnterNode fsenBogus = (FlatSESEEnterNode) fm.getNext(0); - fsenBogus.addSESEParent(fsen); + Set reachableSESEMethodSet = + callGraph.getFirstReachableMethodContainingSESE( mdCallee, methodsContainingSESEs ); + + reachableSESEMethodSet.add( mdCallee ); + reachableSESEMethodSet.retainAll( methodsContainingSESEs ); + + for( Iterator iterator = reachableSESEMethodSet.iterator(); iterator.hasNext(); ) { + MethodDescriptor md = (MethodDescriptor) iterator.next(); + Set seseSet = md2localRootSESEs.get( md ); + if( seseSet != null ) { + fsen.addChildren( seseSet ); + for( Iterator iterator2 = seseSet.iterator(); iterator2.hasNext(); ) { + FlatSESEEnterNode child = (FlatSESEEnterNode) iterator2.next(); + child.addParent( fsen ); + } } - - reachableSESEMethodSet.retainAll(methodsContainingSESEs); - - for (Iterator iterator = reachableSESEMethodSet.iterator(); iterator.hasNext();) { - MethodDescriptor md = (MethodDescriptor) iterator.next(); - Set seseSet = md2seseSet.get(md); - if (seseSet != null) { - fsen.addSESEChildren(seseSet); - for (Iterator iterator2 = seseSet.iterator(); iterator2.hasNext();) { - FlatSESEEnterNode child = (FlatSESEEnterNode) iterator2.next(); - child.addSESEParent(fsen); - } - } - } - } } - } - if (fn == fsen.getFlatExit()) { + if( fn == fsen.getFlatExit() ) { // don't enqueue any futher nodes continue; } + for( int i = 0; i < fn.numNext(); i++ ) { + FlatNode nn = fn.getNext( i ); + + if( !visited.contains( nn ) ) { + flatNodesToVisit.add( nn ); + } + } + } + + return hasChildrenByCall; + } + + + + protected void findPossibleExecutingRBlocksAndStallSites() { + for( Iterator fsenItr = allSESEs.iterator(); fsenItr.hasNext(); ) { + FlatSESEEnterNode fsen = fsenItr.next(); + + // walk the program points, including across method calls, reachable within + // this sese/rblock/task and mark that this rblock might be executing. + // Important: skip the body of child rblocks, BUT DO mark the child ENTER + // and EXIT flat nodes as the parent being the current executing rblock! + Hashtable flatNodesToVisit = + new Hashtable(); + + for( int i = 0; i < fsen.numNext(); i++ ) { + FlatNode nn = fsen.getNext( i ); + flatNodesToVisit.put( nn, fsen.getfmEnclosing() ); + mergeIsPotentialStallSite( nn, false ); + } + + Set visited = new HashSet(); + + while( !flatNodesToVisit.isEmpty() ) { + Map.Entry me = (Map.Entry) flatNodesToVisit.entrySet().iterator().next(); + FlatNode fn = (FlatNode) me.getKey(); + FlatMethod fm = (FlatMethod) me.getValue(); + + flatNodesToVisit.remove( fn ); + visited.add( fn ); + + + // the "is potential stall site" strategy is to propagate + // "false" from the beginning of a task until you hit a + // child, then from the child's exit propagate "true" for + // the parent statements after children. When you pull a node + // out of the bag for traversal and it happens to be an + // enter or an exit node, fix the dumb propagation that + // your IR predecessor pushed on you + Boolean isPotentialStallSite = isPotentialStallSite( fn ); + + if( fn instanceof FlatSESEEnterNode || + fn instanceof FlatSESEExitNode ) { + // fix it so this is never a potential stall site, but from + // a child definition onward propagate 'true' + setIsPotentialStallSite( fn, false ); + isPotentialStallSite = true; + } + + + if( fn == fsen.getFlatExit() ) { + // don't enqueue any futher nodes when you find your exit, + // NOR mark your own flat as a statement you are currently + // executing, your parent(s) will mark it + continue; + } + + + // the purpose of this traversal is to find program + // points where rblock 'fsen' might be executing + addPossibleExecutingRBlock( fn, fsen ); + + + if( fn instanceof FlatSESEEnterNode ) { + // don't visit internal nodes of child, + // just enqueue the exit node + FlatSESEEnterNode child = (FlatSESEEnterNode) fn; + assert fsen.getChildren().contains( child ); + assert child.getParents().contains( fsen ); + flatNodesToVisit.put( child.getFlatExit(), fm ); + + // explicitly do this to handle the case that you + // should mark yourself as possibly executing at + // your own exit, because one instance can + // recursively invoke another + addPossibleExecutingRBlock( child.getFlatExit(), fsen ); + + continue; + } + + if( fn instanceof FlatCall ) { + // start visiting nodes in other contexts + FlatCall fc = (FlatCall) fn; + MethodDescriptor mdCallee = fc.getMethod(); + + Set implementations = new HashSet(); + + if( mdCallee.isStatic() ) { + implementations.add( mdCallee ); + } else { + TypeDescriptor typeDesc = fc.getThis().getType(); + implementations.addAll( callGraph.getMethods( mdCallee, typeDesc ) ); + } + + for( Iterator imps = implementations.iterator(); imps.hasNext(); ) { + MethodDescriptor mdImp = (MethodDescriptor) imps.next(); + FlatMethod fmImp = state.getMethodFlat( mdImp ); + flatNodesToVisit.put( fmImp, fmImp ); + + // propagate your IR graph predecessor's stall site potential + mergeIsPotentialStallSite( fmImp, isPotentialStallSite ); + } + // don't 'continue' out of this loop, also enqueue + // flat nodes that flow in the current method context + } + + // otherwise keep visiting nodes in same context + for( int i = 0; i < fn.numNext(); i++ ) { + FlatNode nn = fn.getNext( i ); + + if( !visited.contains( nn ) ) { + flatNodesToVisit.put( nn, fm ); + + // propagate your IR graph predecessor's stall site potential + mergeIsPotentialStallSite( nn, isPotentialStallSite ); + } + } + } + } + } + + + + protected void addPossibleExecutingRBlock( FlatNode fn, + FlatSESEEnterNode fsen ) { + + Set currentSESEs = fn2currentSESEs.get( fn ); + if( currentSESEs == null ) { + currentSESEs = new HashSet(); + } + + currentSESEs.add( fsen ); + fn2currentSESEs.put( fn, currentSESEs ); + } + + + // definitively set whether a statement is a potential stall site + // such as a task exit is FALSE and the statement following an exit + // is TRUE + protected void setIsPotentialStallSite( FlatNode fn, + Boolean ipss ) { + fn2isPotentialStallSite.put( fn, ipss ); + } + + + // Use this to OR the previous result with a new result + protected void mergeIsPotentialStallSite( FlatNode fn, + Boolean ipss ) { + Boolean ipssPrev = isPotentialStallSite( fn ); + setIsPotentialStallSite( fn, ipssPrev || ipss ); + } + + + + + + ///////////////////////////////////////////////// + // for DEBUG + ///////////////////////////////////////////////// + protected void debugPrintPotentialStallSites(Set descriptorsToAnalyze) { + Iterator mdItr = descriptorsToAnalyze.iterator(); + while (mdItr.hasNext()) { + FlatMethod fm = state.getMethodFlat(mdItr.next()); + printStatusMap(fm); + } + System.exit( 0 ); + } + + protected void printStatusMap(FlatMethod fm) { + + System.out.println("\n\n=== "+fm+" ==="); + + Set flatNodesToVisit = new HashSet(); + flatNodesToVisit.add(fm); + + Set visited = new HashSet(); + + while (!flatNodesToVisit.isEmpty()) { + Iterator fnItr = flatNodesToVisit.iterator(); + FlatNode fn = fnItr.next(); + + flatNodesToVisit.remove(fn); + visited.add(fn); + + System.out.println(fn+"[["+isPotentialStallSite(fn)+"]]"); + for (int i = 0; i < fn.numNext(); i++) { FlatNode nn = fn.getNext(i); @@ -336,9 +578,6 @@ public class RBlockRelationAnalysis { } } } - - return hasChildrenByCall; } - -} +} \ No newline at end of file diff --git a/Robust/src/Analysis/OoOJava/SESEandAgePair.java b/Robust/src/Analysis/OoOJava/SESEandAgePair.java new file mode 100644 index 00000000..49ae0d8a --- /dev/null +++ b/Robust/src/Analysis/OoOJava/SESEandAgePair.java @@ -0,0 +1,54 @@ +package Analysis.OoOJava; + +import IR.*; +import IR.Flat.*; +import java.util.*; +import java.io.*; + +public class SESEandAgePair { + + private FlatSESEEnterNode sese; + private Integer age; + + public SESEandAgePair( FlatSESEEnterNode sese, + Integer age ) { + this.sese = sese; + this.age = age; + } + + public FlatSESEEnterNode getSESE() { + return sese; + } + + public Integer getAge() { + return age; + } + + public boolean equals( Object o ) { + if( o == null ) { + return false; + } + + if( !(o instanceof SESEandAgePair) ) { + return false; + } + + SESEandAgePair p = (SESEandAgePair) o; + + return age.equals( p.age ) && + sese.equals( p.sese ); + } + + public int hashCode() { + return (sese.hashCode() << 2)*(age.hashCode() << 5); + } + + + public String toString() { + return "SESE_"+ + sese.getPrettyIdentifier()+ + sese.getIdentifier()+ + "_"+ + age; + } +} diff --git a/Robust/src/Analysis/OoOJava/SVKey.java b/Robust/src/Analysis/OoOJava/SVKey.java new file mode 100644 index 00000000..e98ff31e --- /dev/null +++ b/Robust/src/Analysis/OoOJava/SVKey.java @@ -0,0 +1,50 @@ +package Analysis.OoOJava; + +import IR.*; +import IR.Flat.*; +import java.util.*; +import java.io.*; + +public class SVKey { + + private FlatSESEEnterNode sese; + private TempDescriptor var; + + public SVKey( FlatSESEEnterNode sese, + TempDescriptor var ) { + this.sese = sese; + this.var = var; + } + + public FlatSESEEnterNode getSESE() { + return sese; + } + + public TempDescriptor getVar() { + return var; + } + + public boolean equals( Object o ) { + if( o == null ) { + return false; + } + + if( !(o instanceof SVKey) ) { + return false; + } + + SVKey k = (SVKey) o; + + return var.equals( k.var ) && + sese.equals( k.sese ); + } + + public int hashCode() { + return (sese.hashCode() << 2)*(var.hashCode() << 5); + } + + + public String toString() { + return "key["+sese.getPrettyIdentifier()+", "+var+"]"; + } +} diff --git a/Robust/src/Analysis/OoOJava/VSTWrapper.java b/Robust/src/Analysis/OoOJava/VSTWrapper.java new file mode 100644 index 00000000..6f17610a --- /dev/null +++ b/Robust/src/Analysis/OoOJava/VSTWrapper.java @@ -0,0 +1,17 @@ +package Analysis.OoOJava; + +import IR.*; +import IR.Flat.*; +import java.util.*; +import java.io.*; + +// the reason for this class is to allow a VariableSourceToken +// to be null in some circumstances + +public class VSTWrapper { + public VariableSourceToken vst; + + public VSTWrapper() { + vst = null; + } +} diff --git a/Robust/src/Analysis/OoOJava/VarSrcTokTable.java b/Robust/src/Analysis/OoOJava/VarSrcTokTable.java new file mode 100644 index 00000000..f1f83687 --- /dev/null +++ b/Robust/src/Analysis/OoOJava/VarSrcTokTable.java @@ -0,0 +1,889 @@ +package Analysis.OoOJava; + +import IR.*; +import IR.Flat.*; +import java.util.*; +import java.io.*; + +// This class formerly had lazy consistency properties, but +// it is being changed so that the full set and the extra +// hash tables to access the full set efficiently by different +// elements will be consistent after EVERY operation. Also, +// a consistent assert method allows a debugger to ask whether +// an operation has produced an inconsistent VarSrcTokTable. + +// in an effort to make sure operations keep the table consistent, +// all public methods that are also used by other methods for +// intermediate results (add and remove are used in other methods) +// there should be a public version that calls the private version +// so consistency is checked after public ops, but not private ops +public class VarSrcTokTable { + + // a set of every token in the table + private HashSet trueSet; + + // these hashtables provide an efficient retreival from the true set + private Hashtable< TempDescriptor, Set > var2vst; + private Hashtable< FlatSESEEnterNode, Set > sese2vst; + private Hashtable< SVKey, Set > sv2vst; + + // maximum age from aging operation + private static final Integer MAX_AGE = new Integer( 2 ); + + public static final Integer SrcType_READY = new Integer( 34 ); + public static final Integer SrcType_STATIC = new Integer( 35 ); + public static final Integer SrcType_DYNAMIC = new Integer( 36 ); + + + public VarSrcTokTable() { + trueSet = new HashSet(); + + sese2vst = new Hashtable< FlatSESEEnterNode, Set >(); + var2vst = new Hashtable< TempDescriptor, Set >(); + sv2vst = new Hashtable< SVKey, Set >(); + + assertConsistency(); + } + + + // make a deep copy of the in table + public VarSrcTokTable( VarSrcTokTable in ) { + this(); + merge( in ); + assertConsistency(); + } + + + public void add( VariableSourceToken vst ) { + addPrivate( vst ); + assertConsistency(); + } + + private void addPrivate( VariableSourceToken vst ) { + + // make sure we aren't clobbering anything! + if( trueSet.contains( vst ) ) { + // if something with the same hashcode is in the true set, they might + // have different reference variable sets because that set is not considered + // in a token's equality, so make sure we smooth that out right here + Iterator vstItr = trueSet.iterator(); + while( vstItr.hasNext() ) { + VariableSourceToken vstAlready = vstItr.next(); + + if( vstAlready.equals( vst ) ) { + + // take out the one that is in (we dont' want collisions in + // any of the other hash map sets either) + removePrivate( vstAlready ); + + // combine reference variable sets + vst.getRefVars().addAll( vstAlready.getRefVars() ); + + // now jump back as we are adding in a brand new token + break; + } + } + } + + trueSet.add( vst ); + + Set s; + + s = sese2vst.get( vst.getSESE() ); + if( s == null ) { + s = new HashSet(); + } + s.add( vst ); + sese2vst.put( vst.getSESE(), s ); + + Iterator refVarItr = vst.getRefVars().iterator(); + while( refVarItr.hasNext() ) { + TempDescriptor refVar = refVarItr.next(); + s = var2vst.get( refVar ); + if( s == null ) { + s = new HashSet(); + } + s.add( vst ); + var2vst.put( refVar, s ); + + SVKey key = new SVKey( vst.getSESE(), refVar ); + s = sv2vst.get( key ); + if( s == null ) { + s = new HashSet(); + } + s.add( vst ); + sv2vst.put( key, s ); + } + } + + public void addAll( Set s ) { + Iterator itr = s.iterator(); + while( itr.hasNext() ) { + addPrivate( itr.next() ); + } + assertConsistency(); + } + + + public Set get() { + return trueSet; + } + + public Set get( FlatSESEEnterNode sese ) { + Set s = sese2vst.get( sese ); + if( s == null ) { + s = new HashSet(); + sese2vst.put( sese, s ); + } + return s; + } + + public Set get( TempDescriptor refVar ) { + Set s = var2vst.get( refVar ); + if( s == null ) { + s = new HashSet(); + var2vst.put( refVar, s ); + } + return s; + } + + public Set get( FlatSESEEnterNode sese, + TempDescriptor refVar ) { + SVKey key = new SVKey( sese, refVar ); + Set s = sv2vst.get( key ); + if( s == null ) { + s = new HashSet(); + sv2vst.put( key, s ); + } + return s; + } + + public Set get( FlatSESEEnterNode sese, + Integer age ) { + + HashSet s0 = (HashSet) sese2vst.get( sese ); + if( s0 == null ) { + s0 = new HashSet(); + sese2vst.put( sese, s0 ); + } + + Set s = (Set) s0.clone(); + Iterator sItr = s.iterator(); + while( sItr.hasNext() ) { + VariableSourceToken vst = sItr.next(); + if( !vst.getAge().equals( age ) ) { + s.remove( vst ); + } + } + + return s; + } + + + // merge now makes a deep copy of incoming stuff because tokens may + // be modified (reference var sets) by later ops that change more + // than one table, causing inconsistency + public void merge( VarSrcTokTable in ) { + + if( in == null ) { + return; + } + + Iterator vstItr = in.trueSet.iterator(); + while( vstItr.hasNext() ) { + VariableSourceToken vst = vstItr.next(); + this.addPrivate( vst.copy() ); + } + + assertConsistency(); + } + + + // remove operations must leave the trueSet + // and the hash maps consistent + public void remove( VariableSourceToken vst ) { + removePrivate( vst ); + assertConsistency(); + } + + private void removePrivate( VariableSourceToken vst ) { + trueSet.remove( vst ); + + Set s; + + s = get( vst.getSESE() ); + if( s != null ) { s.remove( vst ); } + + Iterator refVarItr = vst.getRefVars().iterator(); + while( refVarItr.hasNext() ) { + TempDescriptor refVar = refVarItr.next(); + + s = get( refVar ); + if( s != null ) { + s.remove( vst ); + if( s.isEmpty() ) { + var2vst.remove( refVar ); + } + } + + s = get( vst.getSESE(), refVar ); + if( s != null ) { + s.remove( vst ); + if( s.isEmpty() ) { + sv2vst.remove( new SVKey( vst.getSESE(), refVar ) ); + } + } + } + } + + + public void remove( FlatSESEEnterNode sese ) { + removePrivate( sese ); + assertConsistency(); + } + + public void removePrivate( FlatSESEEnterNode sese ) { + Set s = sese2vst.get( sese ); + if( s == null ) { + return; + } + + Iterator itr = s.iterator(); + while( itr.hasNext() ) { + VariableSourceToken vst = itr.next(); + removePrivate( vst ); + } + + sese2vst.remove( sese ); + } + + + public void remove( TempDescriptor refVar ) { + removePrivate( refVar ); + assertConsistency(); + } + + private void removePrivate( TempDescriptor refVar ) { + Set s = var2vst.get( refVar ); + if( s == null ) { + return; + } + + Set forRemoval = new HashSet(); + + // iterate over tokens that this temp can reference, make a set + // of tokens that need this temp stripped out of them + Iterator itr = s.iterator(); + while( itr.hasNext() ) { + VariableSourceToken vst = itr.next(); + Set refVars = vst.getRefVars(); + assert refVars.contains( refVar ); + forRemoval.add( vst ); + } + + itr = forRemoval.iterator(); + while( itr.hasNext() ) { + + // here's a token marked for removal + VariableSourceToken vst = itr.next(); + Set refVars = vst.getRefVars(); + + // if there was only one one variable + // referencing this token, just take it + // out of the table all together + if( refVars.size() == 1 ) { + removePrivate( vst ); + } + + sv2vst.remove( new SVKey( vst.getSESE(), refVar ) ); + + refVars.remove( refVar ); + } + + var2vst.remove( refVar ); + } + + + public void remove( FlatSESEEnterNode sese, + TempDescriptor var ) { + + // don't seem to need this, don't bother maintaining + // until its clear we need it + assert false; + } + + + // age tokens with respect to SESE curr, where + // any curr tokens increase age by 1 + public void age( FlatSESEEnterNode curr ) { + + Set forRemoval = + new HashSet(); + + Set forAddition = + new HashSet(); + + Iterator itr = trueSet.iterator(); + while( itr.hasNext() ) { + VariableSourceToken vst = itr.next(); + + if( vst.getSESE().equals( curr ) ) { + + // only age if the token isn't already the maximum age + if( vst.getAge() < MAX_AGE ) { + + forRemoval.add( vst ); + + forAddition.add( new VariableSourceToken( vst.getRefVars(), + curr, + vst.getAge() + 1, + vst.getAddrVar() + ) + ); + } + } + } + + itr = forRemoval.iterator(); + while( itr.hasNext() ) { + VariableSourceToken vst = itr.next(); + remove( vst ); + } + + itr = forRemoval.iterator(); + while( itr.hasNext() ) { + VariableSourceToken vst = itr.next(); + add( vst ); + } + + assertConsistency(); + } + + + // at an SESE enter node, all ref vars in the SESE's in-set will + // be copied into the SESE's local scope, change source to itself + public void ownInSet( FlatSESEEnterNode curr ) { + Iterator inVarItr = curr.getInVarSet().iterator(); + while( inVarItr.hasNext() ) { + TempDescriptor inVar = inVarItr.next(); + + remove( inVar ); + assertConsistency(); + + Set refVars = new HashSet(); + refVars.add( inVar ); + add( new VariableSourceToken( refVars, + curr, + new Integer( 0 ), + inVar + ) + ); + assertConsistency(); + } + } + + + // for the given SESE, change child tokens into this parent + public void remapChildTokens( FlatSESEEnterNode curr ) { + + Iterator childItr = curr.getChildren().iterator(); + if( childItr.hasNext() ) { + FlatSESEEnterNode child = childItr.next(); + + // set of VSTs for removal + HashSet removalSet=new HashSet(); + // set of VSTs for additon + HashSet additionSet=new HashSet(); + + Iterator vstItr = get( child ).iterator(); + while( vstItr.hasNext() ) { + VariableSourceToken vst = vstItr.next(); + removalSet.add(vst); + additionSet.add(new VariableSourceToken( vst.getRefVars(), + curr, + new Integer( 0 ), + vst.getAddrVar() + )); + } + + // remove( eah item in forremoval ) + vstItr = removalSet.iterator(); + while( vstItr.hasNext() ) { + VariableSourceToken vst = vstItr.next(); + remove( vst ); + } + // add( each ite inm for additon _ + vstItr = additionSet.iterator(); + while( vstItr.hasNext() ) { + VariableSourceToken vst = vstItr.next(); + add( vst ); + } + } + + assertConsistency(); + } + + + // this method is called at the SESE exit of SESE 'curr' + // if the sources for a variable written by curr can also + // come from curr's parent or curr's siblings then we're not + // sure that curr will actually modify the variable. There are + // many ways to handle this, but for now, mark the variable as + // virtually read so curr insists on having ownership of it + // whether it ends up writing to it or not. It will always, then, + // appear in curr's out-set. + public Set + calcVirtReadsAndPruneParentAndSiblingTokens( FlatSESEEnterNode exiter, + Set liveVars ) { + + Set virtReadSet = new HashSet(); + + Set parents = null; //exiter.getParents(); + if( parents.isEmpty() ) { + // having no parent means no siblings, too + return virtReadSet; + } + + Set alternateSESEs = new HashSet(); + alternateSESEs.addAll( parents ); + Iterator childItr = null; //parents.getChildren().iterator(); + while( childItr.hasNext() ) { + FlatSESEEnterNode sibling = childItr.next(); + if( !sibling.equals( exiter ) ) { + alternateSESEs.add( sibling ); + } + } + + // VSTs to remove if they are alternate sources for exiter VSTs + // whose variables will become virtual reads + Set forRemoval = new HashSet(); + + // look at all of this SESE's VSTs at exit... + Iterator vstItr = get( exiter ).iterator(); + while( vstItr.hasNext() ) { + VariableSourceToken vstExiterSrc = vstItr.next(); + + // only interested in tokens that come from our current instance + if( vstExiterSrc.getAge() != 0 ) { + continue; + } + + // for each variable that might come from those sources... + Iterator refVarItr = vstExiterSrc.getRefVars().iterator(); + while( refVarItr.hasNext() ) { + TempDescriptor refVar = refVarItr.next(); + + // only matters for live variables at SESE exit program point + if( !liveVars.contains( refVar ) ) { + continue; + } + + // examine other sources for a variable... + Iterator srcItr = get( refVar ).iterator(); + while( srcItr.hasNext() ) { + VariableSourceToken vstPossibleOtherSrc = srcItr.next(); + + if( vstPossibleOtherSrc.getSESE().equals( exiter ) && + vstPossibleOtherSrc.getAge() > 0 + ) { + // this is an alternate source if its + // an older instance of this SESE + virtReadSet.add( refVar ); + forRemoval.add( vstPossibleOtherSrc ); + + } else if( alternateSESEs.contains( vstPossibleOtherSrc.getSESE() ) ) { + // this is an alternate source from parent or sibling + virtReadSet.add( refVar ); + forRemoval.add( vstPossibleOtherSrc ); + + } else { + if( !vstPossibleOtherSrc.getSESE().equals( exiter ) || + !vstPossibleOtherSrc.getAge().equals( 0 ) + ) { + System.out.println( "For refVar="+refVar+" at exit of "+exiter+ + ", unexpected possible variable source "+vstPossibleOtherSrc ); + assert false; + } + } + } + } + } + + vstItr = forRemoval.iterator(); + while( vstItr.hasNext() ) { + VariableSourceToken vst = vstItr.next(); + remove( vst ); + } + assertConsistency(); + + return virtReadSet; + } + + + // get the set of VST's that come from a child + public Set getChildrenVSTs( FlatSESEEnterNode curr ) { + + Set out = new HashSet(); + + Iterator cItr = curr.getChildren().iterator(); + while( cItr.hasNext() ) { + FlatSESEEnterNode child = cItr.next(); + out.addAll( get( child ) ); + } + + return out; + } + + + // given a table from a subsequent program point, decide + // which variables are going from a non-dynamic to a + // dynamic source and return them + public Hashtable + getReadyOrStatic2DynamicSet( VarSrcTokTable nextTable, + Set nextLiveIn, + FlatSESEEnterNode current + ) { + + Hashtable out = + new Hashtable(); + + Iterator itr = var2vst.entrySet().iterator(); + while( itr.hasNext() ) { + Map.Entry me = (Map.Entry) itr.next(); + TempDescriptor var = (TempDescriptor) me.getKey(); + HashSet s1 = (HashSet) me.getValue(); + + // only worth tracking if live + if( nextLiveIn.contains( var ) ) { + + VSTWrapper vstIfStaticBefore = new VSTWrapper(); + VSTWrapper vstIfStaticAfter = new VSTWrapper(); + + Integer srcTypeBefore = this.getRefVarSrcType( var, current, vstIfStaticBefore ); + Integer srcTypeAfter = nextTable.getRefVarSrcType( var, current, vstIfStaticAfter ); + + if( !srcTypeBefore.equals( SrcType_DYNAMIC ) && + srcTypeAfter.equals( SrcType_DYNAMIC ) + ) { + // remember the variable and a source + // it had before crossing the transition + // 1) if it was ready, vstIfStatic.vst is null + // 2) if is was static, use vstIfStatic.vst + out.put( var, vstIfStaticBefore ); + } + } + } + + return out; + } + + + // for some reference variable, return the type of source + // it might have in this table, which might be: + // 1. Ready -- this variable is + // definitely available when you are issued. + // 2. Static -- there is definitely one child SESE with + // a known age that will produce the value + // 3. Dynamic -- we don't know where the value will come + // from statically, so we'll track it dynamically + public Integer getRefVarSrcType( TempDescriptor refVar, + FlatSESEEnterNode current, + VSTWrapper vstIfStatic ) { + assert refVar != null; + assert vstIfStatic != null; + + vstIfStatic.vst = null; + + // when the current SESE is null, that simply means it is + // an unknown placeholder, in which case the system will + // ensure that any variables are READY + if( current == null ) { + return SrcType_READY; + } + + // if there appear to be no sources, it means this variable + // comes from outside of any statically-known SESE scope, + // which means the system guarantees its READY, so jump over + // while loop + Set srcs = get( refVar ); + Iterator itrSrcs = srcs.iterator(); + while( itrSrcs.hasNext() ) { + VariableSourceToken vst = itrSrcs.next(); + + // to make the refVar non-READY we have to find at least + // one child token + if( current.getChildren().contains( vst.getSESE() ) ) { + + // if we ever have at least one child source with an + // unknown age, have to treat var as dynamic + if( vst.getAge().equals( OoOJavaAnalysis.maxSESEage ) ) { + return SrcType_DYNAMIC; + } + + // if we have a known-age child source, this var is + // either static or dynamic now: it's static if this + // source is the only source, otherwise dynamic + if( srcs.size() > 1 ) { + return SrcType_DYNAMIC; + } + + vstIfStatic.vst = vst; + return SrcType_STATIC; + } + } + + // if we never found a child source, all other + // sources must be READY before we could even + // begin executing! + return SrcType_READY; + } + + + // any reference variables that are not live can be pruned + // from the table, and if any VSTs are then no longer + // referenced, they can be dropped as well + // THIS CAUSES INCONSISTENCY, FIX LATER, NOT REQUIRED + public void pruneByLiveness( Set rootLiveSet ) { + + // the set of reference variables in the table minus the + // live set gives the set of reference variables to remove + Set deadRefVars = new HashSet(); + deadRefVars.addAll( var2vst.keySet() ); + + if( rootLiveSet != null ) { + deadRefVars.removeAll( rootLiveSet ); + } + + // just use the remove operation to prune the table now + Iterator deadItr = deadRefVars.iterator(); + while( deadItr.hasNext() ) { + TempDescriptor dead = deadItr.next(); + removePrivate( dead ); + } + + assertConsistency(); + } + + + + // use as an aid for debugging, where true-set is checked + // against the alternate mappings: assert that nothing is + // missing or extra in the alternates + public void assertConsistency() { + + Iterator itr; + Set s; + + Set trueSetByAlts = new HashSet(); + itr = sese2vst.entrySet().iterator(); + while( itr.hasNext() ) { + Map.Entry me = (Map.Entry) itr.next(); + FlatSESEEnterNode sese = (FlatSESEEnterNode) me.getKey(); + HashSet s1 = (HashSet) me.getValue(); + assert s1 != null; + + // the trueSet should have all entries in s1 + assert trueSet.containsAll( s1 ); + + // s1 should not have anything that doesn't appear in trueset + Set sInt = (Set) s1.clone(); + sInt.removeAll( trueSet ); + + assert sInt.isEmpty(); + + // add s1 to a running union--at the end check if trueSet has extra + trueSetByAlts.addAll( s1 ); + } + // make sure trueSet isn't too big + assert trueSetByAlts.containsAll( trueSet ); + + + trueSetByAlts = new HashSet(); + itr = var2vst.entrySet().iterator(); + while( itr.hasNext() ) { + Map.Entry me = (Map.Entry) itr.next(); + TempDescriptor var = (TempDescriptor) me.getKey(); + HashSet s1 = (HashSet) me.getValue(); + assert s1 != null; + + // the trueSet should have all entries in s1 + assert trueSet.containsAll( s1 ); + + // s1 should not have anything that doesn't appear in trueset + Set sInt = (Set) s1.clone(); + sInt.removeAll( trueSet ); + + assert sInt.isEmpty(); + + // add s1 to a running union--at the end check if trueSet has extra + trueSetByAlts.addAll( s1 ); + } + // make sure trueSet isn't too big + assert trueSetByAlts.containsAll( trueSet ); + + + trueSetByAlts = new HashSet(); + itr = sv2vst.entrySet().iterator(); + while( itr.hasNext() ) { + Map.Entry me = (Map.Entry) itr.next(); + SVKey key = (SVKey) me.getKey(); + HashSet s1 = (HashSet) me.getValue(); + assert s1 != null; + + // the trueSet should have all entries in s1 + assert trueSet.containsAll( s1 ); + + // s1 should not have anything that doesn't appear in trueset + Set sInt = (Set) s1.clone(); + sInt.removeAll( trueSet ); + + assert sInt.isEmpty(); + + // add s1 to a running union--at the end check if trueSet has extra + trueSetByAlts.addAll( s1 ); + } + // make sure trueSet isn't too big + assert trueSetByAlts.containsAll( trueSet ); + + + // also check that the reference var sets are consistent + Hashtable > vst2refVars = + new Hashtable >(); + itr = var2vst.entrySet().iterator(); + while( itr.hasNext() ) { + Map.Entry me = (Map.Entry) itr.next(); + TempDescriptor refVar = (TempDescriptor) me.getKey(); + HashSet s1 = (HashSet) me.getValue(); + Iterator vstItr = s1.iterator(); + while( vstItr.hasNext() ) { + VariableSourceToken vst = vstItr.next(); + assert vst.getRefVars().contains( refVar ); + + Set refVarsPart = vst2refVars.get( vst ); + if( refVarsPart == null ) { + refVarsPart = new HashSet(); + } + refVarsPart.add( refVar ); + vst2refVars.put( vst, refVarsPart ); + } + } + itr = vst2refVars.entrySet().iterator(); + while( itr.hasNext() ) { + Map.Entry me = (Map.Entry) itr.next(); + VariableSourceToken vst = (VariableSourceToken) me.getKey(); + Set s1 = (Set) me.getValue(); + + assert vst.getRefVars().equals( s1 ); + } + } + + + public boolean equals( Object o ) { + if( o == null ) { + return false; + } + + if( !(o instanceof VarSrcTokTable) ) { + return false; + } + + VarSrcTokTable table = (VarSrcTokTable) o; + return trueSet.equals( table.trueSet ); + } + + public int hashCode() { + return trueSet.hashCode(); + } + + public Iterator iterator() { + return trueSet.iterator(); + } + + public String toString() { + return toStringPretty(); + } + + public String toStringVerbose() { + return "trueSet ="+trueSet.toString()+"\n"+ + "sese2vst="+sese2vst.toString()+"\n"+ + "var2vst ="+var2vst.toString()+"\n"+ + "sv2vst ="+sv2vst.toString(); + } + + public String toStringPretty() { + String tokHighlighter = "o"; + + String str = "VarSrcTokTable\n"; + Iterator vstItr = trueSet.iterator(); + while( vstItr.hasNext() ) { + str += " "+tokHighlighter+" "+vstItr.next()+"\n"; + } + return str; + } + + public String toStringPrettyVerbose() { + String tokHighlighter = "o"; + + String str = "VarSrcTokTable\n"; + + Set s; + Iterator itr; + Iterator vstItr; + + str += " trueSet\n"; + vstItr = trueSet.iterator(); + while( vstItr.hasNext() ) { + str += " "+tokHighlighter+" "+vstItr.next()+"\n"; + } + + str += " sese2vst\n"; + itr = sese2vst.entrySet().iterator(); + while( itr.hasNext() ) { + Map.Entry me = (Map.Entry) itr.next(); + FlatSESEEnterNode sese = (FlatSESEEnterNode) me.getKey(); + HashSet s1 = (HashSet) me.getValue(); + assert s1 != null; + + str += " "+sese.getPrettyIdentifier()+" -> \n"; + + vstItr = s1.iterator(); + while( vstItr.hasNext() ) { + str += " "+tokHighlighter+" "+vstItr.next()+"\n"; + } + } + + str += " var2vst\n"; + itr = var2vst.entrySet().iterator(); + while( itr.hasNext() ) { + Map.Entry me = (Map.Entry) itr.next(); + TempDescriptor var = (TempDescriptor) me.getKey(); + Set s1 = (Set) me.getValue(); + assert s1 != null; + + str += " "+var+" -> \n"; + + vstItr = s1.iterator(); + while( vstItr.hasNext() ) { + str += " "+tokHighlighter+" "+vstItr.next()+"\n"; + } + } + + str += " sv2vst\n"; + itr = sv2vst.entrySet().iterator(); + while( itr.hasNext() ) { + Map.Entry me = (Map.Entry) itr.next(); + SVKey key = (SVKey) me.getKey(); + Set s1 = (Set) me.getValue(); + assert s1 != null; + + str += " "+key+" -> \n"; + + vstItr = s1.iterator(); + while( vstItr.hasNext() ) { + str += " "+tokHighlighter+" "+vstItr.next()+"\n"; + } + } + + return str; + } +} diff --git a/Robust/src/Analysis/OoOJava/VariableSourceToken.java b/Robust/src/Analysis/OoOJava/VariableSourceToken.java new file mode 100644 index 00000000..1d845074 --- /dev/null +++ b/Robust/src/Analysis/OoOJava/VariableSourceToken.java @@ -0,0 +1,82 @@ +package Analysis.OoOJava; + +import IR.*; +import IR.Flat.*; +import java.util.*; +import java.io.*; + +public class VariableSourceToken { + + private Set refVars; + private FlatSESEEnterNode sese; + private Integer seseAge; + private TempDescriptor addrVar; + + public VariableSourceToken( Set refVars, + FlatSESEEnterNode sese, + Integer seseAge, + TempDescriptor addrVar + ) { + this.refVars = refVars; + this.sese = sese; + this.seseAge = seseAge; + this.addrVar = addrVar; + } + + public Set getRefVars() { + return refVars; + } + + public FlatSESEEnterNode getSESE() { + return sese; + } + + public Integer getAge() { + return seseAge; + } + + public TempDescriptor getAddrVar() { + return addrVar; + } + + public VariableSourceToken copy() { + Set refVarsCopy = new HashSet(); + + Iterator rvItr = refVars.iterator(); + while( rvItr.hasNext() ) { + refVarsCopy.add( rvItr.next() ); + } + + return new VariableSourceToken( refVarsCopy, + sese, + new Integer( seseAge ), + addrVar ); + } + + public boolean equals( Object o ) { + if( o == null ) { + return false; + } + + if( !(o instanceof VariableSourceToken) ) { + return false; + } + + VariableSourceToken vst = (VariableSourceToken) o; + + // the reference vars have no bearing on equality + return sese.equals( vst.sese ) && + addrVar.equals( vst.addrVar ) && + seseAge.equals( vst.seseAge ); + } + + public int hashCode() { + // the reference vars have no bearing on hashCode + return (sese.hashCode() << 3) * (addrVar.hashCode() << 4) ^ seseAge.intValue(); + } + + + public String toString() { + return refVars+"\tref "+addrVar+"\t@"+sese.toPrettyString()+"("+seseAge+")"; + } +} diff --git a/Robust/src/Benchmarks/oooJava/barneshut/Barneshut.java b/Robust/src/Benchmarks/oooJava/barneshut/Barneshut.java index 42b97b11..688d0c91 100644 --- a/Robust/src/Benchmarks/oooJava/barneshut/Barneshut.java +++ b/Robust/src/Benchmarks/oooJava/barneshut/Barneshut.java @@ -244,13 +244,19 @@ public void ComputeCenterOfMass(ArrayIndexedGraph octree, ArrayIndexedNode roo for (int step = 0; step < local_ntimesteps; step++) { // time-step the system ComputeCenterAndDiameter(); ArrayIndexedGraph octree = new ArrayIndexedGraph(8); + genreach q1; ArrayIndexedNode root = octree.createNode(new OctTreeNodeData(centerx, centery, centerz)); // create the tree's root + genreach q2; octree.addNode(root); + genreach q3; double radius = diameter * 0.5; for (int i = 0; i < local_nbodies; i++) { + genreach r0; Insert(octree, root, body[i], radius); // grow the tree by inserting each body + genreach r1; body[i].root=root; + genreach r2; } curr = 0; // summarize subtree info in each internal node (plus restructure tree and sort bodies for performance reasons) @@ -265,7 +271,7 @@ public void ComputeCenterOfMass(ArrayIndexedGraph octree, ArrayIndexedNode roo double dt=dthf; double ep=epssq; sese parallel{ - eachbody.ComputeForce(octree, di, it, step, dt, ep); + eachbody.ComputeForce(octree, di, it, step, dt, ep); } } diff --git a/Robust/src/Benchmarks/oooJava/master-makefile b/Robust/src/Benchmarks/oooJava/master-makefile index 939c6334..00e1d0ad 100644 --- a/Robust/src/Benchmarks/oooJava/master-makefile +++ b/Robust/src/Benchmarks/oooJava/master-makefile @@ -73,10 +73,13 @@ DISJOINT= -disjoint -disjoint-k 1 -enable-assertions $(DRELEASEMODE) #-disjoint- # -disjoint-debug-snap-method Remove 10 3 true DISJOINTDEBUG= -justanalyze -disjoint -disjoint-k 1 -enable-assertions \ - -flatirusermethods \ - -disjoint-desire-determinism -# -disjoint-debug-scheduling + -disjoint-debug-callsite createNode run 100 50 false +# -disjoint-desire-determinism # -disjoint-debug-snap-method ComputeCenterOfMass 6 2 true +# -disjoint-debug-scheduling +# -flatirusermethods + + default: diff --git a/Robust/src/IR/Flat/BuildCode.java b/Robust/src/IR/Flat/BuildCode.java index dffb65c9..0e960d42 100644 --- a/Robust/src/IR/Flat/BuildCode.java +++ b/Robust/src/IR/Flat/BuildCode.java @@ -29,21 +29,16 @@ import Analysis.Disjoint.Effect; import Analysis.Disjoint.ReachGraph; import Analysis.Disjoint.Taint; import Analysis.OoOJava.OoOJavaAnalysis; +import Analysis.OoOJava.SESEandAgePair; +import Analysis.OoOJava.VariableSourceToken; +import Analysis.OoOJava.CodePlan; +import Analysis.OoOJava.ConflictNode; +import Analysis.OoOJava.SESEWaitingQueue; +import Analysis.OoOJava.VSTWrapper; import Analysis.Prefetch.*; import Analysis.Loops.WriteBarrier; import Analysis.Loops.GlobalFieldType; import Analysis.Locality.TypeAnalysis; -import Analysis.MLP.ConflictGraph; -import Analysis.MLP.ConflictNode; -import Analysis.MLP.MLPAnalysis; -import Analysis.MLP.ParentChildConflictsMap; -import Analysis.MLP.SESELock; -import Analysis.MLP.SESEWaitingQueue; -import Analysis.MLP.VariableSourceToken; -import Analysis.MLP.VSTWrapper; -import Analysis.MLP.CodePlan; -import Analysis.MLP.SESEandAgePair; -import Analysis.MLP.WaitingElement; import Util.CodePrinter; public class BuildCode { @@ -77,7 +72,6 @@ public class BuildCode { Hashtable> backuptable; SafetyAnalysis sa; PrefetchAnalysis pa; - MLPAnalysis mlpa; OoOJavaAnalysis oooa; String maxTaskRecSizeStr="__maxTaskRecSize___"; String mlperrstr = "if(status != 0) { "+ @@ -93,21 +87,20 @@ public class BuildCode { public BuildCode(State st, Hashtable temptovar, TypeUtil typeutil, SafetyAnalysis sa, PrefetchAnalysis pa) { - this(st, temptovar, typeutil, null, sa, pa, null, null); + this(st, temptovar, typeutil, null, sa, pa, null); } - public BuildCode(State st, Hashtable temptovar, TypeUtil typeutil, SafetyAnalysis sa, PrefetchAnalysis pa, MLPAnalysis mlpa, OoOJavaAnalysis oooa) { - this(st, temptovar, typeutil, null, sa, pa, mlpa, oooa); + public BuildCode(State st, Hashtable temptovar, TypeUtil typeutil, SafetyAnalysis sa, PrefetchAnalysis pa, OoOJavaAnalysis oooa) { + this(st, temptovar, typeutil, null, sa, pa, oooa); } - public BuildCode(State st, Hashtable temptovar, TypeUtil typeutil, LocalityAnalysis locality, PrefetchAnalysis pa, MLPAnalysis mlpa, OoOJavaAnalysis oooa) { - this(st, temptovar, typeutil, locality, null, pa, mlpa, oooa); + public BuildCode(State st, Hashtable temptovar, TypeUtil typeutil, LocalityAnalysis locality, PrefetchAnalysis pa, OoOJavaAnalysis oooa) { + this(st, temptovar, typeutil, locality, null, pa, oooa); } - public BuildCode(State st, Hashtable temptovar, TypeUtil typeutil, LocalityAnalysis locality, SafetyAnalysis sa, PrefetchAnalysis pa, MLPAnalysis mlpa, OoOJavaAnalysis oooa) { + public BuildCode(State st, Hashtable temptovar, TypeUtil typeutil, LocalityAnalysis locality, SafetyAnalysis sa, PrefetchAnalysis pa, OoOJavaAnalysis oooa) { this.sa=sa; this.pa=pa; - this.mlpa=mlpa; this.oooa=oooa; state=st; callgraph=new CallGraph(state); @@ -218,7 +211,7 @@ public class BuildCode { outmethodheader.println("#include \"abortreaders.h\""); outmethodheader.println("#include "); } - if (state.MLP || state.OOOJAVA) { + if (state.OOOJAVA) { outmethodheader.println("#include "); outmethodheader.println("#include "); outmethodheader.println("#include "); @@ -287,17 +280,12 @@ public class BuildCode { outputTaskTypes(outtask); } - if( state.MLP || state.OOOJAVA) { + if(state.OOOJAVA) { // have to initialize some SESE compiler data before // analyzing normal methods, which must happen before // generating SESE internal code - Iterator seseit; - if(state.MLP){ - seseit=mlpa.getAllSESEs().iterator(); - }else{ - seseit=oooa.getAllSESEs().iterator(); - } + Iterator seseit=oooa.getAllSESEs().iterator(); //TODO signal the object that will report errors if(state.RCR) { @@ -319,7 +307,7 @@ public class BuildCode { outputMethods(outmethod); // Output function prototypes and structures for SESE's and code - if( state.MLP || state.OOOJAVA ) { + if( state.OOOJAVA ) { // spit out a global to inform all worker threads with // the maximum size is for any task record @@ -331,11 +319,7 @@ public class BuildCode { // first generate code for each sese's internals Iterator seseit; - if(state.MLP){ - seseit=mlpa.getAllSESEs().iterator(); - }else{ - seseit=oooa.getAllSESEs().iterator(); - } + seseit=oooa.getAllSESEs().iterator(); while(seseit.hasNext()) { FlatSESEEnterNode fsen = seseit.next(); @@ -454,17 +438,13 @@ public class BuildCode { outputStaticBlocks(outmethod); outputClassObjects(outmethod); - if (state.MLP || state.OOOJAVA) { + if (state.OOOJAVA) { // do a calculation to determine which task record // is the largest, store that as a global value for // allocating records Iterator seseit; - if(state.MLP){ - seseit=mlpa.getAllSESEs().iterator(); - }else{ - seseit=oooa.getAllSESEs().iterator(); - } + seseit=oooa.getAllSESEs().iterator(); while(seseit.hasNext()){ FlatSESEEnterNode fsen = seseit.next(); outmethod.println("if( sizeof( "+fsen.getSESErecordName()+ @@ -476,7 +456,7 @@ public class BuildCode { outmethod.println(" runningSESE = NULL;"); - outmethod.println(" workScheduleInit( "+state.MLP_NUMCORES+", invokeSESEmethod );"); + outmethod.println(" workScheduleInit( "+state.OOO_NUMCORES+", invokeSESEmethod );"); //initializes data structures needed for the RCR traverser if(state.RCR && rcr != null) { @@ -601,7 +581,7 @@ public class BuildCode { if (state.THREAD||state.SINGLETM) outmethod.println("pthread_exit(NULL);"); - if (state.MLP || state.OOOJAVA ) { + if (state.OOOJAVA) { outmethod.println(" workScheduleBegin();"); } @@ -682,7 +662,7 @@ public class BuildCode { if (state.CONSCHECK) { outmethod.println("#include \"checkers.h\""); } - if (state.MLP || state.OOOJAVA ) { + if ( state.OOOJAVA ) { outmethod.println("#include "); outmethod.println("#include "); outmethod.println("#include \"mlp_runtime.h\""); @@ -749,7 +729,7 @@ public class BuildCode { outstructs.println("#define INTPTR int"); outstructs.println("#endif"); outstructs.println("#endif"); - if( state.MLP || state.OOOJAVA ) { + if( state.OOOJAVA ) { outstructs.println("#include \"mlp_runtime.h\""); outstructs.println("#include \"psemaphore.h\""); } @@ -847,7 +827,7 @@ public class BuildCode { //Print out definition for array type outclassdefs.println("struct "+arraytype+" {"); outclassdefs.println(" int type;"); - if(state.MLP || state.OOOJAVA ){ + if( state.OOOJAVA ){ outclassdefs.println(" int oid;"); outclassdefs.println(" int allocsite;"); } @@ -905,7 +885,7 @@ public class BuildCode { //Print out definition for Class type outclassdefs.println("struct Class {"); outclassdefs.println(" int type;"); - if(state.MLP || state.OOOJAVA ){ + if( state.OOOJAVA ){ outclassdefs.println(" int oid;"); outclassdefs.println(" int allocsite;"); } @@ -1265,7 +1245,7 @@ public class BuildCode { outclassdefs.print("#endif\n"); outclassdefs.print("int numprefetchsites = " + pa.prefetchsiteid + ";\n"); - if(this.state.MLP || state.OOOJAVA ){ + if( state.OOOJAVA ){ outclassdefs.print("extern __thread int oid;\n"); outclassdefs.print("extern int oidIncrement;\n"); } @@ -1700,7 +1680,7 @@ public class BuildCode { /* Output class structure */ classdefout.println("struct "+cn.getSafeSymbol()+" {"); classdefout.println(" int type;"); - if(state.MLP || state.OOOJAVA){ + if( state.OOOJAVA){ classdefout.println(" int oid;"); classdefout.println(" int allocsite;"); } @@ -2086,12 +2066,10 @@ public class BuildCode { } - if( state.MLP || state.OOOJAVA ) { + if( state.OOOJAVA ) { if( fm.getNext(0) instanceof FlatSESEEnterNode ) { FlatSESEEnterNode callerSESEplaceholder = (FlatSESEEnterNode) fm.getNext( 0 ); - if( (state.MLP && callerSESEplaceholder != mlpa.getMainSESE()) || - (state.OOOJAVA && callerSESEplaceholder != oooa.getMainSESE()) - ) { + if( callerSESEplaceholder != oooa.getMainSESE() ) { // declare variables for naming static SESE's output.println(" /* static SESE names */"); Iterator pItr = callerSESEplaceholder.getNeededStaticNames().iterator(); @@ -2113,19 +2091,19 @@ public class BuildCode { // set up related allocation sites's waiting queues // eom - if(state.MLP){ - ConflictGraph graph = null; - graph = mlpa.getConflictGraphResults().get(fm); - if (graph != null && graph.hasConflictEdge()) { - output.println(" /* set up waiting queues */"); + + FlatSESEEnterNode callerSESEplaceholder = (FlatSESEEnterNode) fm.getNext( 0 ); + if(callerSESEplaceholder!= oooa.getMainSESE()){ + Analysis.OoOJava.ConflictGraph graph = oooa.getConflictGraph(callerSESEplaceholder); + if (graph != null && graph.hasConflictEdge()) { + output.println(" // set up waiting queues "); output.println(" int numMemoryQueue=0;"); output.println(" int memoryQueueItemID=0;"); - HashSet lockSet = mlpa.getConflictGraphLockMap().get( - graph); + Set lockSet = oooa.getLockMappings(graph); System.out.println("#lockSet="+lockSet.hashCode()); System.out.println("lockset="+lockSet); for (Iterator iterator = lockSet.iterator(); iterator.hasNext();) { - SESELock seseLock = (SESELock) iterator.next(); + Analysis.OoOJava.SESELock seseLock = (Analysis.OoOJava.SESELock) iterator.next(); System.out.println("id="+seseLock.getID()); System.out.println("#="+seseLock); } @@ -2137,32 +2115,8 @@ public class BuildCode { output.println(); } } - }else{ - FlatSESEEnterNode callerSESEplaceholder = (FlatSESEEnterNode) fm.getNext( 0 ); - if(callerSESEplaceholder!= oooa.getMainSESE()){ - Analysis.OoOJava.ConflictGraph graph = oooa.getConflictGraph(callerSESEplaceholder); - if (graph != null && graph.hasConflictEdge()) { - output.println(" // set up waiting queues "); - output.println(" int numMemoryQueue=0;"); - output.println(" int memoryQueueItemID=0;"); - Set lockSet = oooa.getLockMappings(graph); - System.out.println("#lockSet="+lockSet.hashCode()); - System.out.println("lockset="+lockSet); - for (Iterator iterator = lockSet.iterator(); iterator.hasNext();) { - Analysis.OoOJava.SESELock seseLock = (Analysis.OoOJava.SESELock) iterator.next(); - System.out.println("id="+seseLock.getID()); - System.out.println("#="+seseLock); - } - System.out.println("size="+lockSet.size()); - if (lockSet.size() > 0) { - output.println(" numMemoryQueue=" + lockSet.size() + ";"); - output.println(" runningSESE->numMemoryQueue=numMemoryQueue;"); - output.println(" runningSESE->memoryQueueArray=mlpCreateMemoryQueueArray(numMemoryQueue);"); - output.println(); - } - } - } } + } @@ -2170,7 +2124,7 @@ public class BuildCode { /* Check to see if we need to do a GC if this is a * multi-threaded program...*/ - if (((state.MLP||state.OOOJAVA||state.THREAD||state.DSM||state.SINGLETM)&&GENERATEPRECISEGC) + if (((state.OOOJAVA||state.THREAD||state.DSM||state.SINGLETM)&&GENERATEPRECISEGC) || this.state.MULTICOREGC) { //Don't bother if we aren't in recursive methods...The loops case will catch it if (callgraph.getAllMethods(md).contains(md)) { @@ -2556,26 +2510,6 @@ public class BuildCode { } output.println(" }"); } - } else { - output.println(" // set up memory queues "); - output.println(" int numMemoryQueue=0;"); - output.println(" int memoryQueueItemID=0;"); - ConflictGraph graph = null; - graph = mlpa.getConflictGraphResults().get(fsen); - if (graph != null && graph.hasConflictEdge()) { - output.println(" {"); - HashSet lockSet = mlpa.getConflictGraphLockMap().get( - graph); - System.out.println("#lockSet="+lockSet); - - if (lockSet.size() > 0) { - output.println(" numMemoryQueue=" + lockSet.size() + "; "); - output.println(" runningSESE->numMemoryQueue=numMemoryQueue;"); - output.println(" runningSESE->memoryQueueArray=mlpCreateMemoryQueueArray(numMemoryQueue);"); - output.println(); - } - output.println(" }"); - } } @@ -2706,11 +2640,8 @@ public class BuildCode { outmethod.println( " switch( ((SESEcommon*)seseRecord)->classID ) {"); outmethod.println( " "); Iterator seseit; - if(state.MLP){ - seseit=mlpa.getAllSESEs().iterator(); - }else{ - seseit=oooa.getAllSESEs().iterator(); - } + seseit=oooa.getAllSESEs().iterator(); + while(seseit.hasNext()){ FlatSESEEnterNode fsen = seseit.next(); @@ -2718,9 +2649,7 @@ public class BuildCode { outmethod.println( " case "+fsen.getIdentifier()+":"); outmethod.println( " "+fsen.getSESEmethodName()+"( seseRecord );"); - if( (state.MLP && fsen.equals( mlpa.getMainSESE() )) || - (state.OOOJAVA && fsen.equals( oooa.getMainSESE() )) - ) { + if( fsen.equals( oooa.getMainSESE() ) ) { outmethod.println( " workScheduleExit();"); } @@ -2823,7 +2752,7 @@ public class BuildCode { output.println("primitives->"+tmp.getSafeSymbol()+"="+tmp.getSafeSymbol()+";"); } } - if ((state.MLP || state.OOOJAVA) && stopset!=null) { + if (state.OOOJAVA && stopset!=null) { assert first.getPrev( 0 ) instanceof FlatSESEEnterNode; assert current_node instanceof FlatSESEExitNode; FlatSESEEnterNode fsen = (FlatSESEEnterNode) first.getPrev( 0 ); @@ -2845,9 +2774,9 @@ public class BuildCode { current_node=null; } else if(current_node.numNext()==1) { FlatNode nextnode; - if ((state.MLP|| state.OOOJAVA) && - current_node.kind()==FKind.FlatSESEEnterNode && - !((FlatSESEEnterNode)current_node).getIsCallerSESEplaceholder() + if (state.OOOJAVA && + current_node.kind()==FKind.FlatSESEEnterNode //&& + //!((FlatSESEEnterNode)current_node).getIsCallerSESEplaceholder() ) { FlatSESEEnterNode fsen = (FlatSESEEnterNode)current_node; generateFlatNode(fm, lb, current_node, output); @@ -3217,14 +3146,9 @@ public class BuildCode { protected void generateFlatNode(FlatMethod fm, LocalityBinding lb, FlatNode fn, PrintWriter output) { // insert pre-node actions from the code plan - if( state.MLP|| state.OOOJAVA ) { + if( state.OOOJAVA ) { - CodePlan cp; - if(state.MLP){ - cp = mlpa.getCodePlan( fn ); - }else{ - cp = oooa.getCodePlan(fn); - } + CodePlan cp = oooa.getCodePlan(fn); if( cp != null ) { @@ -3266,11 +3190,11 @@ public class BuildCode { while( tdItr.hasNext() ) { TempDescriptor td = tdItr.next(); FlatMethod fmContext; - if( currentSESE.getIsCallerSESEplaceholder() ) { - fmContext = currentSESE.getfmEnclosing(); - } else { + //if( currentSESE.getIsCallerSESEplaceholder() ) { + // fmContext = currentSESE.getfmEnclosing(); + //} else { fmContext = currentSESE.getfmBogus(); - } + //} output.println(" "+generateTemp( fmContext, td, null )+ " = child->"+vst.getAddrVar().getSafeSymbol()+";"); } @@ -3313,11 +3237,11 @@ public class BuildCode { output.println(" }"); FlatMethod fmContext; - if( currentSESE.getIsCallerSESEplaceholder() ) { - fmContext = currentSESE.getfmEnclosing(); - } else { + //if( currentSESE.getIsCallerSESEplaceholder() ) { + // fmContext = currentSESE.getfmEnclosing(); + //} else { fmContext = currentSESE.getfmBogus(); - } + //} TypeDescriptor type = dynVar.getType(); String typeStr; @@ -3392,15 +3316,7 @@ public class BuildCode { // eom // handling stall site if (state.OOOJAVA) { - // NEED TO FIX IT - // assumes that there is only one parent, but it is possible that - // currentSESE has more than one so we need to generate - // conditional case for each parent case - Analysis.OoOJava.ConflictGraph graph = null; - if(currentSESE.getSESEParent().size()>0){ - graph = oooa.getConflictGraph(currentSESE.getSESEParent().iterator().next()); - } -// Analysis.OoOJava.ConflictGraph graph = oooa.getConflictGraph(currentSESE); + Analysis.OoOJava.ConflictGraph graph = oooa.getConflictGraph(currentSESE); if(graph!=null){ Set seseLockSet = oooa.getLockMappings(graph); Set waitingElementSet = graph.getStallSiteWaitingElementSet(fn, seseLockSet); @@ -3454,58 +3370,7 @@ public class BuildCode { } } } - } else{ - ParentChildConflictsMap conflictsMap = mlpa.getConflictsResults().get(fn); - if (conflictsMap != null) { - Set allocSet = conflictsMap.getAllocationSiteIDSetofStallSite(); - if (allocSet.size() > 0) { - FlatNode enclosingFlatNode=null; - if( currentSESE.getIsCallerSESEplaceholder() && currentSESE.getParent()==null){ - enclosingFlatNode=currentSESE.getfmEnclosing(); - }else{ - enclosingFlatNode=currentSESE; - } - ConflictGraph graph=mlpa.getConflictGraphResults().get(enclosingFlatNode); - HashSet seseLockSet=mlpa.getConflictGraphLockMap().get(graph); - Set waitingElementSet=graph.getStallSiteWaitingElementSet(conflictsMap, seseLockSet); - - if(waitingElementSet.size()>0){ - output.println("// stall on parent's stall sites "); - output.println(" {"); - output.println(" REntry* rentry;"); - - for (Iterator iterator = waitingElementSet.iterator(); iterator.hasNext();) { - WaitingElement waitingElement = (WaitingElement) iterator.next(); - - if( waitingElement.getStatus() >= ConflictNode.COARSE ){ - // HERE! a parent might conflict with a child - output.println(" rentry=mlpCreateREntry(runningSESE->memoryQueueArray["+ waitingElement.getQueueID()+ "],"+ waitingElement.getStatus()+ ", runningSESE);"); - } else { - output.println(" rentry=mlpCreateFineREntry(runningSESE->memoryQueueArray["+ waitingElement.getQueueID()+ "],"+ waitingElement.getStatus()+ ", runningSESE, (void*)&___locals___."+ waitingElement.getDynID() + ");"); - } - output.println(" rentry->parentStallSem=&runningSESEstallSem;"); - output.println(" psem_reset( &runningSESEstallSem);"); - output.println(" rentry->tag=runningSESEstallSem.tag;"); - output.println(" rentry->queue=runningSESE->memoryQueueArray["+ waitingElement.getQueueID()+ "];"); - output.println(" if(ADDRENTRY(runningSESE->memoryQueueArray["+ waitingElement.getQueueID()+"],rentry)==NOTREADY) {"); - if( state.COREPROF ) { - output.println("#ifdef CP_EVENTID_TASKSTALLMEM"); - output.println(" CP_LOGEVENT( CP_EVENTID_TASKSTALLMEM, CP_EVENTTYPE_BEGIN );"); - output.println("#endif"); - } - output.println(" psem_take( &runningSESEstallSem, (struct garbagelist *)&___locals___ );"); - if( state.COREPROF ) { - output.println("#ifdef CP_EVENTID_TASKSTALLMEM"); - output.println(" CP_LOGEVENT( CP_EVENTID_TASKSTALLMEM, CP_EVENTTYPE_END );"); - output.println("#endif"); - } - output.println(" } "); - } - output.println(" }"); - } - } - } - } + } } } @@ -3602,7 +3467,7 @@ public class BuildCode { if(state.DSM&&state.SANDBOX&&(locality.getAtomic(lb).get(fn).intValue()>0)) { output.println("if (unlikely((--transaction_check_counter)<=0)) checkObjects();"); } - if (((state.MLP|| state.OOOJAVA||state.THREAD||state.DSM||state.SINGLETM)&&GENERATEPRECISEGC) + if (((state.OOOJAVA||state.THREAD||state.DSM||state.SINGLETM)&&GENERATEPRECISEGC) || (this.state.MULTICOREGC)) { if(state.DSM&&locality.getAtomic(lb).get(fn).intValue()>0) { output.println("if (needtocollect) checkcollect2("+localsprefixaddr+");"); @@ -3635,15 +3500,7 @@ public class BuildCode { throw new Error(); } - // insert post-node actions from the code-plan - /* - if( state.MLP) { - CodePlan cp = mlpa.getCodePlan( fn ); - - if( cp != null ) { - } - } - */ + // insert post-node actions from the code-plan (none right now...) } public void generateFlatOffsetNode(FlatMethod fm, LocalityBinding lb, FlatOffsetNode fofn, PrintWriter output) { @@ -4022,22 +3879,20 @@ public class BuildCode { LocalityBinding lb, FlatSESEEnterNode fsen, PrintWriter output) { - // if MLP flag is off, okay that SESE nodes are in IR graph, + // if OOOJAVA flag is off, okay that SESE nodes are in IR graph, // just skip over them and code generates exactly the same - if( !(state.MLP || state.OOOJAVA) ) { + if( !state.OOOJAVA ) { return; } // there may be an SESE in an unreachable method, skip over - if( (state.MLP && !mlpa.getAllSESEs().contains( fsen )) || - (state.OOOJAVA && !oooa.getAllSESEs().contains(fsen)) - ) { + if( !oooa.getAllSESEs().contains(fsen) ) { return; } // also, if we have encountered a placeholder, just skip it - if( fsen.getIsCallerSESEplaceholder() ) { - return; - } + //if( fsen.getIsCallerSESEplaceholder() ) { + // return; + //} output.println(" {"); @@ -4049,9 +3904,7 @@ public class BuildCode { // before doing anything, lock your own record and increment the running children - if( (state.MLP && fsen != mlpa.getMainSESE()) || - (state.OOOJAVA && fsen != oooa.getMainSESE()) - ) { + if( fsen != oooa.getMainSESE() ) { output.println(" childSESE++;"); } @@ -4061,9 +3914,7 @@ public class BuildCode { output.println( "#ifdef CP_EVENTID_POOLALLOC"); output.println( " CP_LOGEVENT( CP_EVENTID_POOLALLOC, CP_EVENTTYPE_BEGIN );"); output.println( "#endif"); - if( (state.MLP && fsen != mlpa.getMainSESE()) || - (state.OOOJAVA && fsen != oooa.getMainSESE()) - ) { + if( fsen != oooa.getMainSESE() ) { output.println(" "+ fsen.getSESErecordName()+"* seseToIssue = ("+ fsen.getSESErecordName()+"*) poolalloc( runningSESE->taskRecordMemPool );"); @@ -4157,15 +4008,14 @@ public class BuildCode { // otherwise use the parent's enclosing method as the context boolean useParentContext = false; - if( (state.MLP && fsen != mlpa.getMainSESE()) || - (state.OOOJAVA && fsen != oooa.getMainSESE()) - ) { - assert fsen.getParent() != null; - if( !fsen.getParent().getIsCallerSESEplaceholder() ) { + if( fsen != oooa.getMainSESE() ) { + assert fsen.getParents() != null; + //if( !fsen.getParent().getIsCallerSESEplaceholder() ) { useParentContext = true; - } + //} } + /* if( useParentContext ) { output.println(" seseToIssue->"+temp+" = "+ generateTemp( fsen.getParent().getfmBogus(), temp, null )+";"); @@ -4173,6 +4023,7 @@ public class BuildCode { output.println(" seseToIssue->"+temp+" = "+ generateTemp( fsen.getfmEnclosing(), temp, null )+";"); } + */ } // before potentially adding this SESE to other forwarding lists, @@ -4181,9 +4032,7 @@ public class BuildCode { output.println(" pthread_mutex_init( &(seseToIssue->common.lock), NULL );"); output.println("#endif"); - if( (state.MLP && fsen != mlpa.getMainSESE()) || - (state.OOOJAVA && fsen != oooa.getMainSESE()) - ) { + if( fsen != oooa.getMainSESE() ) { // count up outstanding dependencies, static first, then dynamic Iterator staticSrcsItr = fsen.getStaticInVarSrcs().iterator(); while( staticSrcsItr.hasNext() ) { @@ -4240,21 +4089,19 @@ public class BuildCode { output.println(" } else {"); boolean useParentContext = false; - if( (state.MLP && fsen != mlpa.getMainSESE()) || - (state.OOOJAVA && fsen != oooa.getMainSESE()) - ) { - assert fsen.getParent() != null; - if( !fsen.getParent().getIsCallerSESEplaceholder() ) { + if( fsen != oooa.getMainSESE() ) { + //assert fsen.getParent() != null; + //if( !fsen.getParent().getIsCallerSESEplaceholder() ) { useParentContext = true; - } - } - if( useParentContext ) { - output.println(" seseToIssue->"+dynInVar+" = "+ - generateTemp( fsen.getParent().getfmBogus(), dynInVar, null )+";"); - } else { - output.println(" seseToIssue->"+dynInVar+" = "+ - generateTemp( fsen.getfmEnclosing(), dynInVar, null )+";"); - } + //} + } + //if( useParentContext ) { + // output.println(" seseToIssue->"+dynInVar+" = "+ + // generateTemp( fsen.getParent().getfmBogus(), dynInVar, null )+";"); + //} else { + // output.println(" seseToIssue->"+dynInVar+" = "+ + // generateTemp( fsen.getfmEnclosing(), dynInVar, null )+";"); + //} output.println(" }"); output.println(" }"); @@ -4271,8 +4118,8 @@ public class BuildCode { // instances from static names SESEandAgePair pairNewest = new SESEandAgePair( fsen, 0 ); SESEandAgePair pairOldest = new SESEandAgePair( fsen, fsen.getOldestAgeToTrack() ); - if( fsen.getParent() != null && - fsen.getParent().getNeededStaticNames().contains( pairNewest ) + if( true//fsen.getParent() != null && + //fsen.getParent().getNeededStaticNames().contains( pairNewest ) ) { output.println(" {"); output.println("#ifndef OOO_DISABLE_TASKMEMPOOL" ); @@ -4313,9 +4160,9 @@ public class BuildCode { // assumes that there is only one parent, but it is possible that // currentSESE has more than one so we need to generate // conditional case for each parent case - assert fsen.getSESEParent().size()>0; - FlatSESEEnterNode parent = fsen.getSESEParent().iterator().next(); - Analysis.OoOJava.ConflictGraph graph = oooa.getConflictGraph(parent); + assert fsen.getParents().size()>0; + FlatSESEEnterNode parent = fsen.getParents().iterator().next(); + Analysis.OoOJava.ConflictGraph graph = oooa.getConflictGraph(parent); if (graph != null && graph.hasConflictEdge()) { Set seseLockSet = oooa.getLockMappings(graph); output.println(); @@ -4408,131 +4255,6 @@ public class BuildCode { } output.println(); } - } else { - ConflictGraph graph = null; - FlatSESEEnterNode parent = fsen.getParent(); - if (parent != null) { - if (parent.isCallerSESEplaceholder) { - graph = mlpa.getConflictGraphResults().get(parent.getfmEnclosing()); - } else { - graph = mlpa.getConflictGraphResults().get(parent); - } - } - if (graph != null && graph.hasConflictEdge()) { - HashSet seseLockSet = mlpa.getConflictGraphLockMap() - .get(graph); - output.println(); - output.println(" //add memory queue element"); - SESEWaitingQueue seseWaitingQueue=graph.getWaitingElementSetBySESEID(fsen.getIdentifier(), - seseLockSet); - if(seseWaitingQueue.getWaitingElementSize()>0){ - output.println(" {"); - output.println(" REntry* rentry=NULL;"); - output.println(" INTPTR* pointer=NULL;"); - output.println(" seseToIssue->common.rentryIdx=0;"); - - Set queueIDSet=seseWaitingQueue.getQueueIDSet(); - for (Iterator iterator = queueIDSet.iterator(); iterator - .hasNext();) { - Integer key = (Integer) iterator.next(); - int queueID=key.intValue(); - Set waitingQueueSet = seseWaitingQueue.getWaitingElementSet(queueID); - int enqueueType=seseWaitingQueue.getType(queueID); - if(enqueueType==SESEWaitingQueue.EXCEPTION){ - output.println(" INITIALIZEBUF(runningSESE->memoryQueueArray[" - + queueID+ "]);"); - } - for (Iterator iterator2 = waitingQueueSet.iterator(); iterator2 - .hasNext();) { - WaitingElement waitingElement = (WaitingElement) iterator2 - .next(); - if (waitingElement.getStatus() >= ConflictNode.COARSE) { - output.println(" rentry=mlpCreateREntry(runningSESE->memoryQueueArray["+ queueID+ "]," - + waitingElement.getStatus() - + ", &(seseToIssue->common));"); - } else { - TempDescriptor td = waitingElement - .getTempDesc(); - // decide whether waiting element is dynamic or - // static - if (fsen.getDynamicInVarSet().contains(td)) { - // dynamic in-var case - output.println(" pointer=seseToIssue->" - + waitingElement.getDynID() - + "_srcSESE+seseToIssue->" - + waitingElement.getDynID() - + "_srcOffset;"); - output - .println(" rentry=mlpCreateFineREntry(runningSESE->memoryQueueArray["+ queueID+ "]," - + waitingElement - .getStatus() - + ", &(seseToIssue->common), pointer );"); - } else if (fsen.getStaticInVarSet() - .contains(td)) { - // static in-var case - VariableSourceToken vst = fsen - .getStaticInVarSrc(td); - if (vst != null) { - - String srcId = "SESE_" - + vst.getSESE() - .getPrettyIdentifier() - + vst.getSESE().getIdentifier() - + "_" + vst.getAge(); - output - .println(" pointer=(void*)&seseToIssue->" - + srcId - + "->" - + waitingElement - .getDynID() - + ";"); - output - .println(" rentry=mlpCreateFineREntry(runningSESE->memoryQueueArray["+ queueID+ "]," - + waitingElement - .getStatus() - + ", &(seseToIssue->common), pointer );"); - - } - } else { - output - .println(" rentry=mlpCreateFineREntry(runningSESE->memoryQueueArray["+ queueID+ "]," - + waitingElement - .getStatus() - + ", &(seseToIssue->common), (void*)&seseToIssue->" - + waitingElement.getDynID() - + ");"); - } - } - output - .println(" rentry->queue=runningSESE->memoryQueueArray[" - + waitingElement.getQueueID() - + "];"); - - if(enqueueType==SESEWaitingQueue.NORMAL){ - output - .println(" seseToIssue->common.rentryArray[seseToIssue->common.rentryIdx++]=rentry;"); - output - .println(" if(ADDRENTRY(runningSESE->memoryQueueArray[" - + waitingElement.getQueueID() - + "],rentry)==NOTREADY){"); - output.println(" ++(localCount);"); - output.println(" } "); - }else{ - output - .println(" ADDRENTRYTOBUF(runningSESE->memoryQueueArray[" - + waitingElement.getQueueID() - + "],rentry);"); - } - } - if(enqueueType!=SESEWaitingQueue.NORMAL){ - output.println(" localCount+=RESOLVEBUF(runningSESE->memoryQueueArray[" - + queueID+ "],&seseToIssue->common);"); - } - } - output.println(" }"); - } - output.println(); - } } } @@ -4571,8 +4293,8 @@ public class BuildCode { // assumes that there is only one parent, but it is possible that // currentSESE has more than one so we need to generate // conditional case for each parent case - assert fsen.getSESEParent().size()>0; - FlatSESEEnterNode parent = fsen.getSESEParent().iterator().next(); + assert fsen.getParents().size()>0; + FlatSESEEnterNode parent = fsen.getParents().iterator().next(); Analysis.OoOJava.ConflictGraph graph = oooa.getConflictGraph(parent); if (graph != null && graph.hasConflictEdge()) { Set seseLockSet = oooa.getLockMappings(graph); @@ -4675,9 +4397,9 @@ public class BuildCode { FlatSESEExitNode fsexn, PrintWriter output) { - // if MLP flag is off, okay that SESE nodes are in IR graph, + // if OOOJAVA flag is off, okay that SESE nodes are in IR graph, // just skip over them and code generates exactly the same - if( ! (state.MLP || state.OOOJAVA) ) { + if( !state.OOOJAVA ) { return; } @@ -4685,16 +4407,14 @@ public class BuildCode { FlatSESEEnterNode fsen = fsexn.getFlatEnter(); // there may be an SESE in an unreachable method, skip over - if( (state.MLP && !mlpa.getAllSESEs().contains( fsen )) || - (state.OOOJAVA && !oooa.getAllSESEs().contains( fsen )) - ) { + if( !oooa.getAllSESEs().contains( fsen ) ) { return; } // also, if we have encountered a placeholder, just jump it - if( fsen.getIsCallerSESEplaceholder() ) { - return; - } + //if( fsen.getIsCallerSESEplaceholder() ) { + // return; + //} if( state.COREPROF ) { output.println("#ifdef CP_EVENTID_TASKEXECUTE"); @@ -4741,21 +4461,19 @@ public class BuildCode { // have to determine the context enclosing this sese boolean useParentContext = false; - if( (state.MLP &&fsen != mlpa.getMainSESE()) || - (state.OOOJAVA &&fsen != oooa.getMainSESE()) - ) { - assert fsen.getParent() != null; - if( !fsen.getParent().getIsCallerSESEplaceholder() ) { + if( fsen != oooa.getMainSESE() ) { + assert fsen.getParents() != null; + //if( !fsen.getParent().getIsCallerSESEplaceholder() ) { useParentContext = true; - } + //} } String from; - if( useParentContext ) { - from = generateTemp( fsen.getParent().getfmBogus(), temp, null ); - } else { + //if( useParentContext ) { + //from = generateTemp( fsen.getParent().getfmBogus(), temp, null ); + //} else { from = generateTemp( fsen.getfmEnclosing(), temp, null ); - } + //} output.println(" "+paramsprefix+ "->"+temp.getSafeSymbol()+ @@ -4766,9 +4484,7 @@ public class BuildCode { output.println(" runningSESE->doneExecuting = TRUE;"); // if parent is stalling on you, let them know you're done - if( (state.MLP && fsexn.getFlatEnter() != mlpa.getMainSESE()) || - (state.OOOJAVA && fsexn.getFlatEnter() != oooa.getMainSESE()) - ) { + if( fsexn.getFlatEnter() != oooa.getMainSESE() ) { output.println(" if( runningSESE->parentsStallSem != NULL ) {"); output.println(" psem_give( runningSESE->parentsStallSem );"); output.println(" }"); @@ -4800,8 +4516,7 @@ public class BuildCode { // clean up its lock element from waiting queue, and decrement dependency count for next SESE block - if((state.MLP && fsen != mlpa.getMainSESE()) || - (state.OOOJAVA && fsen != oooa.getMainSESE())) { + if( fsen != oooa.getMainSESE() ) { output.println(); output.println(" /* check memory dependency*/"); output.println(" {"); @@ -4885,9 +4600,7 @@ public class BuildCode { // if this is not the Main sese (which has no parent) then return // THIS task's record to the PARENT'S task record pool, and only if // the reference count is now zero - if( (state.MLP && fsen != mlpa.getMainSESE()) || - (state.OOOJAVA && fsen != oooa.getMainSESE()) - ) { + if( fsen != oooa.getMainSESE() ) { output.println("#ifndef OOO_DISABLE_TASKMEMPOOL" ); output.println(" RELEASE_REFERENCE_TO( runningSESE );"); output.println("#endif // OOO_DISABLE_TASKMEMPOOL" ); @@ -4924,9 +4637,9 @@ public class BuildCode { FlatWriteDynamicVarNode fwdvn, PrintWriter output ) { - if( !(state.MLP || state.OOOJAVA) ) { + if( !state.OOOJAVA ) { // should node should not be in an IR graph if the - // MLP flag is not set + // OOOJAVA flag is not set throw new Error("Unexpected presence of FlatWriteDynamicVarNode"); } @@ -5653,7 +5366,7 @@ public class BuildCode { if (fn.isGlobal()&&(state.DSM||state.SINGLETM)) { output.println(generateTemp(fm,fn.getDst(),lb)+"=allocate_newarrayglobal("+arrayid+", "+generateTemp(fm, fn.getSize(),lb)+");"); } else if ((GENERATEPRECISEGC) || (this.state.MULTICOREGC)) { - if(this.state.MLP || state.OOOJAVA){ + if(state.OOOJAVA){ output.println(generateTemp(fm,fn.getDst(),lb)+"=allocate_newarray_mlp("+localsprefixaddr+", "+arrayid+", "+generateTemp(fm, fn.getSize(),lb)+", oid, "+oooa.getDisjointAnalysis().getAllocationSiteFromFlatNew(fn).getUniqueAllocSiteID()+");"); output.println(" oid += oidIncrement;"); }else{ @@ -5666,7 +5379,7 @@ public class BuildCode { if (fn.isGlobal()&&(state.DSM||state.SINGLETM)) { output.println(generateTemp(fm,fn.getDst(),lb)+"=allocate_newglobal("+fn.getType().getClassDesc().getId()+");"); } else if ((GENERATEPRECISEGC) || (this.state.MULTICOREGC)) { - if (this.state.MLP || state.OOOJAVA){ + if (state.OOOJAVA){ output.println(generateTemp(fm,fn.getDst(),lb)+"=allocate_new_mlp("+localsprefixaddr+", "+fn.getType().getClassDesc().getId()+", oid, "+oooa.getDisjointAnalysis().getAllocationSiteFromFlatNew(fn).getUniqueAllocSiteID()+");"); output.println(" oid += oidIncrement;"); } else { diff --git a/Robust/src/IR/Flat/BuildFlat.java b/Robust/src/IR/Flat/BuildFlat.java index c9f4b783..44201311 100644 --- a/Robust/src/IR/Flat/BuildFlat.java +++ b/Robust/src/IR/Flat/BuildFlat.java @@ -157,29 +157,24 @@ public class BuildFlat { while(methodit.hasNext()) { currmd=(MethodDescriptor)methodit.next(); - // if MLP is on, splice a special SESE in to - // enclose the main method, and a special SESE - // in around every other method that statically - // represents the SESE instance that will call - // that method at runtime + // if OOOJava is on, splice a special SESE in to + // enclose the main method + boolean spliceInImplicitMain = + state.OOOJAVA && + currmd.equals( typeutil.getMain() ); + FlatSESEEnterNode spliceSESE = null; FlatSESEExitNode spliceExit = null; - if( state.MLP || state.OOOJAVA ) { - if( currmd.equals( typeutil.getMain() ) ) { - SESENode mainTree = new SESENode( "main" ); - spliceSESE = new FlatSESEEnterNode( mainTree ); - spliceExit = new FlatSESEExitNode ( mainTree ); - spliceSESE.setFlatExit ( spliceExit ); - spliceExit.setFlatEnter( spliceSESE ); - } else { - SESENode callerSESETree = new SESENode( "caller SESE placeholder" ); - spliceSESE = new FlatSESEEnterNode( callerSESETree ); - spliceSESE.setCallerSESEplaceholder(); - spliceExit = new FlatSESEExitNode ( callerSESETree ); - spliceSESE.setFlatExit ( spliceExit ); - spliceExit.setFlatEnter( spliceSESE ); - } - } + + if( spliceInImplicitMain ) { + SESENode mainTree = new SESENode( "main" ); + spliceSESE = new FlatSESEEnterNode( mainTree ); + spliceExit = new FlatSESEExitNode ( mainTree ); + spliceSESE.setFlatExit ( spliceExit ); + spliceExit.setFlatEnter( spliceSESE ); + spliceSESE.setIsMainSESE(); + } + fe=new FlatExit(); @@ -216,8 +211,7 @@ public class BuildFlat { } else if (np.getEnd()!=null&&np.getEnd().kind()!=FKind.FlatReturnNode) { FlatNode rnflat=null; - // splice implicit SESE exit after method body - if( state.MLP || state.OOOJAVA ) { + if( spliceInImplicitMain ) { np.getEnd().addNext(spliceExit); rnflat=spliceReturn(spliceExit); } else { @@ -225,16 +219,14 @@ public class BuildFlat { } rnflat.addNext(fe); } else if (np.getEnd()!=null) { - // splice implicit SESE exit after method body - if( state.MLP || state.OOOJAVA ) { + if( spliceInImplicitMain ) { FlatReturnNode rnflat=(FlatReturnNode)np.getEnd(); np.getEnd().addNext(spliceExit); spliceExit.addNext(fe); } } - // splice an implicit SESE enter before method body - if( state.MLP || state.OOOJAVA ) { + if( spliceInImplicitMain ) { spliceSESE.addNext(fn); fn=spliceSESE; } diff --git a/Robust/src/IR/Flat/FlatSESEEnterNode.java b/Robust/src/IR/Flat/FlatSESEEnterNode.java index ca92eadc..875cd8a9 100644 --- a/Robust/src/IR/Flat/FlatSESEEnterNode.java +++ b/Robust/src/IR/Flat/FlatSESEEnterNode.java @@ -5,11 +5,8 @@ import java.util.Set; import java.util.Vector; import java.util.Iterator; import java.util.Collection; - -import Analysis.MLP.SESEEffectsKey; -import Analysis.MLP.SESEEffectsSet; -import Analysis.MLP.SESEandAgePair; -import Analysis.MLP.VariableSourceToken; +import Analysis.OoOJava.VariableSourceToken; +import Analysis.OoOJava.SESEandAgePair; import Analysis.OwnershipAnalysis.HeapRegionNode; import IR.ClassDescriptor; import IR.FieldDescriptor; @@ -26,16 +23,32 @@ public class FlatSESEEnterNode extends FlatNode { private int id; protected FlatSESEExitNode exit; protected SESENode treeNode; - protected FlatSESEEnterNode parent; protected Integer oldestAgeToTrack; - protected boolean isCallerSESEplaceholder; + // a leaf tasks simply has no children, ever protected static final int ISLEAF_UNINIT = 1; protected static final int ISLEAF_FALSE = 2; protected static final int ISLEAF_TRUE = 3; protected int isLeafSESE; + // there is only one main sese that is implicit + // (spliced in by the compiler around whole program) + protected boolean isMainSESE; + + // all children tasks, INCLUDING those that are reachable + // by calling methods protected Set children; + + // all possible parents + protected Set parents; + + // sometimes it is useful to know the locally defined + // parent or children of an SESE for various analysis, + // and by local it is one SESE nested within another + // in a single method context + protected Set localChildren; + protected FlatSESEEnterNode localParent; + protected Set inVars; protected Set outVars; @@ -52,7 +65,6 @@ public class FlatSESEEnterNode extends FlatNode { protected Hashtable staticInVar2src; - private SESEEffectsSet seseEffectsSet; // a subset of the in-set variables that shouuld be traversed during // the dynamic coarse grained conflict strategy, remember them here so @@ -76,21 +88,15 @@ public class FlatSESEEnterNode extends FlatNode { protected String firstDepRecField; protected int numDepRecs; - // a set of sese located at the first in transitive call chain - // starting from the current sese - protected Set seseChildren; - - // a set of complete parent sese, not bogus one - protected Set seseParent; - public FlatSESEEnterNode( SESENode sn ) { this.id = identifier++; treeNode = sn; - parent = null; oldestAgeToTrack = new Integer( 0 ); - children = new HashSet(); + parents = new HashSet(); + localChildren = new HashSet(); + localParent = null; inVars = new HashSet(); outVars = new HashSet(); needStaticNameInCode = new HashSet(); @@ -99,23 +105,19 @@ public class FlatSESEEnterNode extends FlatNode { staticInVars = new HashSet(); dynamicInVars = new HashSet(); dynamicVars = new HashSet(); - seseChildren = new HashSet(); - seseParent = new HashSet(); inVarsForDynamicCoarseConflictResolution = new Vector(); staticInVar2src = new Hashtable(); - seseEffectsSet = new SESEEffectsSet(); - fmEnclosing = null; mdEnclosing = null; cdEnclosing = null; - isCallerSESEplaceholder = false; - isLeafSESE = ISLEAF_UNINIT; + isMainSESE = false; + firstDepRecField = null; numDepRecs = 0; } @@ -134,6 +136,14 @@ public class FlatSESEEnterNode extends FlatNode { return exit; } + public void setIsMainSESE() { + isMainSESE = true; + } + + public boolean getIsMainSESE() { + return isMainSESE; + } + public int kind() { return FKind.FlatSESEEnterNode; } @@ -161,22 +171,46 @@ public class FlatSESEEnterNode extends FlatNode { return "sese "+getPrettyIdentifier()+getIdentifier(); } - public void setParent( FlatSESEEnterNode parent ) { - this.parent = parent; + + + public void addParent( FlatSESEEnterNode parent ) { + parents.add( parent ); + } + + public Set getParents() { + return parents; } - public FlatSESEEnterNode getParent() { - return parent; + public void setLocalParent( FlatSESEEnterNode parent ) { + localParent = parent; + } + + public FlatSESEEnterNode getLocalParent() { + return localParent; } public void addChild( FlatSESEEnterNode child ) { children.add( child ); } + public void addChildren( Set batch ) { + children.addAll( batch ); + } + public Set getChildren() { return children; } + public void addLocalChild( FlatSESEEnterNode child ) { + localChildren.add( child ); + } + + public Set getLocalChildren() { + return localChildren; + } + + + public void addInVar( TempDescriptor td ) { if (!inVars.contains(td)) inVars.add( td ); @@ -351,27 +385,6 @@ public class FlatSESEEnterNode extends FlatNode { "_SESErec"; } - public void setCallerSESEplaceholder() { - isCallerSESEplaceholder = true; - } - - public boolean getIsCallerSESEplaceholder() { - return isCallerSESEplaceholder; - } - - public void addSESEChildren(FlatSESEEnterNode child){ - seseChildren.add(child); - } - - public void addSESEChildren(Set children){ - - seseChildren.addAll(children); - } - - public Set getSESEChildren(){ - return seseChildren; - } - public boolean equals( Object o ) { if( o == null ) { return false; @@ -389,20 +402,6 @@ public class FlatSESEEnterNode extends FlatNode { return 31*id; } - public void writeEffects(TempDescriptor td, String fd, TypeDescriptor type, HeapRegionNode hrn, boolean strongUpdate){ - seseEffectsSet.addWritingVar(td, new SESEEffectsKey(fd, type, hrn.getID(), hrn.getGloballyUniqueIdentifier())); - if(strongUpdate){ - seseEffectsSet.addStrongUpdateVar(td, new SESEEffectsKey(fd, type, hrn.getID(), hrn.getGloballyUniqueIdentifier())); - } - } - - public void readEffects(TempDescriptor td, String fd, TypeDescriptor type, HeapRegionNode hrn ){ - seseEffectsSet.addReadingVar(td, new SESEEffectsKey(fd, type, hrn.getID(), hrn.getGloballyUniqueIdentifier())); - } - - public SESEEffectsSet getSeseEffectsSet(){ - return seseEffectsSet; - } public void setFirstDepRecField( String field ) { @@ -445,13 +444,5 @@ public class FlatSESEEnterNode extends FlatNode { return isLeafSESE == ISLEAF_TRUE; } - - public Set getSESEParent() { - return seseParent; - } - - public void addSESEParent(FlatSESEEnterNode seseParent) { - this.seseParent.add(seseParent); - } } diff --git a/Robust/src/IR/Flat/FlatWriteDynamicVarNode.java b/Robust/src/IR/Flat/FlatWriteDynamicVarNode.java index 2f2119ea..d29cb613 100644 --- a/Robust/src/IR/Flat/FlatWriteDynamicVarNode.java +++ b/Robust/src/IR/Flat/FlatWriteDynamicVarNode.java @@ -1,9 +1,9 @@ package IR.Flat; -import Analysis.MLP.VSTWrapper; +import Analysis.OoOJava.VSTWrapper; import java.util.Hashtable; -// This node is inserted by the MLP analysis +// This node is inserted by the OOOJava analysis // in between a (tail -> head) IR graph edge. // It is for tracking SESE variables with // dynamic sources diff --git a/Robust/src/IR/Flat/RuntimeConflictResolver.java b/Robust/src/IR/Flat/RuntimeConflictResolver.java index 32b216e7..413aea88 100644 --- a/Robust/src/IR/Flat/RuntimeConflictResolver.java +++ b/Robust/src/IR/Flat/RuntimeConflictResolver.java @@ -9,7 +9,6 @@ import java.util.Set; import java.util.Vector; import Util.Pair; import Analysis.Disjoint.*; -import Analysis.MLP.CodePlan; import IR.State; import IR.TypeDescriptor; import Analysis.OoOJava.ConflictGraph; @@ -17,6 +16,7 @@ import Analysis.OoOJava.ConflictNode; import Analysis.OoOJava.OoOJavaAnalysis; import Analysis.OoOJava.SESELock; import Analysis.OoOJava.WaitingElement; +import Analysis.OoOJava.CodePlan; import Util.CodePrinter; /* An instance of this class manages all OoOJava coarse-grained runtime conflicts @@ -155,9 +155,8 @@ public class RuntimeConflictResolver { for(Iterator seseit = oooa.getAllSESEs().iterator();seseit.hasNext();) { fsen = seseit.next(); - if ( fsen.getSESEParent().size() > 0 && - !fsen.getIsCallerSESEplaceholder() && - (parentSESE = (FlatSESEEnterNode) fsen.getSESEParent().iterator().next()) != null && + if ( fsen.getParents().size() > 0 && + (parentSESE = (FlatSESEEnterNode) fsen.getParents().iterator().next()) != null && (conflictGraph = oooa.getConflictGraph(parentSESE)) != null && (conflicts = conflictGraph.getConflictEffectSet(fsen)) != null && (rg = disjointAnaylsis.getEnterReachGraph(fsen)) != null ){ @@ -173,19 +172,9 @@ public class RuntimeConflictResolver { FlatNode fn = codeit.next(); CodePlan cp = oooa.getCodePlan(fn); fsen = cp.getCurrentSESE(); - - // jjenista - I think the following code is WRONG!!! (but right... :( ) - // see note in OoOJavaAnalysis.java explaining that conflict graphs are - // correct but stored in a parent's parent by mistake, and then in places - // like this we look to the parent's parent for the correct conflict graph. - // It should be oooa.getConflictGraph(fsen) which is the task enclosing the - // stall site, and who's children might conflict with the stall site. - // DON'T CHANGE IT unless you are willing to find the many, many dependent - // code sections based on this behavior, but understand what is happening. - - if( fsen.getSESEParent().size() != 0 && - (parentSESE = (FlatSESEEnterNode)fsen.getSESEParent().iterator().next()) != null && - (conflictGraph = oooa.getConflictGraph(parentSESE)) != null && + + if( fsen.getParents().size() != 0 && + (conflictGraph = oooa.getConflictGraph(fsen)) != null && (conflicts = conflictGraph.getConflictEffectSet(fn)) != null && (rg = disjointAnaylsis.getEnterReachGraph(fn)) != null ){ @@ -214,8 +203,7 @@ public class RuntimeConflictResolver { if(generalDebug) { System.out.println(rblock); - System.out.println(rblock.getIsCallerSESEplaceholder()); - System.out.println(rblock.getParent()); + System.out.println(rblock.getParents()); System.out.println("CG=" + conflictGraph); if(verboseDebug) rg.writeGraph("RCR_RG_SESE_DEBUG"+removeInvalidChars(rblock.getPrettyIdentifier())); @@ -525,7 +513,7 @@ public class RuntimeConflictResolver { // FIX IT LATER! Right now, we assume that there is only one parent // JCJ ask yong hun what we should do in the multi-parent future! - FlatSESEEnterNode parentSESE = (FlatSESEEnterNode) fsen.getSESEParent().iterator().next(); + FlatSESEEnterNode parentSESE = (FlatSESEEnterNode) fsen.getParents().iterator().next(); ConflictGraph graph = oooa.getConflictGraph(parentSESE); String id = tmp + "_sese" + fsen.getPrettyIdentifier(); ConflictNode node = graph.getId2cn().get(id); @@ -846,7 +834,7 @@ public class RuntimeConflictResolver { public boolean hasEmptyTraversers(FlatSESEEnterNode fsen) { boolean hasEmpty = true; - Set children = fsen.getSESEChildren(); + Set children = fsen.getChildren(); for (Iterator iterator = children.iterator(); iterator.hasNext();) { FlatSESEEnterNode child = (FlatSESEEnterNode) iterator.next(); hasEmpty &= child.getInVarsForDynamicCoarseConflictResolution().size() == 0; diff --git a/Robust/src/IR/State.java b/Robust/src/IR/State.java index 8b61997a..b9bbfafb 100644 --- a/Robust/src/IR/State.java +++ b/Robust/src/IR/State.java @@ -118,10 +118,8 @@ public class State { public boolean THREAD=false; public boolean CONSCHECK=false; public boolean INSTRUCTIONFAILURE=false; - public boolean MLP=false; - public boolean MLPDEBUG=false; - public int MLP_NUMCORES=0; - public int MLP_MAXSESEAGE=0; + public int OOO_NUMCORES=0; + public int OOO_MAXSESEAGE=0; public boolean METHODEFFECTS=false; public static double TRUEPROB=0.8; public static boolean PRINTFLAT=false; diff --git a/Robust/src/Main/Main.java b/Robust/src/Main/Main.java index 4ace49de..d9687ab2 100644 --- a/Robust/src/Main/Main.java +++ b/Robust/src/Main/Main.java @@ -42,7 +42,6 @@ import Analysis.Locality.GenerateConversions; import Analysis.Prefetch.PrefetchAnalysis; import Analysis.FlatIRGraph.FlatIRGraph; import Analysis.OwnershipAnalysis.OwnershipAnalysis; -import Analysis.MLP.MLPAnalysis; import Analysis.Disjoint.DisjointAnalysis; import Analysis.OoOJava.OoOJavaAnalysis; import Analysis.Loops.*; @@ -314,16 +313,7 @@ public class Main { else if (option.equals("-abcclose")) state.ARRAYBOUNDARYCHECK=false; - else if (option.equals("-mlp")) { - state.MLP = true; - state.OWNERSHIP = true; - state.MLP_NUMCORES = Integer.parseInt( args[++i] ); - state.MLP_MAXSESEAGE = Integer.parseInt( args[++i] ); - - } else if (option.equals("-mlpdebug")) { - state.MLPDEBUG=true; - - } else if (option.equals("-methodeffects")) { + else if (option.equals("-methodeffects")) { state.METHODEFFECTS=true; } else if (option.equals("-coreprof")) { @@ -332,8 +322,8 @@ public class Main { } else if (option.equals("-ooojava")) { state.OOOJAVA = true; state.DISJOINT = true; - state.MLP_NUMCORES = Integer.parseInt( args[++i] ); - state.MLP_MAXSESEAGE = Integer.parseInt( args[++i] ); + state.OOO_NUMCORES = Integer.parseInt( args[++i] ); + state.OOO_MAXSESEAGE = Integer.parseInt( args[++i] ); } else if (option.equals("-ooodebug") ){ state.OOODEBUG = true; @@ -437,7 +427,6 @@ public class Main { bf.buildFlat(); SafetyAnalysis sa=null; PrefetchAnalysis pa=null; - MLPAnalysis mlpa=null; OoOJavaAnalysis oooa=null; if (state.INLINEATOMIC) { Iterator classit=state.getClassSymbolTable().getDescriptorsIterator(); @@ -499,7 +488,7 @@ public class Main { state.FLATIRGRAPHLIBMETHODS); } - if (state.OWNERSHIP && !state.MLP) { + if (state.OWNERSHIP) { CallGraph callGraph = new CallGraph(state); Liveness liveness = new Liveness(); ArrayReferencees ar = new ArrayReferencees(state); @@ -515,31 +504,11 @@ public class Main { state.METHODEFFECTS); } - if (state.MLP) { - CallGraph callGraph = new CallGraph(state); - Liveness liveness = new Liveness(); - ArrayReferencees ar = new ArrayReferencees(state); - OwnershipAnalysis oa = new OwnershipAnalysis(state, - tu, - callGraph, - liveness, - ar, - state.OWNERSHIPALLOCDEPTH, - state.OWNERSHIPWRITEDOTS, - state.OWNERSHIPWRITEALL, - state.OWNERSHIPALIASFILE, - state.METHODEFFECTS); - mlpa = new MLPAnalysis(state, - tu, - callGraph, - oa); - } - if (state.DISJOINT && !state.OOOJAVA) { CallGraph cg = new CallGraph(state); Liveness l = new Liveness(); ArrayReferencees ar = new ArrayReferencees(state); - DisjointAnalysis da = new DisjointAnalysis(state, tu, cg, l, ar, null, null, null); + DisjointAnalysis da = new DisjointAnalysis(state, tu, cg, l, ar, null, null); } if (state.OOOJAVA) { @@ -659,10 +628,10 @@ public class Main { } LocalityAnalysis la=new LocalityAnalysis(state, callgraph, tu); GenerateConversions gc=new GenerateConversions(la, state); - BuildCode bc=new BuildCode(state, bf.getMap(), tu, la, pa, mlpa,oooa); + BuildCode bc=new BuildCode(state, bf.getMap(), tu, la, pa, oooa); bc.buildCode(); } else { - BuildCode bc=new BuildCode(state, bf.getMap(), tu, sa, pa, mlpa,oooa); + BuildCode bc=new BuildCode(state, bf.getMap(), tu, sa, pa, oooa); bc.buildCode(); } } diff --git a/Robust/src/Makefile b/Robust/src/Makefile index 2ec3843b..6de9d90c 100644 --- a/Robust/src/Makefile +++ b/Robust/src/Makefile @@ -91,12 +91,6 @@ Analysis/OwnershipAnalysis/ParameterDecomposition.class \ Analysis/OwnershipAnalysis/AccessPath.class \ Analysis/Disjoint/DisjointAnalysis.class \ Analysis/Disjoint/ReachGraph.class \ -Analysis/MLP/MLPAnalysis.class \ -Analysis/MLP/VariableSourceToken.class \ -Analysis/MLP/VSTWrapper.class \ -Analysis/MLP/SVKey.class \ -Analysis/MLP/VarSrcTokTable.class \ -Analysis/MLP/CodePlan.class \ Analysis/OoOJava/OoOJavaAnalysis.class \ Analysis/OoOJava/CodePlan.class \ Analysis/OoOJava/SVKey.class \ @@ -136,7 +130,6 @@ JAVAFILES=IR/*.java \ Analysis/Locality/*.java \ Analysis/OwnershipAnalysis/*.java \ Analysis/Disjoint/*.java \ - Analysis/MLP/*.java \ Analysis/OoOJava/*.java \ Analysis/Prefetch/*.java \ Analysis/Scheduling/*.java \ @@ -188,13 +181,13 @@ mytabbing: javadoc: mkdir javadoc - javadoc -classpath ../cup:.:$(CLASSPATH) -sourcepath . -private -d javadoc Lex Util IR IR.Tree IR.Flat Analysis Analysis.CallGraph Analysis.Flag Analysis.TaskStateAnalysis Analysis.Locality Analysis.Prefetch Main Analysis.OwnershipAnalysis Analysis.Disjoint Analysis.MLP Analysis.Scheduling + javadoc -classpath ../cup:.:$(CLASSPATH) -sourcepath . -private -d javadoc Lex Util IR IR.Tree IR.Flat Analysis Analysis.CallGraph Analysis.Flag Analysis.TaskStateAnalysis Analysis.Locality Analysis.Prefetch Main Analysis.OwnershipAnalysis Analysis.Disjoint Analysis.Scheduling clean: - rm -f IR/*.class IR/Tree/*.class Main/*.class Lex/*.class Parse/*.class Parse/Sym.java Parse/Parser.java IR/Flat/*.class classdefs.h methodheaders.h methods.c structdefs.h virtualtable.h task.h taskdefs.c taskdefs.h Analysis/*.class Analysis/Flag/*.class Analysis/CallGraph/*.class Analysis/TaskStateAnalysis/*.class Interface/*.class Util/*.class Analysis/Locality/*.class Analysis/Prefetch/*.class Analysis/FlatIRGraph/*.class Analysis/OwnershipAnalysis/*.class Analysis/Disjoint/*.class Analysis/OoOJava/*.class Analysis/MLP/*.class Analysis/Scheduling/*.class Analysis/Loops/*.class + rm -f IR/*.class IR/Tree/*.class Main/*.class Lex/*.class Parse/*.class Parse/Sym.java Parse/Parser.java IR/Flat/*.class classdefs.h methodheaders.h methods.c structdefs.h virtualtable.h task.h taskdefs.c taskdefs.h Analysis/*.class Analysis/Flag/*.class Analysis/CallGraph/*.class Analysis/TaskStateAnalysis/*.class Interface/*.class Util/*.class Analysis/Locality/*.class Analysis/Prefetch/*.class Analysis/FlatIRGraph/*.class Analysis/OwnershipAnalysis/*.class Analysis/Disjoint/*.class Analysis/OoOJava/*.class Analysis/Scheduling/*.class Analysis/Loops/*.class cleanclass: - rm -f IR/*.class IR/Tree/*.class Main/*.class IR/Flat/*.class Analysis/*.class Analysis/Flag/*.class Analysis/CallGraph/*.class Analysis/TaskStateAnalysis/*.class Interface/*.class Util/*.class Analysis/Locality/*.class Analysis/Prefetch/*.class Analysis/FlatIRGraph/*.class Analysis/OwnershipAnalysis/*.class Analysis/Disjoint/*.class Analysis/OoOJava/*.class Analysis/MLP/*.class Analysis/Scheduling/*.class Analysis/Loops/*.class + rm -f IR/*.class IR/Tree/*.class Main/*.class IR/Flat/*.class Analysis/*.class Analysis/Flag/*.class Analysis/CallGraph/*.class Analysis/TaskStateAnalysis/*.class Interface/*.class Util/*.class Analysis/Locality/*.class Analysis/Prefetch/*.class Analysis/FlatIRGraph/*.class Analysis/OwnershipAnalysis/*.class Analysis/Disjoint/*.class Analysis/OoOJava/*.class Analysis/Scheduling/*.class Analysis/Loops/*.class cleandoc: rm -rf javadoc diff --git a/Robust/src/Tests/disjoint/converge00/makefile b/Robust/src/Tests/disjoint/converge00/makefile new file mode 100644 index 00000000..5e0f1428 --- /dev/null +++ b/Robust/src/Tests/disjoint/converge00/makefile @@ -0,0 +1,28 @@ +PROGRAM=test + +SOURCE_FILES=$(PROGRAM).java + +BUILDSCRIPT=~/research/Robust/src/buildscript +BSFLAGS= -mainclass Test -disjoint -disjoint-k 1 -enable-assertions +# -disjoint-write-dots final -disjoint-alias-file aliases.txt normal -justanalyze -joptimize -flatirusermethods + +all: $(PROGRAM).bin + +view: PNGs + eog *.png & + +PNGs: DOTs + d2p *COMPLETE*.dot + +DOTs: $(PROGRAM).bin + +$(PROGRAM).bin: $(SOURCE_FILES) + $(BUILDSCRIPT) $(BSFLAGS) -o $(PROGRAM) $(SOURCE_FILES) + +clean: + rm -f $(PROGRAM).bin + rm -fr tmpbuilddirectory + rm -f *~ + rm -f *.dot + rm -f *.png + rm -f aliases.txt diff --git a/Robust/src/Tests/disjoint/converge00/test.java b/Robust/src/Tests/disjoint/converge00/test.java new file mode 100644 index 00000000..391d7958 --- /dev/null +++ b/Robust/src/Tests/disjoint/converge00/test.java @@ -0,0 +1,44 @@ +public class Foo { + public Foo() { + f = null; + } + public Foo f; +} + +public class Test { + static public void main( String[] args ) { + Foo a = new Foo(); + //Foo b = f0( a ); + //b.f = new Foo(); + + /* + Foo ptr = a; + int cnt = 0; + while( ptr != null ) { + cnt++; + ptr = ptr.f; + } + + System.out.println( "expecting 7, "+cnt ); + */ + } + + static public Foo f0( Foo a ) { + a.f = new Foo(); + Foo b = f1( a.f ); + b.f = new Foo(); + return b.f; + } + + static public Foo f1( Foo a ) { + a.f = new Foo(); + Foo b = f2( a.f ); + b.f = new Foo(); + return b.f; + } + + static public Foo f2( Foo a ) { + a.f = new Foo(); + return a.f; + } +} diff --git a/Robust/src/Tests/disjoint/returnValAssign/makefile b/Robust/src/Tests/disjoint/returnValAssign/makefile new file mode 100644 index 00000000..b36b083b --- /dev/null +++ b/Robust/src/Tests/disjoint/returnValAssign/makefile @@ -0,0 +1,27 @@ +PROGRAM=test + +SOURCE_FILES=$(PROGRAM).java + +BUILDSCRIPT=~/research/Robust/src/buildscript +BSFLAGS= -joptimize -flatirusermethods -mainclass Test -justanalyze -disjoint -disjoint-k 1 -disjoint-write-dots final -disjoint-alias-file aliases.txt normal -enable-assertions + +all: $(PROGRAM).bin + +view: PNGs + eog *.png & + +PNGs: DOTs + d2p *COMPLETE*.dot + +DOTs: $(PROGRAM).bin + +$(PROGRAM).bin: $(SOURCE_FILES) + $(BUILDSCRIPT) $(BSFLAGS) -o $(PROGRAM) $(SOURCE_FILES) + +clean: + rm -f $(PROGRAM).bin + rm -fr tmpbuilddirectory + rm -f *~ + rm -f *.dot + rm -f *.png + rm -f aliases.txt diff --git a/Robust/src/Tests/disjoint/returnValAssign/test.java b/Robust/src/Tests/disjoint/returnValAssign/test.java new file mode 100644 index 00000000..c3904780 --- /dev/null +++ b/Robust/src/Tests/disjoint/returnValAssign/test.java @@ -0,0 +1,17 @@ +public class Foo { + public Foo() {} + public Foo f; +} + +public class Test { + static public void main( String[] args ) { + Foo a = disjoint A new Foo(); + genreach r2; + Foo b = createFoo(); + genreach r3; + } + + static public Foo createFoo() { + return disjoint B new Foo(); + } +} diff --git a/Robust/src/Tests/oooJava/conflict-graph-location/makefile b/Robust/src/Tests/oooJava/conflict-graph-location/makefile new file mode 100644 index 00000000..f206390a --- /dev/null +++ b/Robust/src/Tests/oooJava/conflict-graph-location/makefile @@ -0,0 +1,59 @@ +PROGRAM=Test + +SOURCE_FILES=test.java + +BUILDSCRIPT=../../../buildscript + +COREPROFOVERFLOW= #-coreprof-checkoverflow +USECOREPROF= #-coreprof $(COREPROFOVERFLOW) \ + -coreprof-eventwords 1024*1024*128 \ + -coreprof-enable cpe_main \ + -coreprof-enable cpe_runmalloc \ + -coreprof-enable cpe_runfree \ + -coreprof-enable cpe_count_poolalloc \ + -coreprof-enable cpe_count_poolreuse \ + -coreprof-enable cpe_workschedgrab \ + -coreprof-enable cpe_taskdispatch \ + -coreprof-enable cpe_taskexecute \ + -coreprof-enable cpe_taskretire +# -coreprof-enable cpe_taskstallvar \ +# -coreprof-enable cpe_taskstallmem + + +DISJOINT= -disjoint -disjoint-k 1 -enable-assertions #-disjoint-desire-determinism + +USEOOO= -ooojava 24 2 -ooodebug -squeue +USERCR= -ooojava 23 2 -rcr -ooodebug -squeue + +BSFLAGS= -justanalyze -64bit -mainclass $(PROGRAM) -heapsize-mb 1024 -garbagestats -noloop -joptimize -debug #-ooodebug-disable-task-mem-pool + + +all: ooo + + +single: + $(BUILDSCRIPT) $(BSFLAGS) -thread -o $(PROGRAM)s -builddir sing $(SOURCE_FILES) + + +ooo: $(PROGRAM)p.bin + +$(PROGRAM)p.bin: $(SOURCE_FILES) makefile + $(BUILDSCRIPT) $(BSFLAGS) $(USECOREPROF) $(USEOOO) $(DISJOINT) -o $(PROGRAM)p -builddir par $(SOURCE_FILES) + +rcr: $(PROGRAM)r.bin + +$(PROGRAM)r.bin: $(SOURCE_FILES) makefile + $(BUILDSCRIPT) $(BSFLAGS) $(USECOREPROF) $(USERCR) $(DISJOINT) -o $(PROGRAM)r -builddir rcr $(SOURCE_FILES) + + +clean: + rm -f $(PROGRAM)p.bin $(PROGRAM)r.bin $(PROGRAM)s.bin + rm -fr par rcr sing + rm -f *~ + rm -f *.dot + rm -f *.png + rm -f *.txt + rm -f aliases.txt + rm -f mlpReport*txt + rm -f results*txt + rm -f coreprof.dat diff --git a/Robust/src/Tests/oooJava/conflict-graph-location/test.java b/Robust/src/Tests/oooJava/conflict-graph-location/test.java new file mode 100644 index 00000000..da360f4e --- /dev/null +++ b/Robust/src/Tests/oooJava/conflict-graph-location/test.java @@ -0,0 +1,117 @@ +public class Foo { + public int z; + public Foo() {} +} + +public class Test { + + /* + static public void main( String args[] ) { + FOOO(); + } + + static public void FOOO() { + + int x = 1000000; + + for( int i = 0; i < 200000; ++i ) { + rblock a { + Foo f = new Foo(); + f.z = 0; + ++f.z; + } + rblock b { + --f.z; + } + int y = -1000; + if( i % 2 == 0 ) { + y = 1000; + } + + if( f.z > 0 ) { + System.out.println( "WHOA WHOA WHOA" ); + } + x += f.z + y; + } + + System.out.println( x ); + } + */ + + /* + static public void main( String args[] ) { + + int x = 1000000; + + for( int i = 0; i < 200000; ++i ) { + + Foo f = new Foo(); + f.z = 0; + + int y = -1000; + if( i % 2 == 0 ) { + y = 1000; + } + + rblock g { + f.z--; + } + + aCall( f ); + + x += f.z + y; + } + + System.out.println( x ); + } + + static public void aCall( Foo f ) { + f.z++; + + if( f.z > 0 ) { + System.out.println( "WHOA WHOA WHOA" ); + } + } + + static public void yo() { + rblock h { + int x = 2; + } + } + */ + + + static public void main( String args[] ) { + + int x = 1; + + rblock a { + x++; + } + + x--; + + int y = yo(); + + x = x - y; + + rblock c { + x++; + } + + x--; + + System.out.println( x ); + } + + static public int yo() { + int j = 0; + + rblock b { + j++; + } + + j--; + return j; + } +}