private Hashtable< FlatNode, Set<TempDescriptor> > notAvailableResults;
private Hashtable< FlatNode, CodePlan > codePlans;
- private static final int maxSESEage = 2;
+ private static int maxSESEage = -1;
// use these methods in BuildCode to have access to analysis results
this.typeUtil = tu;
this.callGraph = callGraph;
this.ownAnalysis = ownAnalysis;
+ this.maxSESEage = state.MLP_MAXSESEAGE;
// initialize analysis data structures
allSESEs = new HashSet<FlatSESEEnterNode>();
FlatMethod fmMain = state.getMethodFlat( tu.getMain() );
- rootSESE = (FlatSESEEnterNode) fmMain.getNext(0);
+ rootSESE = (FlatSESEEnterNode) fmMain.getNext(0);
+ rootSESE.setfmEnclosing( fmMain );
+ rootSESE.setmdEnclosing( fmMain.getMethod() );
+ rootSESE.setcdEnclosing( fmMain.getMethod().getClassDesc() );
// 1st pass
System.out.println( "" );
//System.out.println( "\nSESE Hierarchy\n--------------\n" ); printSESEHierarchy();
//System.out.println( "\nSESE Liveness\n-------------\n" ); printSESELiveness();
- //System.out.println( "\nLiveness Root View\n------------------\n"+fmMain.printMethod( livenessRootView ) );
- //System.out.println( "\nVariable Results\n----------------\n"+fmMain.printMethod( variableResults ) );
+ System.out.println( "\nLiveness Root View\n------------------\n"+fmMain.printMethod( livenessRootView ) );
+ System.out.println( "\nVariable Results\n----------------\n"+fmMain.printMethod( variableResults ) );
//System.out.println( "\nNot Available Results\n---------------------\n"+fmMain.printMethod( notAvailableResults ) );
System.out.println( "\nCode Plans\n----------\n"+fmMain.printMethod( codePlans ) );
}
FlatSESEEnterNode fsen = (FlatSESEEnterNode) fn;
allSESEs.add( fsen );
- fsen.setEnclosingFlatMeth( fm );
+ fsen.setfmEnclosing( fm );
+ fsen.setmdEnclosing( fm.getMethod() );
+ fsen.setcdEnclosing( fm.getMethod().getClassDesc() );
if( !seseStack.empty() ) {
seseStack.peek().addChild( fsen );
// note that FlatOpNode's that aren't ASSIGN
// fall through to this default case
default: {
+
// decide if we must stall for variables dereferenced at this node
- Set<VariableSourceToken> stallSet = vstTable.getStallSet( currentSESE );
+ Set<VariableSourceToken> potentialStallSet =
+ vstTable.getChildrenVSTs( currentSESE );
+
+ // a node with no live set has nothing to stall for
+ Set<TempDescriptor> liveSet = livenessRootView.get( fn );
+ if( liveSet == null ) {
+ break;
+ }
TempDescriptor[] readarray = fn.readsTemps();
for( int i = 0; i < readarray.length; i++ ) {
continue;
}
- Set<VariableSourceToken> readSet = vstTable.get( readtmp );
-
- //Two cases:
+ // Two cases:
+ Set<VariableSourceToken> srcs = vstTable.get( readtmp );
+ assert !srcs.isEmpty();
- //1) Multiple token/age pairs or unknown age: Stall for
- //dynamic name only.
-
+ // 1) Multiple token/age pairs or unknown age: Stall for
+ // dynamic name only.
+ if( srcs.size() > 1 ||
+ srcs.iterator().next().getAge() == maxSESEage ) {
+ // identify that this is a stall, and allocate an integer
+ // pointer in the generated code that keeps a pointer to
+ // the source SESE and the address of where to get this thing
+ // --then the stall is just wait for that, and copy the
+ // one thing because we're not sure if we can copy other stuff
- //2) Single token/age pair: Stall for token/age pair, and copy
- //all live variables with same token/age pair at the same
- //time. This is the same stuff that the notavaialable analysis
- //marks as now available.
+ // NEEDS WORK!
+
+
- //VarSrcTokTable table = variableResults.get( fn );
- //Set<VariableSourceToken> srcs = table.get( rTemp );
+ // 2) Single token/age pair: Stall for token/age pair, and copy
+ // all live variables with same token/age pair at the same
+ // time. This is the same stuff that the notavaialable analysis
+ // marks as now available.
+ } else {
+ VariableSourceToken vst = srcs.iterator().next();
- //XXXXXXXXXX: Note: We have to generate code to do these
- //copies in the codeplan. Note we should only copy the
- //variables that are live!
+ Iterator<VariableSourceToken> availItr =
+ vstTable.get( vst.getSESE(), vst.getAge() ).iterator();
- /*
- if( srcs.size() == 1 ) {
- VariableSourceToken vst = srcs.iterator().next();
-
- Iterator<VariableSourceToken> availItr = table.get( vst.getSESE(),
- vst.getAge()
- ).iterator();
while( availItr.hasNext() ) {
VariableSourceToken vstAlsoAvail = availItr.next();
- notAvailSet.removeAll( vstAlsoAvail.getRefVars() );
- }
- }
- */
+ // only grab additional stuff that is live
+ Set<TempDescriptor> copySet = new HashSet<TempDescriptor>();
+
+ Iterator<TempDescriptor> refVarItr = vstAlsoAvail.getRefVars().iterator();
+ while( refVarItr.hasNext() ) {
+ TempDescriptor refVar = refVarItr.next();
+ if( liveSet.contains( refVar ) ) {
+ copySet.add( refVar );
+ }
+ }
+
+ if( !copySet.isEmpty() ) {
+ plan.addStall2CopySet( vstAlsoAvail, copySet );
+ }
+ }
+ }
- // assert notAvailSet.containsAll( writeSet );
+ // assert that everything being stalled for is in the
+ // "not available" set coming into this flat node and
+ // that every VST identified is in the possible "stall set"
+ // that represents VST's from children SESE's
- /*
- for( Iterator<VariableSourceToken> readit = readSet.iterator();
- readit.hasNext(); ) {
- VariableSourceToken vst = readit.next();
- if( stallSet.contains( vst ) ) {
- if( before == null ) {
- before = "**STALL for:";
- }
- before += "("+vst+" "+readtmp+")";
- }
- }
- */
}
} break;
} // end switch
+ // identify sese-age pairs that are statically useful
+ // and should have an associated SESE variable in code
+ Set<VariableSourceToken> staticSet = vstTable.getStaticSet();
+ Iterator<VariableSourceToken> vstItr = staticSet.iterator();
+ while( vstItr.hasNext() ) {
+ VariableSourceToken vst = vstItr.next();
+ currentSESE.addNeededStaticName(
+ new SESEandAgePair( vst.getSESE(), vst.getAge() )
+ );
+ }
+
// if any variable at this node has a static source (exactly one sese)
// but goes to a dynamic source at a next node, write its dynamic addr
Set<VariableSourceToken> static2dynamicSet = new HashSet<VariableSourceToken>();