From cc54506834e3dd1cc787efa38e679346e149ce00 Mon Sep 17 00:00:00 2001 From: jjenista Date: Tue, 1 Feb 2011 00:46:30 +0000 Subject: [PATCH] pushing cleaned code further through analyses... --- .../src/Analysis/OoOJava/OoOJavaAnalysis.java | 203 +++++++------ .../OoOJava/RBlockRelationAnalysis.java | 23 +- .../OoOJava/RBlockStatusAnalysis.java | 278 ------------------ .../src/Analysis/OoOJava/VarSrcTokTable.java | 68 +++-- Robust/src/IR/Flat/FlatSESEEnterNode.java | 17 +- 5 files changed, 180 insertions(+), 409 deletions(-) delete mode 100644 Robust/src/Analysis/OoOJava/RBlockStatusAnalysis.java diff --git a/Robust/src/Analysis/OoOJava/OoOJavaAnalysis.java b/Robust/src/Analysis/OoOJava/OoOJavaAnalysis.java index b5da9306..50e66a72 100644 --- a/Robust/src/Analysis/OoOJava/OoOJavaAnalysis.java +++ b/Robust/src/Analysis/OoOJava/OoOJavaAnalysis.java @@ -85,6 +85,11 @@ public class OoOJavaAnalysis { return codePlans.keySet(); } + public DisjointAnalysis getDisjointAnalysis() { + return disjointAnalysisTaints; + } + + public OoOJavaAnalysis(State state, TypeUtil typeUtil, CallGraph callGraph, @@ -119,6 +124,7 @@ public class OoOJavaAnalysis { // 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 methItr = descriptorsToAnalyze.iterator(); @@ -131,7 +137,6 @@ public class OoOJavaAnalysis { livenessAnalysisBackward(fm); } - /* // 3rd pass, variable analysis methItr = descriptorsToAnalyze.iterator(); while (methItr.hasNext()) { @@ -152,6 +157,7 @@ public class OoOJavaAnalysis { livenessAnalysisBackward(fm); } + /* // 5th pass, use disjointness with NO FLAGGED REGIONS // to compute taints and effects disjointAnalysisTaints = @@ -246,15 +252,13 @@ public class OoOJavaAnalysis { } */ - /* 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"+ @@ -411,12 +415,12 @@ public class OoOJavaAnalysis { curr.merge(incoming); } - Set 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)) { @@ -430,20 +434,22 @@ public class OoOJavaAnalysis { } } - private void variable_nodeActions(FlatNode fn, - VarSrcTokTable vstTable, - Set 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; @@ -460,7 +466,8 @@ public class OoOJavaAnalysis { // of parent or sibling sources Set liveVars = livenessGlobalView.get(fn); Set fsenVirtReads = - vstTable.calcVirtReadsAndPruneParentAndSiblingTokens(fsen, liveVars); + vstTable.calcVirtReadsAndPruneParentAndSiblingTokens(fsen, + liveVars); Set fsenVirtReadsOld = livenessVirtualReads.get(fn); if (fsenVirtReadsOld != null) { @@ -483,6 +490,7 @@ public class OoOJavaAnalysis { vstTable.assertConsistency(); } break; + case FKind.FlatOpNode: { FlatOpNode fon = (FlatOpNode) fn; @@ -501,20 +509,36 @@ public class OoOJavaAnalysis { HashSet ts = new HashSet(); 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 @@ -527,34 +551,36 @@ public class OoOJavaAnalysis { // fall through to this default case default: { TempDescriptor[] writeTemps = fn.writesTemps(); - if (writeTemps.length > 0) { + if( writeTemps.length > 0 ) { // for now, when writeTemps > 1, make sure // its a call node, programmer enforce only // doing stuff like calling a print routine - // 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 ts = new HashSet(); - 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 flatNodesToVisit = new HashSet(); @@ -1458,8 +1484,8 @@ public class OoOJavaAnalysis { 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"); @@ -1477,46 +1503,42 @@ public class OoOJavaAnalysis { ".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 rootItr = rblockRel.getAllSESEs().iterator(); + bw.write("SESE Local Hierarchy\n--------------\n"); + Iterator 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 childItr = fsen.getChildren().iterator(); + Iterator childItr = fsen.getLocalChildren().iterator(); while (childItr.hasNext()) { FlatSESEEnterNode fsenChild = childItr.next(); printSESEHierarchyTree(bw, fsenChild, depth + 1); @@ -1525,57 +1547,42 @@ public class OoOJavaAnalysis { private void printSESEInfo(BufferedWriter bw) throws java.io.IOException { bw.write("\nSESE info\n-------------\n"); - Iterator 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 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 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 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 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"); } } - } diff --git a/Robust/src/Analysis/OoOJava/RBlockRelationAnalysis.java b/Robust/src/Analysis/OoOJava/RBlockRelationAnalysis.java index 99fd2bcf..fb30f231 100644 --- a/Robust/src/Analysis/OoOJava/RBlockRelationAnalysis.java +++ b/Robust/src/Analysis/OoOJava/RBlockRelationAnalysis.java @@ -115,10 +115,6 @@ public class RBlockRelationAnalysis { return mainSESE; } - public FlatSESEEnterNode getCallerProxySESE() { - return callerProxySESE; - } - public Set getAllSESEs() { return allSESEs; } @@ -126,6 +122,14 @@ public class RBlockRelationAnalysis { public Set getLocalRootSESEs() { return allLocalRootSESEs; } + + public Set getLocalRootSESEs( FlatMethod fm ) { + Set out = md2localRootSESEs.get( fm ); + if( out == null ) { + out = new HashSet(); + } + return out; + } public Set getPossibleExecutingRBlocks( FlatNode fn ) { return fn2currentSESEs.get( fn ); @@ -135,6 +139,16 @@ public class RBlockRelationAnalysis { 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 ) { @@ -152,6 +166,7 @@ public class RBlockRelationAnalysis { this.callGraph = callGraph; callerProxySESE = new FlatSESEEnterNode( null ); + callerProxySESE.setIsCallerProxySESE(); allSESEs = new HashSet(); allLocalRootSESEs = new HashSet(); diff --git a/Robust/src/Analysis/OoOJava/RBlockStatusAnalysis.java b/Robust/src/Analysis/OoOJava/RBlockStatusAnalysis.java deleted file mode 100644 index f0933016..00000000 --- a/Robust/src/Analysis/OoOJava/RBlockStatusAnalysis.java +++ /dev/null @@ -1,278 +0,0 @@ -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>> 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>>(); - - MethodDescriptor mdSourceEntry = typeUtil.getMain(); - FlatMethod fmMain = state.getMethodFlat(mdSourceEntry); - - // add all methods transitively reachable from the - // source's main to set for analysis - Set descriptorsToAnalyze = callGraph.getAllMethods(mdSourceEntry); - - descriptorsToAnalyze.add(mdSourceEntry); - - analyzeMethods(descriptorsToAnalyze); - - //analyzeMethodsDebug(descriptorsToAnalyze); - } - - protected void analyzeMethods(Set descriptorsToAnalyze) { - - Iterator mdItr = descriptorsToAnalyze.iterator(); - while (mdItr.hasNext()) { - FlatMethod fm = state.getMethodFlat(mdItr.next()); - - Hashtable> fn2seseStatus = - computeRBlockStatus(fm); - - fm2statusmap.put(fm, fn2seseStatus); - } - } - - public Hashtable> computeRBlockStatus( - FlatMethod fm) { - - Hashtable> seseStacks = - new Hashtable>(); - - Hashtable> fn2seseStatus = - new Hashtable>(); - - LinkedList flatNodesToVisit = new LinkedList(); - flatNodesToVisit.add(fm); - - Stack seseStackFirst = new Stack(); - seseStacks.put(fm, seseStackFirst); - - while (!flatNodesToVisit.isEmpty()) { - Iterator fnItr = flatNodesToVisit.iterator(); - FlatNode fn = fnItr.next(); - - Hashtable prevResult = fn2seseStatus.get(fn); - - Hashtable currentResult = - new Hashtable(); - - for (int i = 0; i < fn.numPrev(); i++) { - FlatNode prevFlatNode = fn.getPrev(i); - Hashtable 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 current, - Hashtable 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> statusMap = - fm2statusmap.get(fmContaining); - Hashtable 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 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 setPossibleCallees = new HashSet(); - - if (mdCallee.isStatic()) { - setPossibleCallees.add(mdCallee); - } else { - TypeDescriptor typeDesc = fc.getThis().getType(); - setPossibleCallees.addAll(callGraph.getMethods(mdCallee, typeDesc)); - } - - Iterator 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 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 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 descriptorsToAnalyze) { - - Iterator mdItr = descriptorsToAnalyze.iterator(); - while (mdItr.hasNext()) { - FlatMethod fm = state.getMethodFlat(mdItr.next()); - printStatusMap(fm); - - } - } - - protected void printStatusMap(FlatMethod 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("------------------"); - 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); - - } - } - } - - } - -} diff --git a/Robust/src/Analysis/OoOJava/VarSrcTokTable.java b/Robust/src/Analysis/OoOJava/VarSrcTokTable.java index f1f83687..1ad5ec59 100644 --- a/Robust/src/Analysis/OoOJava/VarSrcTokTable.java +++ b/Robust/src/Analysis/OoOJava/VarSrcTokTable.java @@ -34,6 +34,9 @@ public class VarSrcTokTable { 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(); @@ -386,7 +389,7 @@ public class VarSrcTokTable { // for the given SESE, change child tokens into this parent public void remapChildTokens( FlatSESEEnterNode curr ) { - Iterator childItr = curr.getChildren().iterator(); + Iterator childItr = curr.getLocalChildren().iterator(); if( childItr.hasNext() ) { FlatSESEEnterNode child = childItr.next(); @@ -433,26 +436,43 @@ public class VarSrcTokTable { // whether it ends up writing to it or not. It will always, then, // appear in curr's out-set. public Set - calcVirtReadsAndPruneParentAndSiblingTokens( FlatSESEEnterNode exiter, + calcVirtReadsAndPruneParentAndSiblingTokens( FlatSESEEnterNode exiter, Set liveVars ) { Set virtReadSet = new HashSet(); - Set 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 alternateSESEs = new HashSet(); - alternateSESEs.addAll( parents ); - Iterator childItr = null; //parents.getChildren().iterator(); + Iterator 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 @@ -519,21 +539,6 @@ public class VarSrcTokTable { 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 @@ -587,7 +592,7 @@ public class VarSrcTokTable { // 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; @@ -597,7 +602,7 @@ public class VarSrcTokTable { // 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; } @@ -611,9 +616,18 @@ public class VarSrcTokTable { 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 ) ) { diff --git a/Robust/src/IR/Flat/FlatSESEEnterNode.java b/Robust/src/IR/Flat/FlatSESEEnterNode.java index 875cd8a9..de512a03 100644 --- a/Robust/src/IR/Flat/FlatSESEEnterNode.java +++ b/Robust/src/IR/Flat/FlatSESEEnterNode.java @@ -35,6 +35,10 @@ public class FlatSESEEnterNode extends FlatNode { // (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 children; @@ -116,7 +120,8 @@ public class FlatSESEEnterNode extends FlatNode { isLeafSESE = ISLEAF_UNINIT; - isMainSESE = false; + isMainSESE = false; + isCallerProxySESE = false; firstDepRecField = null; numDepRecs = 0; @@ -144,6 +149,14 @@ public class FlatSESEEnterNode extends FlatNode { return isMainSESE; } + public void setIsCallerProxySESE() { + isCallerProxySESE = true; + } + + public boolean getIsCallerProxySESE() { + return isCallerProxySESE; + } + public int kind() { return FKind.FlatSESEEnterNode; } @@ -157,7 +170,7 @@ public class FlatSESEEnterNode extends FlatNode { } public String getPrettyIdentifier() { - if( treeNode.getID() != null ) { + if( treeNode != null && treeNode.getID() != null ) { return treeNode.getID(); } return ""+id; -- 2.34.1