}
- private void livenessAnalysisBackward( FlatSESEEnterNode fsen, boolean toplevel, Hashtable<FlatSESEExitNode, Set<TempDescriptor>> liveout, FlatExit fexit) {
+ private void livenessAnalysisBackward( FlatSESEEnterNode fsen,
+ boolean toplevel,
+ Hashtable< FlatSESEExitNode, Set<TempDescriptor> > liveout,
+ FlatExit fexit ) {
+
// start from an SESE exit, visit nodes in reverse up to
// SESE enter in a fixed-point scheme, where children SESEs
// should already be analyzed and therefore can be skipped
Set<TempDescriptor> liveIn,
FlatSESEEnterNode currentSESE,
boolean toplevel,
- Hashtable<FlatSESEExitNode, Set<TempDescriptor>> liveout) {
+ Hashtable< FlatSESEExitNode, Set<TempDescriptor> > liveout ) {
switch( fn.kind() ) {
// merge sets from control flow joins
VarSrcTokTable inUnion = new VarSrcTokTable();
for( int i = 0; i < fn.numPrev(); i++ ) {
- FlatNode nn = fn.getPrev( i );
+ FlatNode nn = fn.getPrev( i );
- inUnion.merge( variableResults.get( nn ) );
+ VarSrcTokTable incoming = variableResults.get( nn );
+ if( incoming != null ) {
+ incoming.assertConsistency();
+ }
+
+ inUnion.merge( incoming );
}
- VarSrcTokTable curr = variable_nodeActions( fn, inUnion, seseStack.peek() );
-
+ VarSrcTokTable curr = variable_nodeActions( fn, inUnion, seseStack.peek() );
+
// if a new result, schedule forward nodes for analysis
if( !curr.equals( prev ) ) {
+
+ curr.assertConsistency();
+
variableResults.put( fn, curr );
for( int i = 0; i < fn.numNext(); i++ ) {
FlatSESEEnterNode fsen = (FlatSESEEnterNode) fn;
assert fsen.equals( currentSESE );
vstTable.age( currentSESE );
+
+ vstTable.assertConsistency();
+
} break;
case FKind.FlatSESEExitNode: {
virLiveIn.addAll( virLiveInOld );
}
livenessVirtualReads.put( fn, virLiveIn );
+
+ vstTable.assertConsistency();
+
} break;
case FKind.FlatOpNode: {
// only break if this is an ASSIGN op node,
// otherwise fall through to default case
+
+ vstTable.assertConsistency();
+
break;
}
}
)
);
}
+
+ vstTable.assertConsistency();
+
} break;
} // end switch
public VarSrcTokTable() {
- trueSet = new HashSet<VariableSourceToken>();
+ trueSet = new HashSet<VariableSourceToken>();
sese2vst = new Hashtable< FlatSESEEnterNode, Set<VariableSourceToken> >();
var2vst = new Hashtable< TempDescriptor, Set<VariableSourceToken> >();
sv2vst = new Hashtable< SVKey, Set<VariableSourceToken> >();
+
+ assertConsistency();
}
}
public Set<VariableSourceToken> get( FlatSESEEnterNode sese,
- TempDescriptor refVar ) {
+ TempDescriptor refVar ) {
SVKey key = new SVKey( sese, refVar );
Set<VariableSourceToken> s = sv2vst.get( key );
if( s == null ) {
}
public Set<VariableSourceToken> get( FlatSESEEnterNode sese,
- Integer age ) {
- Set<VariableSourceToken> s = sese2vst.get( sese );
- if( s == null ) {
- s = new HashSet<VariableSourceToken>();
- sese2vst.put( sese, s );
+ Integer age ) {
+
+ HashSet<VariableSourceToken> s0 = (HashSet<VariableSourceToken>) sese2vst.get( sese );
+ if( s0 == null ) {
+ s0 = new HashSet<VariableSourceToken>();
+ sese2vst.put( sese, s0 );
}
+
+ Set<VariableSourceToken> s = (Set<VariableSourceToken>) s0.clone();
Iterator<VariableSourceToken> sItr = s.iterator();
while( sItr.hasNext() ) {
VariableSourceToken vst = sItr.next();
s.remove( vst );
}
}
+
return s;
}
- public void merge( VarSrcTokTable tableIn ) {
+ public void merge( VarSrcTokTable table ) {
- if( tableIn == null ) {
+ if( table == null ) {
return;
}
- // make a copy for modification to use in the merge
- VarSrcTokTable table = new VarSrcTokTable( tableIn );
+ System.out.println( "MERGING\n" );
+ System.out.println( "THIS="+this.toStringPrettyVerbose() );
+ System.out.println( "TABLEIN="+table.toStringPrettyVerbose() );
- trueSet.addAll( table.trueSet );
+ trueSet.addAll( table.trueSet );
Iterator itr;
+
// merge sese2vst mappings
itr = this.sese2vst.entrySet().iterator();
while( itr.hasNext() ) {
}
}
+
// merge var2vst mappings
itr = this.var2vst.entrySet().iterator();
while( itr.hasNext() ) {
}
}
+
// merge sv2vst mappings
itr = this.sv2vst.entrySet().iterator();
while( itr.hasNext() ) {
}
}
+ System.out.println( "OUT="+this.toStringPrettyVerbose() );
+
+
assertConsistency();
}
remove( vst );
// if there are other references to the token, alter the
- // token and then readd it to this table, because it has
+ // token and then re-add it to this table, because it has
// a new hash value now
Set<TempDescriptor> refVars = vst.getRefVars();
refVars.remove( refVar );
}
}
- //var2vst.remove( var );
+ var2vst.remove( refVar );
assertConsistency();
}
public void remove( FlatSESEEnterNode sese,
TempDescriptor var ) {
+ // dont' use this yet
+ assert false;
+
SVKey key = new SVKey( sese, var );
Set<VariableSourceToken> s = sv2vst.get( key );
if( s == null ) {
}
-
- // return a new table based on this one and
// age tokens with respect to SESE curr, where
// any curr tokens increase age by 1
- public VarSrcTokTable age( FlatSESEEnterNode curr ) {
-
- // create a table to modify as a copy of this
- VarSrcTokTable out = new VarSrcTokTable( this );
+ public void age( FlatSESEEnterNode curr ) {
Iterator<VariableSourceToken> itr = trueSet.iterator();
while( itr.hasNext() ) {
if( newAge > MAX_AGE ) {
newAge = MAX_AGE;
}
+
+ remove( vst );
- out.remove( vst );
-
- out.add( new VariableSourceToken( vst.getRefVars(),
- curr,
- newAge,
- vst.getAddrVar()
- )
- );
+ add( new VariableSourceToken( vst.getRefVars(),
+ curr,
+ newAge,
+ vst.getAddrVar()
+ )
+ );
}
}
-
- out.assertConsistency();
- return out;
+
+ assertConsistency();
}
VariableSourceToken vst = vstItr.next();
remove( vst );
-
+
add( new VariableSourceToken( vst.getRefVars(),
curr,
new Integer( 0 ),
assertConsistency();
}
-
+
// if we can get a value from the current SESE and the parent
// or a sibling, just getting from the current SESE suffices now
// return a set of temps that are virtually read
public Set<TempDescriptor> removeParentAndSiblingTokens( FlatSESEEnterNode curr,
Set<TempDescriptor> liveIn ) {
-
+
HashSet<TempDescriptor> virtualLiveIn = new HashSet<TempDescriptor>();
-
+
FlatSESEEnterNode parent = curr.getParent();
if( parent == null ) {
// have no parent or siblings
return virtualLiveIn;
}
-
+
remove_A_if_B( parent, curr, liveIn, virtualLiveIn );
Iterator<FlatSESEEnterNode> childItr = parent.getChildren().iterator();
if( childItr.hasNext() ) {
FlatSESEEnterNode child = childItr.next();
-
+
if( !child.equals( curr ) ) {
remove_A_if_B( child, curr, liveIn, virtualLiveIn );
}
VariableSourceToken vst = vstItr.next();
remove( vst );
}
- }
+ assertConsistency();
+ }
+
public Set<VariableSourceToken> getStallSet( FlatSESEEnterNode curr ) {
-
+
Set<VariableSourceToken> out = new HashSet<VariableSourceToken>();
-
+
Iterator<FlatSESEEnterNode> cItr = curr.getChildren().iterator();
while( cItr.hasNext() ) {
FlatSESEEnterNode child = cItr.next();
out.addAll( get( child ) );
}
+ assertConsistency();
return out;
}