From: yeom Date: Thu, 3 May 2012 17:33:35 +0000 (+0000) Subject: Fix the bug in the variable analysis: When we define nested tasks, the task liveness... X-Git-Url: http://plrg.eecs.uci.edu/git/?p=IRC.git;a=commitdiff_plain;h=4c0d447e6e01694c4bc2aaa7e9edcc6c8d22f109;ds=sidebyside Fix the bug in the variable analysis: When we define nested tasks, the task liveness analysis computes a wrong inset/outset. The new analysis computes liveness for each task and keeps the local view of liveness rather than doing the global liveness computation and taking special care with nested task enter/exit nodes. --- diff --git a/Robust/src/Analysis/OoOJava/OoOJavaAnalysis.java b/Robust/src/Analysis/OoOJava/OoOJavaAnalysis.java index c361c747..4a5283d5 100644 --- a/Robust/src/Analysis/OoOJava/OoOJavaAnalysis.java +++ b/Robust/src/Analysis/OoOJava/OoOJavaAnalysis.java @@ -147,11 +147,12 @@ public class OoOJavaAnalysis { State.logEvent("OoOJavaAnalysis 1st pass completed"); // 2nd pass, liveness, in-set out-set (no virtual reads yet!) - Iterator seseItr = rblockRel.getLocalRootSESEs().iterator(); + // run liveness analysis for each sese blocks + Iterator seseItr = rblockRel.getAllSESEs().iterator(); while (seseItr.hasNext()) { FlatSESEEnterNode sese = seseItr.next(); livenessAnalysisBackward(sese); - } + } State.logEvent("OoOJavaAnalysis 2nd pass completed"); @@ -324,38 +325,50 @@ public class OoOJavaAnalysis { } + private void livenessAnalysisBackward(FlatSESEEnterNode fsen) { - // flow backward across nodes to compute liveness, and - // take special care with sese enter/exit nodes that - // alter this from normal liveness analysis + // each task maintains a local liveness result + Hashtable> livenessLocalView = + new Hashtable>(); + + // flow backward across nodes to compute liveness. + // it contributes liveness results to the global view + // only if the current flat node belongs directly to the currently analyzing + // sese. Set flatNodesToVisit = new HashSet(); - // flatNodesToVisit.add( fm.getFlatExit() ); flatNodesToVisit.add(fsen.getFlatExit()); while (!flatNodesToVisit.isEmpty()) { FlatNode fn = (FlatNode) flatNodesToVisit.iterator().next(); flatNodesToVisit.remove(fn); - Set prev = livenessGlobalView.get(fn); + Set prev = livenessLocalView.get(fn); // merge sets from control flow joins Set livein = new HashSet(); for (int i = 0; i < fn.numNext(); i++) { FlatNode nn = fn.getNext(i); - Set s = livenessGlobalView.get(nn); + Set s = livenessLocalView.get(nn); if (s != null) { livein.addAll(s); } } - Set curr = liveness_nodeActions(fn, livein); + Set curr = liveness_nodeActions(fsen, fn, livein); // if a new result, schedule backward nodes for analysis if (!curr.equals(prev)) { if (fn != fsen) { - livenessGlobalView.put(fn, curr); + livenessLocalView.put(fn, curr); + + if (rblockRel.getLocalInnerRBlock(fn).equals(fsen)) { + // the current flat node belongs to the currently analyzing sese + // store its liveness in the gloval view + livenessGlobalView.put(fn, curr); + } + for (int i = 0; i < fn.numPrev(); i++) { FlatNode nn = fn.getPrev(i); flatNodesToVisit.add(nn); @@ -365,17 +378,21 @@ public class OoOJavaAnalysis { } } - private Set liveness_nodeActions(FlatNode fn, Set liveIn) { + private Set liveness_nodeActions(FlatSESEEnterNode currSESE, FlatNode fn, + Set liveIn) { + switch (fn.kind()) { case FKind.FlatSESEEnterNode: { // add whatever is live-in at a task enter to that // task's in-var set FlatSESEEnterNode fsen = (FlatSESEEnterNode) fn; - if (liveIn != null) { - fsen.addInVarSet(liveIn); + if (currSESE.equals(fsen)) { + if (liveIn != null) { + fsen.addInVarSet(liveIn); + } + // no break, should also execute default actions } - // no break, should also execute default actions } default: { @@ -409,7 +426,7 @@ public class OoOJavaAnalysis { liveIn.addAll(virtualReadTemps); } } - break; + break; } // end switch @@ -482,7 +499,8 @@ public class OoOJavaAnalysis { // written by an SESE and should be added to the in-set // anything virtually read by this SESE should be pruned // of parent or sibling sources - Set liveVars = liveness.getLiveInTemps(fsen.getfmEnclosing(), fn); + // Set liveVars = liveness.getLiveInTemps(fsen.getfmEnclosing(), fn); + Set liveVars = livenessGlobalView.get(fn); Set fsenVirtReads = vstTable.calcVirtReadsAndPruneParentAndSiblingTokens(fsen, liveVars);