return codePlans.keySet();
}
+ public DisjointAnalysis getDisjointAnalysis() {
+ return disjointAnalysisTaints;
+ }
+
+
public OoOJavaAnalysis(State state,
TypeUtil typeUtil,
CallGraph callGraph,
// 1st pass, find basic rblock relations & potential stall sites
rblockRel = new RBlockRelationAnalysis(state, typeUtil, callGraph);
+ VarSrcTokTable.rblockRel = rblockRel;
// 2nd pass, liveness, in-set out-set (no virtual reads yet!)
Iterator<MethodDescriptor> methItr = descriptorsToAnalyze.iterator();
livenessAnalysisBackward(fm);
}
- /*
// 3rd pass, variable analysis
methItr = descriptorsToAnalyze.iterator();
while (methItr.hasNext()) {
livenessAnalysisBackward(fm);
}
+ /*
// 5th pass, use disjointness with NO FLAGGED REGIONS
// to compute taints and effects
disjointAnalysisTaints =
}
*/
- /*
if (state.OOODEBUG) {
try {
writeReports("");
- disjointAnalysisTaints.getEffectsAnalysis().writeEffects("effects.txt");
- writeConflictGraph();
+ //disjointAnalysisTaints.getEffectsAnalysis().writeEffects("effects.txt");
+ //writeConflictGraph();
} catch (IOException e) {}
}
- */
System.out.println("\n\n\n##########################################################\n"+
"Warning, lots of code changes going on, OoOJava and RCR/DFJ\n"+
curr.merge(incoming);
}
- Set<FlatSESEEnterNode> possiblyExecuting =
- rblockRel.getPossibleExecutingRBlocks( fn );
-
- if (!possiblyExecuting.isEmpty()) {
- variable_nodeActions(fn, curr, possiblyExecuting);
+ FlatSESEEnterNode currentSESE = rblockRel.getLocalInnerRBlock( fn );
+ if( currentSESE == null ) {
+ currentSESE = rblockRel.getCallerProxySESE();
}
+
+ variable_nodeActions(fn, curr, currentSESE);
// if a new result, schedule forward nodes for analysis
if (!curr.equals(prev)) {
}
}
- private void variable_nodeActions(FlatNode fn,
- VarSrcTokTable vstTable,
- Set<FlatSESEEnterNode> currentSESEs) {
+ private void variable_nodeActions(FlatNode fn,
+ VarSrcTokTable vstTable,
+ FlatSESEEnterNode currentSESE) {
switch (fn.kind()) {
+
case FKind.FlatSESEEnterNode: {
FlatSESEEnterNode fsen = (FlatSESEEnterNode) fn;
- // ignore currently executing SESEs, at this point
+ // ignore currently executing SESE, at this point
// the analysis considers a new instance is becoming
// the current SESE
vstTable.age(fsen);
vstTable.assertConsistency();
} break;
+
case FKind.FlatSESEExitNode: {
FlatSESEExitNode fsexn = (FlatSESEExitNode) fn;
// of parent or sibling sources
Set<TempDescriptor> liveVars = livenessGlobalView.get(fn);
Set<TempDescriptor> fsenVirtReads =
- vstTable.calcVirtReadsAndPruneParentAndSiblingTokens(fsen, liveVars);
+ vstTable.calcVirtReadsAndPruneParentAndSiblingTokens(fsen,
+ liveVars);
Set<TempDescriptor> fsenVirtReadsOld = livenessVirtualReads.get(fn);
if (fsenVirtReadsOld != null) {
vstTable.assertConsistency();
} break;
+
case FKind.FlatOpNode: {
FlatOpNode fon = (FlatOpNode) fn;
HashSet<TempDescriptor> ts = new HashSet<TempDescriptor>();
ts.add(lhs);
- ///////////////// TODO !!!!!!!!!!!!!!!!!////////////////
- // @$@$@$@$#%@%$^@%^@$&@#$^&%&*$&*(%^*(%^*()%^*()
- /*
- if (currentSESE.getChildren().contains(vst.getSESE())) {
+ // when we do x = y for variables, just copy over from a child,
+ // there are two cases:
+ // 1. if the current task is the caller proxy, any local root is a child
+ boolean case1 =
+ currentSESE.getIsCallerProxySESE() &&
+ rblockRel.getLocalRootSESEs().contains( vst.getSESE() );
+
+ // 2. if the child task is a locally-defined child of the current task
+ boolean case2 = currentSESE.getLocalChildren().contains( vst.getSESE() );
+
+ if( case1 || case2 ) {
// if the source comes from a child, copy it over
- forAddition.add(new VariableSourceToken(ts, vst.getSESE(), vst.getAge(), vst.getAddrVar()));
+ forAddition.add( new VariableSourceToken( ts,
+ vst.getSESE(),
+ vst.getAge(),
+ vst.getAddrVar()
+ )
+ );
} else {
// otherwise, stamp it as us as the source
- forAddition.add(new VariableSourceToken(ts, currentSESE, new Integer(0), lhs));
+ forAddition.add( new VariableSourceToken( ts,
+ currentSESE,
+ new Integer( 0 ),
+ lhs
+ )
+ );
}
- */
}
- vstTable.addAll(forAddition);
+ vstTable.addAll( forAddition );
// only break if this is an ASSIGN op node,
// otherwise fall through to default case
// fall through to this default case
default: {
TempDescriptor[] writeTemps = fn.writesTemps();
- if (writeTemps.length > 0) {
+ if( writeTemps.length > 0 ) {
// for now, when writeTemps > 1, make sure
// its a call node, programmer enforce only
// doing stuff like calling a print routine
- // assert writeTemps.length == 1;
- if (writeTemps.length > 1) {
+ if( writeTemps.length > 1 ) {
assert fn.kind() == FKind.FlatCall || fn.kind() == FKind.FlatMethod;
break;
}
- vstTable.remove(writeTemps[0]);
+ vstTable.remove( writeTemps[0] );
HashSet<TempDescriptor> ts = new HashSet<TempDescriptor>();
- ts.add(writeTemps[0]);
-
- ///////////////// TODO !!!!!!!!!!!!!!!!!////////////////
- // @$@$@$@$#%@%$^@%^@$&@#$^&%&*$&*(%^*(%^*()%^*()
- //vstTable.add(new VariableSourceToken(ts, currentSESE, new Integer(0), writeTemps[0]));
+ ts.add( writeTemps[0] );
+
+ vstTable.add( new VariableSourceToken( ts,
+ currentSESE,
+ new Integer( 0 ),
+ writeTemps[0]
+ )
+ );
}
vstTable.assertConsistency();
- }
- break;
+ } break;
} // end switch
}
+
private void notAvailableForward(FlatMethod fm) {
Set<FlatNode> flatNodesToVisit = new HashSet<FlatNode>();
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");
+ BufferedWriter bw = new BufferedWriter(new FileWriter("ooojReport_summary.txt"));
+ bw.write("OoOJava Analysis Results\n\n");
bw.write(timeReport + "\n\n");
printSESEHierarchy(bw);
bw.write("\n");
".txt"));
bw.write("OoOJava Results for " + md + "\n-------------------\n");
- FlatSESEEnterNode implicitSESE = (FlatSESEEnterNode) fm.getNext(0);
+ //FlatSESEEnterNode implicitSESE = (FlatSESEEnterNode) fm.getNext(0);
//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("Dynamic vars to manage:\n " + implicitSESE.getDynamicVarSet());
bw.write("\n\nLive-In, Root View\n------------------\n" + fm.printMethod(livenessGlobalView));
bw.write("\n\nVariable Results-Out\n----------------\n" + fm.printMethod(variableResults));
- bw.write("\n\nNot Available Results-Out\n---------------------\n"
- + fm.printMethod(notAvailableResults));
- bw.write("\n\nCode Plans\n----------\n" + fm.printMethod(codePlans));
+ //bw.write("\n\nNot Available Results-Out\n---------------------\n"
+ // + fm.printMethod(notAvailableResults));
+ //bw.write("\n\nCode Plans\n----------\n" + fm.printMethod(codePlans));
bw.close();
}
}
}
private void printSESEHierarchy(BufferedWriter bw) throws java.io.IOException {
- bw.write("SESE Hierarchy\n--------------\n");
- Iterator<FlatSESEEnterNode> rootItr = rblockRel.getAllSESEs().iterator();
+ bw.write("SESE Local Hierarchy\n--------------\n");
+ Iterator<FlatSESEEnterNode> rootItr = rblockRel.getLocalRootSESEs().iterator();
while (rootItr.hasNext()) {
FlatSESEEnterNode root = rootItr.next();
- //if (root.getIsCallerSESEplaceholder()) {
- // if (!root.getChildren().isEmpty()) {
- // printSESEHierarchyTree(bw, root, 0);
- // }
- //} else {
- printSESEHierarchyTree(bw, root, 0);
- //}
+ printSESEHierarchyTree(bw, root, 0);
}
}
- private void printSESEHierarchyTree(BufferedWriter bw, FlatSESEEnterNode fsen, int depth)
- throws java.io.IOException {
+ private void printSESEHierarchyTree(BufferedWriter bw,
+ FlatSESEEnterNode fsen,
+ int depth
+ ) throws java.io.IOException {
for (int i = 0; i < depth; ++i) {
bw.write(" ");
}
bw.write("- " + fsen.getPrettyIdentifier() + "\n");
- Iterator<FlatSESEEnterNode> childItr = fsen.getChildren().iterator();
+ Iterator<FlatSESEEnterNode> childItr = fsen.getLocalChildren().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<FlatSESEEnterNode> rootItr = null; //rblockRel.getRootSESEs().iterator();
- while (rootItr.hasNext()) {
- FlatSESEEnterNode root = rootItr.next();
- //if (root.getIsCallerSESEplaceholder()) {
- // if (!root.getChildren().isEmpty()) {
- // printSESEInfoTree(bw, root);
- // }
- //} else {
- printSESEInfoTree(bw, root);
- //}
- }
- }
+ Iterator<FlatSESEEnterNode> fsenItr = rblockRel.getAllSESEs().iterator();
+ while( fsenItr.hasNext() ) {
+ FlatSESEEnterNode fsen = fsenItr.next();
- public DisjointAnalysis getDisjointAnalysis() {
- return disjointAnalysisTaints;
- }
-
- private void printSESEInfoTree(BufferedWriter bw, FlatSESEEnterNode fsen)
- throws java.io.IOException {
-
- bw.write("SESE " + fsen.getPrettyIdentifier());
- if( fsen.getIsLeafSESE() ) {
- bw.write(" (leaf)");
- }
- bw.write(" {\n");
-
- bw.write(" in-set: " + fsen.getInVarSet() + "\n");
- Iterator<TempDescriptor> tItr = fsen.getInVarSet().iterator();
- while (tItr.hasNext()) {
- TempDescriptor inVar = tItr.next();
- if (fsen.getReadyInVarSet().contains(inVar)) {
- bw.write(" (ready) " + inVar + "\n");
+ bw.write("SESE " + fsen.getPrettyIdentifier());
+ if( fsen.getIsLeafSESE() ) {
+ bw.write(" (leaf)");
}
- 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(" {\n");
+
+ bw.write(" in-set: " + fsen.getInVarSet() + "\n");
+ Iterator<TempDescriptor> 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(" Dynamic vars to manage: " + fsen.getDynamicVarSet() + "\n");
- bw.write(" out-set: " + fsen.getOutVarSet() + "\n");
- bw.write("}\n");
+ bw.write(" out-set: " + fsen.getOutVarSet() + "\n");
- Iterator<FlatSESEEnterNode> childItr = fsen.getChildren().iterator();
- while (childItr.hasNext()) {
- FlatSESEEnterNode fsenChild = childItr.next();
- printSESEInfoTree(bw, fsenChild);
+ bw.write(" local parent: " + fsen.getLocalParent() + "\n");
+ bw.write(" local children: " + fsen.getLocalChildren() + "\n");
+
+ bw.write(" possible parents: " + fsen.getParents() + "\n");
+ bw.write(" possible children: " + fsen.getChildren() + "\n");
+
+ bw.write("}\n");
}
}
-
}
return mainSESE;
}
- public FlatSESEEnterNode getCallerProxySESE() {
- return callerProxySESE;
- }
-
public Set<FlatSESEEnterNode> getAllSESEs() {
return allSESEs;
}
public Set<FlatSESEEnterNode> getLocalRootSESEs() {
return allLocalRootSESEs;
}
+
+ public Set<FlatSESEEnterNode> getLocalRootSESEs( FlatMethod fm ) {
+ Set<FlatSESEEnterNode> out = md2localRootSESEs.get( fm );
+ if( out == null ) {
+ out = new HashSet<FlatSESEEnterNode>();
+ }
+ return out;
+ }
public Set<FlatSESEEnterNode> getPossibleExecutingRBlocks( FlatNode fn ) {
return fn2currentSESEs.get( fn );
return fn2localInnerSESE.get( fn );
}
+ // the "caller proxy" is a static name for whichever
+ // task invoked the current method context. It is very
+ // convenient to know this is ALWAYS a different instance
+ // of any task defined within the current method context,
+ // and so using its name simplifies many intraprocedural
+ // analyses
+ public FlatSESEEnterNode getCallerProxySESE() {
+ return callerProxySESE;
+ }
+
public boolean isPotentialStallSite( FlatNode fn ) {
Boolean ipss = fn2isPotentialStallSite.get( fn );
if( ipss == null ) {
this.callGraph = callGraph;
callerProxySESE = new FlatSESEEnterNode( null );
+ callerProxySESE.setIsCallerProxySESE();
allSESEs = new HashSet<FlatSESEEnterNode>();
allLocalRootSESEs = new HashSet<FlatSESEEnterNode>();
+++ /dev/null
-package Analysis.OoOJava;
-
-import java.util.HashSet;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.Set;
-import java.util.Stack;
-import java.util.TreeSet;
-import java.util.Map.Entry;
-
-import Analysis.CallGraph.CallGraph;
-import Analysis.Disjoint.ReachGraph;
-import IR.Descriptor;
-import IR.MethodDescriptor;
-import IR.State;
-import IR.TypeDescriptor;
-import IR.TypeUtil;
-import IR.Flat.FKind;
-import IR.Flat.FlatCall;
-import IR.Flat.FlatMethod;
-import IR.Flat.FlatNode;
-import IR.Flat.FlatSESEEnterNode;
-import IR.Flat.FlatSESEExitNode;
-
-public class RBlockStatusAnalysis {
-
- // compiler data
- State state;
- TypeUtil typeUtil;
- CallGraph callGraph;
- RBlockRelationAnalysis rra;
-
- // per method-per node-rblock stacks
- protected Hashtable<FlatMethod, Hashtable<FlatNode, Hashtable<FlatSESEEnterNode, Boolean>>> fm2statusmap;
-
- public RBlockStatusAnalysis(State state, TypeUtil typeUtil, CallGraph callGraph,
- RBlockRelationAnalysis rra) {
- this.state = state;
- this.typeUtil = typeUtil;
- this.callGraph = callGraph;
- this.rra = rra;
-
- fm2statusmap =
- new Hashtable<FlatMethod, Hashtable<FlatNode, Hashtable<FlatSESEEnterNode, Boolean>>>();
-
- MethodDescriptor mdSourceEntry = typeUtil.getMain();
- FlatMethod fmMain = state.getMethodFlat(mdSourceEntry);
-
- // add all methods transitively reachable from the
- // source's main to set for analysis
- Set<MethodDescriptor> descriptorsToAnalyze = callGraph.getAllMethods(mdSourceEntry);
-
- descriptorsToAnalyze.add(mdSourceEntry);
-
- analyzeMethods(descriptorsToAnalyze);
-
- //analyzeMethodsDebug(descriptorsToAnalyze);
- }
-
- protected void analyzeMethods(Set<MethodDescriptor> descriptorsToAnalyze) {
-
- Iterator<MethodDescriptor> mdItr = descriptorsToAnalyze.iterator();
- while (mdItr.hasNext()) {
- FlatMethod fm = state.getMethodFlat(mdItr.next());
-
- Hashtable<FlatNode, Hashtable<FlatSESEEnterNode, Boolean>> fn2seseStatus =
- computeRBlockStatus(fm);
-
- fm2statusmap.put(fm, fn2seseStatus);
- }
- }
-
- public Hashtable<FlatNode, Hashtable<FlatSESEEnterNode, Boolean>> computeRBlockStatus(
- FlatMethod fm) {
-
- Hashtable<FlatNode, Stack<FlatSESEEnterNode>> seseStacks =
- new Hashtable<FlatNode, Stack<FlatSESEEnterNode>>();
-
- Hashtable<FlatNode, Hashtable<FlatSESEEnterNode, Boolean>> fn2seseStatus =
- new Hashtable<FlatNode, Hashtable<FlatSESEEnterNode, Boolean>>();
-
- LinkedList<FlatNode> flatNodesToVisit = new LinkedList<FlatNode>();
- flatNodesToVisit.add(fm);
-
- Stack<FlatSESEEnterNode> seseStackFirst = new Stack<FlatSESEEnterNode>();
- seseStacks.put(fm, seseStackFirst);
-
- while (!flatNodesToVisit.isEmpty()) {
- Iterator<FlatNode> fnItr = flatNodesToVisit.iterator();
- FlatNode fn = fnItr.next();
-
- Hashtable<FlatSESEEnterNode, Boolean> prevResult = fn2seseStatus.get(fn);
-
- Hashtable<FlatSESEEnterNode, Boolean> currentResult =
- new Hashtable<FlatSESEEnterNode, Boolean>();
-
- for (int i = 0; i < fn.numPrev(); i++) {
- FlatNode prevFlatNode = fn.getPrev(i);
- Hashtable<FlatSESEEnterNode, Boolean> incoming = fn2seseStatus.get(prevFlatNode);
- if (incoming != null) {
- merge(currentResult, incoming);
- }
- }
-
- flatNodesToVisit.remove(fn);
-
- nodeActions(fn, fm, currentResult);
-
- // if we have a new result, schedule forward nodes for
- // analysis
- if (prevResult == null || !currentResult.equals(prevResult)) {
- fn2seseStatus.put(fn, currentResult);
- for (int i = 0; i < fn.numNext(); i++) {
- FlatNode nn = fn.getNext(i);
- flatNodesToVisit.addFirst(nn);
- }
- }
- }
-
- return fn2seseStatus;
- }
-
- private void merge(Hashtable<FlatSESEEnterNode, Boolean> current,
- Hashtable<FlatSESEEnterNode, Boolean> incoming) {
-
- Iterator inIter = incoming.entrySet().iterator();
- while (inIter.hasNext()) {
- Entry inEntry = (Entry) inIter.next();
- FlatSESEEnterNode seseContaining = (FlatSESEEnterNode) inEntry.getKey();
- Boolean isAfter = (Boolean) inEntry.getValue();
-
- if(isAfter==null){
- isAfter=Boolean.FALSE;
- }
- Boolean currentIsAfter = current.get(seseContaining);
-
- if (currentIsAfter == null){
- currentIsAfter=Boolean.FALSE;
- }
- current.put(seseContaining, (isAfter|currentIsAfter));
-
- }
-
- }
-
- public boolean isInCriticalRegion(FlatMethod fmContaining, FlatNode fn) {
- FlatSESEEnterNode seseContaining = rra.getRBlockStacks(fmContaining, fn).peek();
- Hashtable<FlatNode, Hashtable<FlatSESEEnterNode, Boolean>> statusMap =
- fm2statusmap.get(fmContaining);
- Hashtable<FlatSESEEnterNode, Boolean> status = statusMap.get(fn);
-
- if(status.get(seseContaining).booleanValue()==true){
-// System.out.println(fn+" is in the critical region in according to "+seseContaining);
- }
-
- return status.get(seseContaining).booleanValue();
- }
-
- protected void nodeActions(FlatNode fn, FlatMethod fm,
- Hashtable<FlatSESEEnterNode, Boolean> status) {
- switch (fn.kind()) {
-
- case FKind.FlatSESEExitNode: {
- FlatSESEExitNode fsexn = (FlatSESEExitNode) fn;
- FlatSESEEnterNode fsen = fsexn.getFlatEnter();
- if (fsen.getParent() != null) {
- status.put(fsen.getParent(), Boolean.TRUE);
- }
- }
- break;
-
- case FKind.FlatCall: {
- Descriptor mdCaller = fm.getMethod();
-
- FlatCall fc = (FlatCall) fn;
- MethodDescriptor mdCallee = fc.getMethod();
- FlatMethod fmCallee = state.getMethodFlat(mdCallee);
-
- Set<MethodDescriptor> setPossibleCallees = new HashSet<MethodDescriptor>();
-
- if (mdCallee.isStatic()) {
- setPossibleCallees.add(mdCallee);
- } else {
- TypeDescriptor typeDesc = fc.getThis().getType();
- setPossibleCallees.addAll(callGraph.getMethods(mdCallee, typeDesc));
- }
-
- Iterator<MethodDescriptor> mdItr = setPossibleCallees.iterator();
- while (mdItr.hasNext()) {
- MethodDescriptor mdPossible = mdItr.next();
- FlatMethod fmPossible = state.getMethodFlat(mdPossible);
- }
-
- boolean hasSESECallee = false;
- for (Iterator iterator = setPossibleCallees.iterator(); iterator.hasNext();) {
- MethodDescriptor md = (MethodDescriptor) iterator.next();
- FlatMethod flatMethod = state.getMethodFlat(md);
- FlatNode flatNode = flatMethod.getNext(0);
- assert flatNode instanceof FlatSESEEnterNode;
- FlatSESEEnterNode flatSESE = (FlatSESEEnterNode) flatNode;
- hasSESECallee |= (!flatSESE.getIsLeafSESE());
- }
-
- Stack<FlatSESEEnterNode> seseStack = rra.getRBlockStacks(fm, fn);
- if (!seseStack.isEmpty()) {
- FlatSESEEnterNode currentParent = seseStack.peek();
- if (!status.containsKey(currentParent)) {
- status.put(currentParent, new Boolean(hasSESECallee));
- } else {
- boolean currentParentStatus = status.get(currentParent).booleanValue();
- status.put(currentParent, new Boolean(hasSESECallee | currentParentStatus));
- }
- }
-
- } break;
-
- default: {
- if (!(fn instanceof FlatMethod)) {
- Stack<FlatSESEEnterNode> seseStack = rra.getRBlockStacks(fm, fn);
- if (!seseStack.isEmpty()) {
- FlatSESEEnterNode currentParent = seseStack.peek();
- if (!status.containsKey(currentParent)) {
- status.put(currentParent, Boolean.FALSE);
- }
- }
- }
-
- }
- break;
- }
-
- }
-
- /*
- * DEBUG
- */
- protected void analyzeMethodsDebug(Set<MethodDescriptor> descriptorsToAnalyze) {
-
- Iterator<MethodDescriptor> mdItr = descriptorsToAnalyze.iterator();
- while (mdItr.hasNext()) {
- FlatMethod fm = state.getMethodFlat(mdItr.next());
- printStatusMap(fm);
-
- }
- }
-
- protected void printStatusMap(FlatMethod fm) {
-
- Set<FlatNode> flatNodesToVisit = new HashSet<FlatNode>();
- flatNodesToVisit.add(fm);
-
- Set<FlatNode> visited = new HashSet<FlatNode>();
-
- while (!flatNodesToVisit.isEmpty()) {
- Iterator<FlatNode> fnItr = flatNodesToVisit.iterator();
- FlatNode fn = fnItr.next();
-
- flatNodesToVisit.remove(fn);
- visited.add(fn);
-
- System.out.println("------------------");
- System.out.println("fn=" + fn);
- System.out.println(fm2statusmap.get(fm).get(fn));
-
- for (int i = 0; i < fn.numNext(); i++) {
- FlatNode nn = fn.getNext(i);
-
- if (!visited.contains(nn)) {
- flatNodesToVisit.add(nn);
-
- }
- }
- }
-
- }
-
-}
public static final Integer SrcType_STATIC = new Integer( 35 );
public static final Integer SrcType_DYNAMIC = new Integer( 36 );
+ public static RBlockRelationAnalysis rblockRel;
+
+
public VarSrcTokTable() {
trueSet = new HashSet<VariableSourceToken>();
// for the given SESE, change child tokens into this parent
public void remapChildTokens( FlatSESEEnterNode curr ) {
- Iterator<FlatSESEEnterNode> childItr = curr.getChildren().iterator();
+ Iterator<FlatSESEEnterNode> childItr = curr.getLocalChildren().iterator();
if( childItr.hasNext() ) {
FlatSESEEnterNode child = childItr.next();
// whether it ends up writing to it or not. It will always, then,
// appear in curr's out-set.
public Set<TempDescriptor>
- calcVirtReadsAndPruneParentAndSiblingTokens( FlatSESEEnterNode exiter,
+ calcVirtReadsAndPruneParentAndSiblingTokens( FlatSESEEnterNode exiter,
Set<TempDescriptor> liveVars ) {
Set<TempDescriptor> virtReadSet = new HashSet<TempDescriptor>();
- Set<FlatSESEEnterNode> parents = null; //exiter.getParents();
- if( parents.isEmpty() ) {
- // having no parent means no siblings, too
+ // this calculation is unneeded for the main task, just return an
+ // empty set of virtual reads
+ if( rblockRel.getMainSESE() == exiter ) {
return virtReadSet;
}
+ // who are the parent and siblings?
Set<FlatSESEEnterNode> alternateSESEs = new HashSet<FlatSESEEnterNode>();
- alternateSESEs.addAll( parents );
- Iterator<FlatSESEEnterNode> childItr = null; //parents.getChildren().iterator();
+ Iterator<FlatSESEEnterNode> childItr;
+
+ FlatSESEEnterNode parent = exiter.getLocalParent();
+
+ if( parent == null ) {
+ // when some caller task is the exiter's parent, the siblings
+ // of the exiter are other local root tasks
+ parent = rblockRel.getCallerProxySESE();
+ childItr = rblockRel.getLocalRootSESEs( exiter.getfmEnclosing() ).iterator();
+
+ } else {
+ // otherwise, the siblings are locally-defined
+ childItr = parent.getLocalChildren().iterator();
+ }
+
+ alternateSESEs.add( parent );
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
return virtReadSet;
}
-
- // get the set of VST's that come from a child
- public Set<VariableSourceToken> getChildrenVSTs( FlatSESEEnterNode curr ) {
-
- Set<VariableSourceToken> out = new HashSet<VariableSourceToken>();
-
- Iterator<FlatSESEEnterNode> 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
// 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,
+ FlatSESEEnterNode currentSESE,
VSTWrapper vstIfStatic ) {
assert refVar != null;
assert vstIfStatic != 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 ) {
+ if( currentSESE == null ) {
return SrcType_READY;
}
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() ) ) {
-
+ // one child token, there are two cases
+ // 1. if the current task invoked the local method context,
+ // its children are the locally-defined root tasks
+ boolean case1 =
+ currentSESE.getIsCallerProxySESE() &&
+ rblockRel.getLocalRootSESEs().contains( vst.getSESE() );
+
+ // 2. if the child task is a locally-defined child of the current task
+ boolean case2 = currentSESE.getLocalChildren().contains( vst.getSESE() );
+
+ if( case1 || case2 ) {
+
// if we ever have at least one child source with an
// unknown age, have to treat var as dynamic
if( vst.getAge().equals( OoOJavaAnalysis.maxSESEage ) ) {
// (spliced in by the compiler around whole program)
protected boolean isMainSESE;
+ // this is a useful static name for whichever task
+ // invoked the current local method context
+ protected boolean isCallerProxySESE;
+
// all children tasks, INCLUDING those that are reachable
// by calling methods
protected Set<FlatSESEEnterNode> children;
isLeafSESE = ISLEAF_UNINIT;
- isMainSESE = false;
+ isMainSESE = false;
+ isCallerProxySESE = false;
firstDepRecField = null;
numDepRecs = 0;
return isMainSESE;
}
+ public void setIsCallerProxySESE() {
+ isCallerProxySESE = true;
+ }
+
+ public boolean getIsCallerProxySESE() {
+ return isCallerProxySESE;
+ }
+
public int kind() {
return FKind.FlatSESEEnterNode;
}
}
public String getPrettyIdentifier() {
- if( treeNode.getID() != null ) {
+ if( treeNode != null && treeNode.getID() != null ) {
return treeNode.getID();
}
return ""+id;