From: jjenista Date: Thu, 14 May 2009 21:37:42 +0000 (+0000) Subject: Lots of changes that aren't working yet, so new methods are commented and existing... X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=5286e56e354ee7449915af1b40f951bb61092cb2;p=IRC.git Lots of changes that aren't working yet, so new methods are commented and existing code altered for new stuff is checked in. Won't affect other compiler modes, and checks in stuff to reduce conflicts while getting the sese's working. --- diff --git a/Robust/src/Analysis/MLP/MLPAnalysis.java b/Robust/src/Analysis/MLP/MLPAnalysis.java index 9a4dbff1..57bfbb65 100644 --- a/Robust/src/Analysis/MLP/MLPAnalysis.java +++ b/Robust/src/Analysis/MLP/MLPAnalysis.java @@ -21,6 +21,8 @@ public class MLPAnalysis { private FlatSESEEnterNode rootSESE; private FlatSESEExitNode rootExit; + private Set allSESEs; + private Hashtable< FlatNode, Stack > seseStacks; private Hashtable< FlatNode, Set > livenessRootView; private Hashtable< FlatNode, Set > livenessVirtualReads; @@ -29,6 +31,18 @@ public class MLPAnalysis { private Hashtable< FlatNode, CodePlan > codePlans; + // use these methods in BuildCode to have access to analysis results + public Set getAllSESEs() { + return allSESEs; + } + + public CodePlan getCodePlan( FlatNode fn ) { + CodePlan cp = codePlans.get( fn ); + assert cp != null; + return cp; + } + + public MLPAnalysis( State state, TypeUtil tu, CallGraph callGraph, @@ -43,6 +57,8 @@ public class MLPAnalysis { this.ownAnalysis = ownAnalysis; // initialize analysis data structures + allSESEs = new HashSet(); + seseStacks = new Hashtable< FlatNode, Stack >(); livenessVirtualReads = new Hashtable< FlatNode, Set >(); variableResults = new Hashtable< FlatNode, VarSrcTokTable >(); @@ -50,7 +66,6 @@ public class MLPAnalysis { codePlans = new Hashtable< FlatNode, CodePlan >(); - // build an implicit root SESE to wrap contents of main method rootTree = new SESENode( "root" ); rootSESE = new FlatSESEEnterNode( rootTree ); @@ -151,7 +166,7 @@ public class MLPAnalysis { flatNodesToVisit.remove( fn ); visited.add( fn ); - buildForest_nodeActions( fn, seseStack ); + buildForest_nodeActions( fn, seseStack, fm ); for( int i = 0; i < fn.numNext(); i++ ) { FlatNode nn = fn.getNext( i ); @@ -171,11 +186,16 @@ public class MLPAnalysis { } private void buildForest_nodeActions( FlatNode fn, - Stack seseStack ) { + Stack seseStack, + FlatMethod fm ) { switch( fn.kind() ) { case FKind.FlatSESEEnterNode: { - FlatSESEEnterNode fsen = (FlatSESEEnterNode) fn; + FlatSESEEnterNode fsen = (FlatSESEEnterNode) fn; + + allSESEs.add( fsen ); + fsen.setEnclosingFlatMeth( fm ); + assert !seseStack.empty(); seseStack.peek().addChild( fsen ); fsen.setParent( seseStack.peek() ); diff --git a/Robust/src/IR/Flat/BuildCode.java b/Robust/src/IR/Flat/BuildCode.java index 7d6f8b85..0d1cbb67 100644 --- a/Robust/src/IR/Flat/BuildCode.java +++ b/Robust/src/IR/Flat/BuildCode.java @@ -22,6 +22,7 @@ import Analysis.CallGraph.CallGraph; import Analysis.Prefetch.*; import Analysis.Loops.WriteBarrier; import Analysis.Locality.TypeAnalysis; +import Analysis.MLP.MLPAnalysis; public class BuildCode { State state; @@ -52,23 +53,28 @@ public class BuildCode { Hashtable> backuptable; SafetyAnalysis sa; PrefetchAnalysis pa; - HashSet setSESEtoGen; + MLPAnalysis mlpa; boolean nonSESEpass=true; WriteBarrier wb; DiscoverConflicts dc; CallGraph callgraph; public BuildCode(State st, Hashtable temptovar, TypeUtil typeutil, SafetyAnalysis sa, PrefetchAnalysis pa) { - this(st, temptovar, typeutil, null, sa, pa); + this(st, temptovar, typeutil, null, sa, pa, null); } - public BuildCode(State st, Hashtable temptovar, TypeUtil typeutil, LocalityAnalysis locality, PrefetchAnalysis pa) { - this(st, temptovar, typeutil, locality, null, pa); + public BuildCode(State st, Hashtable temptovar, TypeUtil typeutil, SafetyAnalysis sa, PrefetchAnalysis pa, MLPAnalysis mlpa) { + this(st, temptovar, typeutil, null, sa, pa, mlpa); } - public BuildCode(State st, Hashtable temptovar, TypeUtil typeutil, LocalityAnalysis locality, SafetyAnalysis sa, PrefetchAnalysis pa) { + public BuildCode(State st, Hashtable temptovar, TypeUtil typeutil, LocalityAnalysis locality, PrefetchAnalysis pa, MLPAnalysis mlpa) { + this(st, temptovar, typeutil, locality, null, pa, mlpa); + } + + public BuildCode(State st, Hashtable temptovar, TypeUtil typeutil, LocalityAnalysis locality, SafetyAnalysis sa, PrefetchAnalysis pa, MLPAnalysis mlpa) { this.sa=sa; this.pa=pa; + this.mlpa=mlpa; state=st; callgraph=new CallGraph(state); if (state.SINGLETM) @@ -91,8 +97,6 @@ public class BuildCode { this.dc=new DiscoverConflicts(locality, st, typeanalysis); dc.doAnalysis(); } - - setSESEtoGen = new HashSet(); } /** The buildCode method outputs C code for all the methods. The Flat @@ -184,15 +188,13 @@ public class BuildCode { /* Build the actual methods */ outputMethods(outmethod); + // Output function prototypes and structures for SESE's and code if( state.MLP ) { nonSESEpass = false; - while( !setSESEtoGen.isEmpty() ) { - FlatSESEEnterNode fsen = setSESEtoGen.iterator().next(); - setSESEtoGen.remove(fsen); - generateMethodSESE(fsen, fsen.getEnclosingFlatMeth(), null, outmethod); + for(Iterator seseit=mlpa.getAllSESEs().iterator();seseit.hasNext();) { + FlatSESEEnterNode fsen = seseit.next(); + generateMethodSESE(fsen, null, outstructs, outmethodheader, outmethod); } - } else { - assert setSESEtoGen.isEmpty(); } if (state.TASK) { @@ -1489,35 +1491,156 @@ public class BuildCode { output.println("}\n\n"); } + /***** Generate code for FlatMethod fm. *****/ + + private void generateFlatMethodSESE(FlatMethod fm, + ClassDescriptor cn, + FlatSESEEnterNode seseEnter, + FlatSESEExitNode seseExit, + PrintWriter output + ) { + /* + MethodDescriptor md=fm.getMethod(); + ParamsObject objectparams=(ParamsObject)paramstable.get(md); + //generateHeader(fm, lb, md); + TempObject objecttemp=(TempObject) tempstable.get(md); + */ + + /* + if (GENERATEPRECISEGC) { + output.print(" struct "+cn.getSafeSymbol()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_locals "+localsprefix+"={"); + output.print(objecttemp.numPointers()+","); + output.print(paramsprefix); + for(int j=0; j itr = faen.getInVarSet().iterator(); - while( itr.hasNext() ) { - TempDescriptor td = itr.next(); - output.println(" "+td+";"); - } - output.println("}"); + FlatMethod fm = fsen.getEnclosingFlatMeth(); + MethodDescriptor md = fm.getMethod(); + ClassDescriptor cn = md.getClassDesc(); + + + //Creates bogus method descriptor to index into tables + Modifiers bogusmod=new Modifiers(); + MethodDescriptor bogusmd=new MethodDescriptor(bogusmod, new TypeDescriptor(TypeDescriptor.VOID), fsen.getIdentifier()); + FlatMethod bogusfm=new FlatMethod(bogusmd, null); + + //Build paramsobj for bogus method descriptor + ParamsObject objectparams=new ParamsObject(bogusmd, tag++); + paramstable.put(bogusmd, objectparams); + + for(int i=0; i"+td.getSafeSymbol(); } + throw new Error(); } diff --git a/Robust/src/IR/Flat/FlatSESEEnterNode.java b/Robust/src/IR/Flat/FlatSESEEnterNode.java index 11da4cb8..4d8968d4 100644 --- a/Robust/src/IR/Flat/FlatSESEEnterNode.java +++ b/Robust/src/IR/Flat/FlatSESEEnterNode.java @@ -64,6 +64,49 @@ public class FlatSESEEnterNode extends FlatNode { return inVars; } + Vector vecinVars; + void buildvarVec() { + HashSet paramset=new HashSet(); + paramset.addAll(inVars); + paramset.addAll(outVars); + vecinVars=new Vector(); + vecinVars.addAll(paramset); + } + + public TempDescriptor getParameter(int i) { + if (vecinVars==null) { + buildvarVec(); + } + return vecinVars.get(i); + } + + public int numParameters() { + if (vecinVars==null) { + buildvarVec(); + } + return vecinVars.size(); + } + + public Set getNodeSet() { + HashSet tovisit=new HashSet(); + HashSet visited=new HashSet(); + tovisit.add(this); + while(!tovisit.isEmpty()) { + FlatNode fn=tovisit.iterator().next(); + tovisit.remove(fn); + visited.add(fn); + + if (fn!=exit) { + for(int i=0; i getOutVarSet() { return outVars; } diff --git a/Robust/src/Main/Main.java b/Robust/src/Main/Main.java index ec102337..45625edf 100644 --- a/Robust/src/Main/Main.java +++ b/Robust/src/Main/Main.java @@ -248,6 +248,7 @@ public class Main { bf.buildFlat(); SafetyAnalysis sa=null; PrefetchAnalysis pa=null; + MLPAnalysis mlpa=null; if (state.OPTIMIZE) { CallGraph callgraph=new CallGraph(state); @@ -303,10 +304,10 @@ public class Main { state.OWNERSHIPWRITEDOTS, state.OWNERSHIPWRITEALL, state.OWNERSHIPALIASFILE); - MLPAnalysis mlpa = new MLPAnalysis(state, - tu, - callGraph, - oa); + mlpa = new MLPAnalysis(state, + tu, + callGraph, + oa); } if (state.TAGSTATE) { @@ -394,10 +395,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); + BuildCode bc=new BuildCode(state, bf.getMap(), tu, la, pa, mlpa); bc.buildCode(); } else { - BuildCode bc=new BuildCode(state, bf.getMap(), tu, sa, pa); + BuildCode bc=new BuildCode(state, bf.getMap(), tu, sa, pa, mlpa); bc.buildCode(); } } diff --git a/Robust/src/Tests/mlp/tinyTest/makefile b/Robust/src/Tests/mlp/tinyTest/makefile index ad9d6ba8..897d72e8 100644 --- a/Robust/src/Tests/mlp/tinyTest/makefile +++ b/Robust/src/Tests/mlp/tinyTest/makefile @@ -3,8 +3,7 @@ PROGRAM=test SOURCE_FILES=$(PROGRAM).java BUILDSCRIPT=~/research/Robust/src/buildscript -BSFLAGS= -mlpdebug -justanalyze -mainclass Test -ownership -ownallocdepth 1 -ownwritedots final -enable-assertions -flatirusermethods -ownaliasfile aliases.txt #-justanalyze -recover -#BSFLAGS= -mainclass Test -ownership -ownallocdepth 1 -ownwritedots final -enable-assertions -flatirusermethods -ownaliasfile aliases.txt #-justanalyze -recover +BSFLAGS= -mlpdebug -mainclass Test -ownership -ownallocdepth 1 -ownwritedots final -enable-assertions -flatirusermethods -ownaliasfile aliases.txt all: $(PROGRAM).bin diff --git a/Robust/src/Tests/mlp/tinyTest/test.java b/Robust/src/Tests/mlp/tinyTest/test.java index 2c38702c..c55d0b18 100644 --- a/Robust/src/Tests/mlp/tinyTest/test.java +++ b/Robust/src/Tests/mlp/tinyTest/test.java @@ -40,5 +40,12 @@ public class Test { y = y + 1; x = x + 1; z = z + 1; + + //Integer i; + //afunc( i ); + } + + public static void afunc( Integer i ) { + i = null; } }