From: jjenista Date: Wed, 23 Jun 2010 23:57:55 +0000 (+0000) Subject: More pieces for new version of analysis X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=2f34178e87157ec58a013b05455066452e9a74ce;p=IRC.git More pieces for new version of analysis --- diff --git a/Robust/src/Analysis/Disjoint/DisjointAnalysis.java b/Robust/src/Analysis/Disjoint/DisjointAnalysis.java index 3649b822..5595e5ca 100644 --- a/Robust/src/Analysis/Disjoint/DisjointAnalysis.java +++ b/Robust/src/Analysis/Disjoint/DisjointAnalysis.java @@ -3,6 +3,7 @@ package Analysis.Disjoint; import Analysis.CallGraph.*; import Analysis.Liveness; import Analysis.ArrayReferencees; +import Analysis.RBlockRelationAnalysis; import IR.*; import IR.Flat.*; import IR.Tree.Modifiers; @@ -332,6 +333,7 @@ public class DisjointAnalysis { public CallGraph callGraph; public Liveness liveness; public ArrayReferencees arrayReferencees; + public RBlockRelationAnalysis rblockRel; public TypeUtil typeUtil; public int allocationDepth; @@ -553,19 +555,19 @@ public class DisjointAnalysis { TypeUtil tu, CallGraph cg, Liveness l, - ArrayReferencees ar - //RBlockRelationAnalysis rra - ) throws java.io.IOException { - init( s, tu, cg, l, ar ); + ArrayReferencees ar, + RBlockRelationAnalysis rra + ) { + init( s, tu, cg, l, ar, rra ); } protected void init( State state, TypeUtil typeUtil, CallGraph callGraph, Liveness liveness, - ArrayReferencees arrayReferencees - //RBlockRelationAnalysis rra - ) throws java.io.IOException { + ArrayReferencees arrayReferencees, + RBlockRelationAnalysis rra + ) { analysisComplete = false; @@ -574,6 +576,7 @@ public class DisjointAnalysis { this.callGraph = callGraph; this.liveness = liveness; this.arrayReferencees = arrayReferencees; + this.rblockRel = rra; this.allocationDepth = state.DISJOINTALLOCDEPTH; this.releaseMode = state.DISJOINTRELEASEMODE; this.determinismDesired = state.DISJOINTDETERMINISM; @@ -620,7 +623,12 @@ public class DisjointAnalysis { double timeStartAnalysis = (double) System.nanoTime(); // start interprocedural fixed-point computation - analyzeMethods(); + try { + analyzeMethods(); + } catch( IOException e ) { + throw new Error( "IO Exception while writing disjointness analysis output." ); + } + analysisComplete=true; double timeEndAnalysis = (double) System.nanoTime(); @@ -629,29 +637,33 @@ public class DisjointAnalysis { String justtime = String.format( "%.2f", dt ); System.out.println( treport ); - if( writeFinalDOTs && !writeAllIncrementalDOTs ) { - writeFinalGraphs(); - } + try { + if( writeFinalDOTs && !writeAllIncrementalDOTs ) { + writeFinalGraphs(); + } - if( state.DISJOINTWRITEIHMS ) { - writeFinalIHMs(); - } + if( state.DISJOINTWRITEIHMS ) { + writeFinalIHMs(); + } - if( state.DISJOINTWRITEINITCONTEXTS ) { - writeInitialContexts(); - } + if( state.DISJOINTWRITEINITCONTEXTS ) { + writeInitialContexts(); + } - if( state.DISJOINTALIASFILE != null ) { - if( state.TASK ) { - writeAllSharing(state.DISJOINTALIASFILE, treport, justtime, state.DISJOINTALIASTAB, state.lines); - } else { - writeAllSharingJava(state.DISJOINTALIASFILE, - treport, - justtime, - state.DISJOINTALIASTAB, - state.lines - ); + if( state.DISJOINTALIASFILE != null ) { + if( state.TASK ) { + writeAllSharing(state.DISJOINTALIASFILE, treport, justtime, state.DISJOINTALIASTAB, state.lines); + } else { + writeAllSharingJava(state.DISJOINTALIASFILE, + treport, + justtime, + state.DISJOINTALIASTAB, + state.lines + ); + } } + } catch( IOException e ) { + throw new Error( "IO Exception while writing disjointness analysis output." ); } } diff --git a/Robust/src/Analysis/OoOJava/OoOJavaAnalysis.java b/Robust/src/Analysis/OoOJava/OoOJavaAnalysis.java index ee4cff96..130c8f6d 100644 --- a/Robust/src/Analysis/OoOJava/OoOJavaAnalysis.java +++ b/Robust/src/Analysis/OoOJava/OoOJavaAnalysis.java @@ -6,13 +6,13 @@ import java.util.Iterator; import java.util.Set; import java.util.Stack; +import Analysis.CallGraph.CallGraph; import Analysis.ArrayReferencees; import Analysis.Liveness; -import Analysis.CallGraph.CallGraph; +import Analysis.RBlockRelationAnalysis; import Analysis.Disjoint.DisjointAnalysis; -import Analysis.OwnershipAnalysis.AllocationSite; -import Analysis.OwnershipAnalysis.MethodContext; import IR.Descriptor; +import IR.MethodDescriptor; import IR.Operation; import IR.State; import IR.TypeUtil; @@ -33,29 +33,9 @@ public class OoOJavaAnalysis { private State state; private TypeUtil typeUtil; private CallGraph callGraph; - private DisjointAnalysis disjointAnalysis; - - // an implicit SESE is automatically spliced into - // the IR graph around the C main before this analysis--it - // is nothing special except that we can make assumptions - // about it, such as the whole program ends when it ends - private FlatSESEEnterNode mainSESE; - - // SESEs that are the root of an SESE tree belong to this - // set--the main SESE is always a root, statically SESEs - // inside methods are a root because we don't know how they - // will fit into the runtime tree of SESEs - private Set rootSESEs; - - // simply a set of every reachable SESE in the program, not - // including caller placeholder SESEs - private Set allSESEs; - - // A mapping of flat nodes to the stack of SESEs for that node, where - // an SESE is the child of the SESE directly below it on the stack. - // These stacks do not reflect the heirarchy over methods calls--whenever - // there is an empty stack it means all variables are available. - private Hashtable> seseStacks; + private RBlockRelationAnalysis rblockRel; + private DisjointAnalysis disjointAnalysisTaints; + private DisjointAnalysis disjointAnalysisReach; private Hashtable> livenessRootView; private Hashtable> livenessVirtualReads; @@ -67,31 +47,15 @@ public class OoOJavaAnalysis { private Hashtable wdvNodesToSpliceIn; - private Hashtable> mapMethodContextToLiveInAllocationSiteSet; - // private Hashtable conflictsResults; // private Hashtable methodSummaryResults; // private OwnershipAnalysis ownAnalysisForSESEConflicts; // private Hashtable conflictGraphResults; - // temporal data structures to track analysis progress. - static private int uniqueLockSetId = 0; +// static private int uniqueLockSetId = 0; public static int maxSESEage = -1; - // use these methods in BuildCode to have access to analysis results - public FlatSESEEnterNode getMainSESE() { - return mainSESE; - } - - public Set getRootSESEs() { - return rootSESEs; - } - - public Set getAllSESEs() { - return allSESEs; - } - public int getMaxSESEage() { return maxSESEage; } @@ -102,21 +66,19 @@ public class OoOJavaAnalysis { return cp; } - public OoOJavaAnalysis(State state, TypeUtil tu, CallGraph callGraph, - DisjointAnalysis disjointAnalysis, Liveness liveness, ArrayReferencees arrayReferencees) { + public OoOJavaAnalysis(State state, + TypeUtil typeUtil, + CallGraph callGraph, + Liveness liveness, + ArrayReferencees arrayReferencees) { double timeStartAnalysis = (double) System.nanoTime(); this.state = state; - this.typeUtil = tu; + this.typeUtil = typeUtil; this.callGraph = callGraph; - this.disjointAnalysis = disjointAnalysis; this.maxSESEage = state.MLP_MAXSESEAGE; - rootSESEs = new HashSet(); - allSESEs = new HashSet(); - - seseStacks = new Hashtable>(); livenessRootView = new Hashtable>(); livenessVirtualReads = new Hashtable>(); variableResults = new Hashtable(); @@ -126,7 +88,16 @@ public class OoOJavaAnalysis { notAvailableIntoSESE = new Hashtable>(); - mapMethodContextToLiveInAllocationSiteSet = new Hashtable>(); + // add all methods transitively reachable from the + // source's main to set for analysis + MethodDescriptor mdSourceEntry = typeUtil.getMain(); + FlatMethod fmMain = state.getMethodFlat( mdSourceEntry ); + + Set descriptorsToAnalyze = + callGraph.getAllMethods( mdSourceEntry ); + + descriptorsToAnalyze.add( mdSourceEntry ); + // conflictsResults = new Hashtable(); // methodSummaryResults = new Hashtable(); @@ -136,36 +107,20 @@ public class OoOJavaAnalysis { // isAfterChildSESEIndicatorMap = new Hashtable(); // conflictGraphLockMap = new Hashtable>(); - FlatMethod fmMain = state.getMethodFlat(typeUtil.getMain()); - - mainSESE = (FlatSESEEnterNode) fmMain.getNext(0); - mainSESE.setfmEnclosing(fmMain); - mainSESE.setmdEnclosing(fmMain.getMethod()); - mainSESE.setcdEnclosing(fmMain.getMethod().getClassDesc()); - - // 1st pass - // run analysis on each method that is actually called - // reachability analysis already computed this so reuse - Iterator methItr = disjointAnalysis.getDescriptorsToAnalyze().iterator(); - while (methItr.hasNext()) { - Descriptor d = methItr.next(); - FlatMethod fm = state.getMethodFlat(d); - - // find every SESE from methods that may be called - // and organize them into roots and children - buildForestForward(fm); - } - - // 2nd pass, results are saved in FlatSESEEnterNode, so - // intermediate results, for safety, are discarded - Iterator rootItr = rootSESEs.iterator(); + // 1st pass, find basic rblock relations + RBlockRelationAnalysis rblockRel = + new RBlockRelationAnalysis(state, typeUtil, callGraph); + + // 2nd pass, liveness, in-set out-set (no virtual reads yet!) + Iterator rootItr = + rblockRel.getRootSESEs().iterator(); while (rootItr.hasNext()) { FlatSESEEnterNode root = rootItr.next(); livenessAnalysisBackward(root, true, null); } - // 3rd pass - methItr = disjointAnalysis.getDescriptorsToAnalyze().iterator(); + // 3rd pass, variable analysis + Iterator methItr = descriptorsToAnalyze.iterator(); while (methItr.hasNext()) { Descriptor d = methItr.next(); FlatMethod fm = state.getMethodFlat(d); @@ -177,25 +132,24 @@ public class OoOJavaAnalysis { // 4th pass, compute liveness contribution from // virtual reads discovered in variable pass - rootItr = rootSESEs.iterator(); + rootItr = rblockRel.getRootSESEs().iterator(); while (rootItr.hasNext()) { FlatSESEEnterNode root = rootItr.next(); livenessAnalysisBackward(root, true, null); } - - /* - * SOMETHING IS WRONG WITH THIS, DON'T USE IT UNTIL IT CAN BE FIXED - * - * // 5th pass methItr = ownAnalysis.descriptorsToAnalyze.iterator(); while( - * methItr.hasNext() ) { Descriptor d = methItr.next(); FlatMethod fm = - * state.getMethodFlat( d ); - * - * // prune variable results in one traversal // by removing reference - * variables that are not live pruneVariableResultsWithLiveness( fm ); } - */ - - // 6th pass - methItr = disjointAnalysis.getDescriptorsToAnalyze().iterator(); + + // 5th pass, use disjointness with NO FLAGGED REGIONS + // to compute taints and effects + disjointAnalysisTaints = + new DisjointAnalysis(state, + typeUtil, + callGraph, + liveness, + arrayReferencees, + rblockRel); + + // 6th pass, not available analysis FOR VARIABLES! + methItr = descriptorsToAnalyze.iterator(); while (methItr.hasNext()) { Descriptor d = methItr.next(); FlatMethod fm = state.getMethodFlat(d); @@ -205,91 +159,10 @@ public class OoOJavaAnalysis { notAvailableForward(fm); } - } - - private void buildForestForward(FlatMethod fm) { - - // start from flat method top, visit every node in - // method exactly once, find SESEs and remember - // roots and child relationships - Set flatNodesToVisit = new HashSet(); - flatNodesToVisit.add(fm); - - Set visited = new HashSet(); - - Stack seseStackFirst = new Stack(); - seseStacks.put(fm, seseStackFirst); - - while (!flatNodesToVisit.isEmpty()) { - Iterator fnItr = flatNodesToVisit.iterator(); - FlatNode fn = fnItr.next(); - - Stack seseStack = seseStacks.get(fn); - assert seseStack != null; - - flatNodesToVisit.remove(fn); - visited.add(fn); - - buildForest_nodeActions(fn, seseStack, fm); + // MORE PASSES? - for (int i = 0; i < fn.numNext(); i++) { - FlatNode nn = fn.getNext(i); - - if (!visited.contains(nn)) { - flatNodesToVisit.add(nn); - - // clone stack and send along each analysis path - seseStacks.put(nn, (Stack) seseStack.clone()); - } - } - } } - private void buildForest_nodeActions(FlatNode fn, Stack seseStack, - FlatMethod fm) { - switch (fn.kind()) { - - case FKind.FlatSESEEnterNode: { - FlatSESEEnterNode fsen = (FlatSESEEnterNode) fn; - - if (!fsen.getIsCallerSESEplaceholder()) { - allSESEs.add(fsen); - } - - fsen.setfmEnclosing(fm); - fsen.setmdEnclosing(fm.getMethod()); - fsen.setcdEnclosing(fm.getMethod().getClassDesc()); - - if (seseStack.empty()) { - rootSESEs.add(fsen); - fsen.setParent(null); - } else { - seseStack.peek().addChild(fsen); - fsen.setParent(seseStack.peek()); - } - - seseStack.push(fsen); - } - break; - - case FKind.FlatSESEExitNode: { - FlatSESEExitNode fsexn = (FlatSESEExitNode) fn; - assert !seseStack.empty(); - FlatSESEEnterNode fsen = seseStack.pop(); - } - break; - - case FKind.FlatReturnNode: { - FlatReturnNode frn = (FlatReturnNode) fn; - if (!seseStack.empty() && !seseStack.peek().getIsCallerSESEplaceholder()) { - throw new Error("Error: return statement enclosed within SESE " - + seseStack.peek().getPrettyIdentifier()); - } - } - break; - - } - } private void livenessAnalysisBackward(FlatSESEEnterNode fsen, boolean toplevel, Hashtable> liveout) { @@ -422,9 +295,9 @@ public class OoOJavaAnalysis { FlatNode fn = (FlatNode) flatNodesToVisit.iterator().next(); flatNodesToVisit.remove(fn); - Stack seseStack = seseStacks.get(fn); + Stack seseStack = rblockRel.getRBlockStacks(fm, fn); assert seseStack != null; - + VarSrcTokTable prev = variableResults.get(fn); // merge sets from control flow joins @@ -579,7 +452,7 @@ public class OoOJavaAnalysis { FlatNode fn = (FlatNode) flatNodesToVisit.iterator().next(); flatNodesToVisit.remove(fn); - Stack seseStack = seseStacks.get(fn); + Stack seseStack = rblockRel.getRBlockStacks(fm, fn); assert seseStack != null; Set prev = notAvailableResults.get(fn); diff --git a/Robust/src/Main/Main.java b/Robust/src/Main/Main.java index 2bd8897b..664c4202 100644 --- a/Robust/src/Main/Main.java +++ b/Robust/src/Main/Main.java @@ -42,6 +42,7 @@ import Analysis.Prefetch.PrefetchAnalysis; import Analysis.FlatIRGraph.FlatIRGraph; import Analysis.OwnershipAnalysis.OwnershipAnalysis; import Analysis.MLP.MLPAnalysis; +import Analysis.RBlockRelationAnalysis; import Analysis.Disjoint.DisjointAnalysis; import Analysis.OoOJava.OoOJavaAnalysis; import Analysis.Loops.*; @@ -505,15 +506,14 @@ public class Main { CallGraph cg = new CallGraph(state); Liveness l = new Liveness(); ArrayReferencees ar = new ArrayReferencees(state); - DisjointAnalysis da = new DisjointAnalysis(state, tu, cg, l, ar); + DisjointAnalysis da = new DisjointAnalysis(state, tu, cg, l, ar, null); } if (state.OOOJAVA) { - CallGraph cg = new CallGraph(state); - Liveness l = new Liveness(); - ArrayReferencees ar = new ArrayReferencees(state); - DisjointAnalysis da = new DisjointAnalysis(state, tu, cg, l, ar); - OoOJavaAnalysis oa = new OoOJavaAnalysis(state, tu, cg, da, l, ar); + CallGraph cg = new CallGraph(state); + Liveness l = new Liveness(); + ArrayReferencees ar = new ArrayReferencees(state); + OoOJavaAnalysis oa = new OoOJavaAnalysis(state, tu, cg, l, ar); }