From: jjenista Date: Mon, 15 Jun 2009 22:51:52 +0000 (+0000) Subject: Make SESE root spliced into IR graph just as any other SESE, make sure MLP analysis... X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=c25c1b5aeaf69aaca82f64aede0d82f552be55b5;p=IRC.git Make SESE root spliced into IR graph just as any other SESE, make sure MLP analysis simply ignores the few IR nodes outside of root SESE scope. Problem: this implementation doesn't transform all return nodes into a single exit point yet --- diff --git a/Robust/src/Analysis/MLP/MLPAnalysis.java b/Robust/src/Analysis/MLP/MLPAnalysis.java index 0673a1ff..b2a66874 100644 --- a/Robust/src/Analysis/MLP/MLPAnalysis.java +++ b/Robust/src/Analysis/MLP/MLPAnalysis.java @@ -12,15 +12,12 @@ import java.io.*; public class MLPAnalysis { // data from the compiler - private State state; - private TypeUtil typeUtil; - private CallGraph callGraph; + private State state; + private TypeUtil typeUtil; + private CallGraph callGraph; private OwnershipAnalysis ownAnalysis; - private SESENode rootTree; - private FlatSESEEnterNode rootSESE; - private FlatSESEExitNode rootExit; - + private FlatSESEEnterNode rootSESE; private Set allSESEs; private Hashtable< FlatNode, Stack > seseStacks; @@ -32,15 +29,16 @@ public class MLPAnalysis { private static final int maxSESEage = 2; - // use these methods in BuildCode to have access to analysis results - public Set getAllSESEs() { - return allSESEs; - } + // use these methods in BuildCode to have access to analysis results public FlatSESEEnterNode getRootSESE() { return rootSESE; } + public Set getAllSESEs() { + return allSESEs; + } + public int getMaxSESEage() { return maxSESEage; } @@ -74,16 +72,10 @@ public class MLPAnalysis { notAvailableResults = new Hashtable< FlatNode, Set >(); codePlans = new Hashtable< FlatNode, CodePlan >(); - - // build an implicit root SESE to wrap contents of main method - rootTree = new SESENode( "root" ); - rootSESE = new FlatSESEEnterNode( rootTree ); - rootExit = new FlatSESEExitNode ( rootTree ); - rootSESE.setFlatExit ( rootExit ); - rootExit.setFlatEnter( rootSESE ); - FlatMethod fmMain = state.getMethodFlat( tu.getMain() ); + rootSESE = (FlatSESEEnterNode) fmMain.getNext(0); + // 1st pass // run analysis on each method that is actually called @@ -173,7 +165,6 @@ public class MLPAnalysis { Set visited = new HashSet(); Stack seseStackFirst = new Stack(); - seseStackFirst.push( rootSESE ); seseStacks.put( fm, seseStackFirst ); while( !flatNodesToVisit.isEmpty() ) { @@ -212,9 +203,11 @@ public class MLPAnalysis { allSESEs.add( fsen ); fsen.setEnclosingFlatMeth( fm ); - assert !seseStack.empty(); - seseStack.peek().addChild( fsen ); - fsen.setParent( seseStack.peek() ); + if( !seseStack.empty() ) { + seseStack.peek().addChild( fsen ); + fsen.setParent( seseStack.peek() ); + } + seseStack.push( fsen ); } break; @@ -226,9 +219,9 @@ public class MLPAnalysis { case FKind.FlatReturnNode: { FlatReturnNode frn = (FlatReturnNode) fn; - if( !seseStack.empty() && - !seseStack.peek().equals( rootSESE ) ) { - throw new Error( "Error: return statement enclosed within "+seseStack.peek() ); + if( !seseStack.empty() ) { + throw new Error( "Error: return statement enclosed within SESE "+ + seseStack.peek().getPrettyIdentifier() ); } } break; @@ -436,10 +429,13 @@ public class MLPAnalysis { inUnion.merge( incoming ); } - VarSrcTokTable curr = variable_nodeActions( fn, inUnion, seseStack.peek() ); + VarSrcTokTable curr = null; + if( !seseStack.empty() ) { + curr = variable_nodeActions( fn, inUnion, seseStack.peek() ); + } // if a new result, schedule forward nodes for analysis - if( !curr.equals( prev ) ) { + if( curr != null && !curr.equals( prev ) ) { variableResults.put( fn, curr ); for( int i = 0; i < fn.numNext(); i++ ) { @@ -589,10 +585,13 @@ public class MLPAnalysis { } } - Set curr = notAvailable_nodeActions( fn, inUnion, seseStack.peek() ); + Set curr = null; + if( !seseStack.empty() ) { + curr = notAvailable_nodeActions( fn, inUnion, seseStack.peek() ); + } // if a new result, schedule forward nodes for analysis - if( !curr.equals( prev ) ) { + if( curr != null && !curr.equals( prev ) ) { notAvailableResults.put( fn, curr ); for( int i = 0; i < fn.numNext(); i++ ) { @@ -746,7 +745,9 @@ public class MLPAnalysis { } } - computeStalls_nodeActions( fn, dotSTtable, dotSTnotAvailSet, seseStack.peek() ); + if( !seseStack.empty() ) { + computeStalls_nodeActions( fn, dotSTtable, dotSTnotAvailSet, seseStack.peek() ); + } for( int i = 0; i < fn.numNext(); i++ ) { FlatNode nn = fn.getNext( i ); @@ -867,8 +868,11 @@ public class MLPAnalysis { for( int i = 0; i < fn.numNext(); i++ ) { FlatNode nn = fn.getNext( i ); VarSrcTokTable nextVstTable = variableResults.get( nn ); - assert nextVstTable != null; - static2dynamicSet.addAll( vstTable.getStatic2DynamicSet( nextVstTable ) ); + // the table can be null if it is one of the few IR nodes + // completely outside of the root SESE scope + if( nextVstTable != null ) { + static2dynamicSet.addAll( vstTable.getStatic2DynamicSet( nextVstTable ) ); + } } /* Iterator vstItr = static2dynamicSet.iterator(); diff --git a/Robust/src/IR/Flat/BuildFlat.java b/Robust/src/IR/Flat/BuildFlat.java index 95b57a99..d2f4727a 100644 --- a/Robust/src/IR/Flat/BuildFlat.java +++ b/Robust/src/IR/Flat/BuildFlat.java @@ -116,9 +116,21 @@ public class BuildFlat { private void flattenClass(ClassDescriptor cn) { Iterator methodit=cn.getMethods(); - while(methodit.hasNext()) { - fe=new FlatExit(); + while(methodit.hasNext()) { currmd=(MethodDescriptor)methodit.next(); + + FlatSESEEnterNode rootSESE = null; + FlatSESEExitNode rootExit = null; + if (state.MLP && currmd.equals(typeutil.getMain())) { + SESENode rootTree = new SESENode( "root" ); + rootSESE = new FlatSESEEnterNode( rootTree ); + rootExit = new FlatSESEExitNode ( rootTree ); + rootSESE.setFlatExit ( rootExit ); + rootExit.setFlatEnter( rootSESE ); + } + + fe=new FlatExit(); + BlockNode bn=state.getMethodBody(currmd); if (state.DSM&&currmd.getModifiers().isAtomic()) { @@ -151,6 +163,14 @@ public class BuildFlat { aen.addNext(rnflat); rnflat.addNext(fe); } + } else if (state.MLP && rootSESE != null) { + rootSESE.addNext(fn); + fn=rootSESE; + FlatReturnNode rnflat=new FlatReturnNode(null); + np.getEnd().addNext(rootExit); + rootExit.addNext(rnflat); + rnflat.addNext(fe); + } else if (np.getEnd()!=null&&np.getEnd().kind()!=FKind.FlatReturnNode) { FlatReturnNode rnflat=new FlatReturnNode(null); np.getEnd().addNext(rnflat); diff --git a/Robust/src/Tests/mlp/tinyTest/test.java b/Robust/src/Tests/mlp/tinyTest/test.java index b2883db6..a8654e35 100644 --- a/Robust/src/Tests/mlp/tinyTest/test.java +++ b/Robust/src/Tests/mlp/tinyTest/test.java @@ -12,6 +12,17 @@ public class Test { } } + + // just for testing root's ability to + // realize a single exit after all returns + // DOESN'T WORK! + /* + if( false ) { + return; + } + */ + + /* ADD BACK IN LATER, TO TEST STALLS // shouldn't cause a stall int z = x;