From: jjenista Date: Thu, 23 Sep 2010 19:06:54 +0000 (+0000) Subject: support for optimizations later, leaf tasks need less data X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=d95b5633af15df81d37e4f6a558e46ce4875aab9;p=IRC.git support for optimizations later, leaf tasks need less data --- diff --git a/Robust/src/Analysis/OoOJava/RBlockRelationAnalysis.java b/Robust/src/Analysis/OoOJava/RBlockRelationAnalysis.java index f47d0cf1..73f90ced 100644 --- a/Robust/src/Analysis/OoOJava/RBlockRelationAnalysis.java +++ b/Robust/src/Analysis/OoOJava/RBlockRelationAnalysis.java @@ -40,6 +40,10 @@ public class RBlockRelationAnalysis { > > fm2relmap; + // to support calculation of leaf SESEs (no children even + // through method calls) for optimization during code gen + protected Set methodsContainingSESEs; + public RBlockRelationAnalysis( State state, TypeUtil typeUtil, @@ -51,6 +55,8 @@ public class RBlockRelationAnalysis { rootSESEs = new HashSet(); allSESEs = new HashSet(); + methodsContainingSESEs = new HashSet(); + fm2relmap = new Hashtable< FlatMethod, Hashtable< FlatNode, Stack > >(); @@ -71,6 +77,8 @@ public class RBlockRelationAnalysis { descriptorsToAnalyze.add( mdSourceEntry ); analyzeMethods( descriptorsToAnalyze ); + + computeLeafSESEs(); } @@ -162,6 +170,7 @@ public class RBlockRelationAnalysis { if( !fsen.getIsCallerSESEplaceholder() ) { allSESEs.add( fsen ); + methodsContainingSESEs.add( fm.getMethod() ); } fsen.setfmEnclosing( fm ); @@ -197,4 +206,67 @@ public class RBlockRelationAnalysis { } } + + + protected void computeLeafSESEs() { + for( Iterator itr = allSESEs.iterator(); + itr.hasNext(); + ) { + FlatSESEEnterNode fsen = itr.next(); + + boolean hasNoNestedChildren = !fsen.getChildren().isEmpty(); + boolean hasNoChildrenByCall = !hasChildrenByCall( fsen ); + + fsen.setIsLeafSESE( hasNoNestedChildren && + hasNoChildrenByCall ); + } + } + + + protected boolean hasChildrenByCall( FlatSESEEnterNode fsen ) { + + // visit every flat node in SESE body, find method calls that + // may transitively call methods with SESEs enclosed + Set flatNodesToVisit = new HashSet(); + flatNodesToVisit.add( fsen ); + + Set visited = new HashSet(); + + while( !flatNodesToVisit.isEmpty() ) { + Iterator fnItr = flatNodesToVisit.iterator(); + FlatNode fn = fnItr.next(); + + flatNodesToVisit.remove( fn ); + visited.add( fn ); + + if( fn.kind() == FKind.FlatCall ) { + FlatCall fc = (FlatCall) fn; + MethodDescriptor mdCallee = fc.getMethod(); + Set reachable = new HashSet(); + + reachable.addAll( callGraph.getAllMethods( mdCallee ) ); + reachable.retainAll( methodsContainingSESEs ); + + if( !reachable.isEmpty() ) { + return true; + } + } + + if( fn == fsen.getFlatExit() ) { + // don't enqueue any futher nodes + continue; + } + + for( int i = 0; i < fn.numNext(); i++ ) { + FlatNode nn = fn.getNext( i ); + + if( !visited.contains( nn ) ) { + flatNodesToVisit.add( nn ); + } + } + } + + return false; + } + } diff --git a/Robust/src/IR/Flat/FlatSESEEnterNode.java b/Robust/src/IR/Flat/FlatSESEEnterNode.java index 086b1b76..bb33b988 100644 --- a/Robust/src/IR/Flat/FlatSESEEnterNode.java +++ b/Robust/src/IR/Flat/FlatSESEEnterNode.java @@ -28,6 +28,11 @@ public class FlatSESEEnterNode extends FlatNode { protected Integer oldestAgeToTrack; protected boolean isCallerSESEplaceholder; + protected static final int ISLEAF_UNINIT = 1; + protected static final int ISLEAF_FALSE = 2; + protected static final int ISLEAF_TRUE = 3; + protected int isLeafSESE; + protected Set children; protected Set inVars; @@ -98,6 +103,8 @@ public class FlatSESEEnterNode extends FlatNode { isCallerSESEplaceholder = false; + isLeafSESE = ISLEAF_UNINIT; + firstDepRecField = null; numDepRecs = 0; } @@ -397,4 +404,22 @@ public class FlatSESEEnterNode extends FlatNode { public void addInVarForDynamicCoarseConflictResolution(TempDescriptor inVar) { inVarsForDynamicCoarseConflictResolution.add(inVar); } + + + public void setIsLeafSESE( boolean isLeaf ) { + //protected static final int ISLEAF_UNINIT = 1; + if( isLeaf ) { + isLeafSESE = ISLEAF_TRUE; + } else { + isLeafSESE = ISLEAF_FALSE; + } + } + + public boolean getIsLeafSESE() { + if( isLeafSESE == ISLEAF_UNINIT ) { + throw new Error( "isLeafSESE uninitialized" ); + } + + return isLeafSESE == ISLEAF_TRUE; + } }