From: jjenista Date: Fri, 10 Apr 2009 21:42:37 +0000 (+0000) Subject: stable, non-functional still X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=00d77de9a33471955079714fd09aec4fc4a3421c;p=IRC.git stable, non-functional still --- diff --git a/Robust/src/Analysis/MLP/MLPAnalysis.java b/Robust/src/Analysis/MLP/MLPAnalysis.java index f4ca377a..525d7377 100644 --- a/Robust/src/Analysis/MLP/MLPAnalysis.java +++ b/Robust/src/Analysis/MLP/MLPAnalysis.java @@ -19,8 +19,7 @@ public class MLPAnalysis { private Set seseRoots; private Hashtable< FlatNode, Stack > seseStacks; - - private Hashtable< FlatNode, Set > pointResults; + private Hashtable< FlatNode, VarSrcTokTable > pointResults; public MLPAnalysis( State state, @@ -39,7 +38,7 @@ public class MLPAnalysis { // initialize analysis data structures seseRoots = new HashSet(); seseStacks = new Hashtable< FlatNode, Stack >(); - pointResults = new Hashtable< FlatNode, Set >(); + pointResults = new Hashtable< FlatNode, VarSrcTokTable >(); // run analysis on each method that is actually called @@ -120,7 +119,7 @@ public class MLPAnalysis { analyzeFlatNodeForward( fn, seseStack ); // initialize for backward computation in next step - pointResults.put( fn, new HashSet() ); + pointResults.put( fn, new VarSrcTokTable() ); for( int i = 0; i < fn.numNext(); i++ ) { FlatNode nn = fn.getNext( i ); @@ -148,16 +147,16 @@ public class MLPAnalysis { FlatNode fn = (FlatNode) flatNodesToVisit.iterator().next(); flatNodesToVisit.remove( fn ); - Set prev = pointResults.get( fn ); + VarSrcTokTable prev = pointResults.get( fn ); // merge sets from control flow joins - Set merge = new HashSet(); + VarSrcTokTable inUnion = new VarSrcTokTable(); for( int i = 0; i < fn.numNext(); i++ ) { - FlatNode nn = fn.getNext( i ); - merge = mergeVSTsets( merge, pointResults.get( nn ) ); + FlatNode nn = fn.getNext( i ); + inUnion.merge( pointResults.get( nn ) ); } - Set curr = analyzeFlatNodeBackward( fn, merge, fsen ); + VarSrcTokTable curr = analyzeFlatNodeBackward( fn, inUnion, fsen ); // if a new result, schedule backward nodes for analysis if( !prev.equals( curr ) ) { @@ -225,9 +224,9 @@ public class MLPAnalysis { } - private Set analyzeFlatNodeBackward( FlatNode fn, - Set vstSet, - FlatSESEEnterNode currentSESE ) { + private VarSrcTokTable analyzeFlatNodeBackward( FlatNode fn, + VarSrcTokTable vstTable, + FlatSESEEnterNode currentSESE ) { switch( fn.kind() ) { case FKind.FlatSESEEnterNode: { @@ -259,16 +258,14 @@ public class MLPAnalysis { // handle effects of statement in reverse, writes then reads TempDescriptor [] writeTemps = fn.writesTemps(); for( int i = 0; i < writeTemps.length; ++i ) { - vstSet = killTemp( vstSet, writeTemps[i] ); + vstTable.remove( writeTemps[i] ); } TempDescriptor [] readTemps = fn.readsTemps(); for( int i = 0; i < readTemps.length; ++i ) { - Set vstNew = new HashSet(); - vstNew.add( new VariableSourceToken( currentSESE, - readTemps[i], - new Integer( 0 ) ) ); - vstSet = mergeVSTsets( vstSet, vstNew ); + vstTable.add( new VariableSourceToken( currentSESE, + readTemps[i], + new Integer( 0 ) ) ); } } break; @@ -312,88 +309,6 @@ public class MLPAnalysis { } // end switch - return vstSet; - } - - - private Set killTemp( Set s, - TempDescriptor t ) { - Set out = new HashSet(); - - Iterator vstitr = s.iterator(); - while( vstitr.hasNext() ) { - VariableSourceToken vst = vstitr.next(); - - if( !vst.getVar().equals( t ) ) { - out.add( vst ); - } - } - - return out; - } - - - private Set mergeVSTsets( Set s1, - Set s2 ) { - - Set out = new HashSet(); - - Iterator vst1itr = s1.iterator(); - while( vst1itr.hasNext() ) { - VariableSourceToken vst1 = vst1itr.next(); - - int changeAge = -1; - - Iterator vst2itr = s2.iterator(); - while( vst2itr.hasNext() ) { - VariableSourceToken vst2 = vst2itr.next(); - - if( vst1.getSESE().equals( vst2.getSESE() ) && - vst1.getVar() .equals( vst2.getVar() ) ) { - changeAge = vst1.getAge(); - int a = vst2.getAge(); - if( a < changeAge ) { - changeAge = a; - } - break; - } - } - - if( changeAge < 0 ) { - out.add( vst1 ); - } else { - out.add( new VariableSourceToken( vst1.getSESE(), - vst1.getVar(), - new Integer( changeAge ) ) ); - } - } - - - Iterator vst2itr = s2.iterator(); - while( vst2itr.hasNext() ) { - VariableSourceToken vst2 = vst2itr.next(); - - boolean matchSESEandVar = false; - - vst1itr = s1.iterator(); - while( vst1itr.hasNext() ) { - VariableSourceToken vst1 = vst1itr.next(); - - if( vst1.getSESE().equals( vst2.getSESE() ) && - vst1.getVar() .equals( vst2.getVar() ) ) { - matchSESEandVar = true; - break; - } - } - - if( !matchSESEandVar ) { - out.add( vst2 ); - } - } - - - return out; + return vstTable; } } - - diff --git a/Robust/src/Analysis/MLP/SVKey.java b/Robust/src/Analysis/MLP/SVKey.java index afc53d09..d23ea608 100644 --- a/Robust/src/Analysis/MLP/SVKey.java +++ b/Robust/src/Analysis/MLP/SVKey.java @@ -35,8 +35,8 @@ public class SVKey { SVKey k = (SVKey) o; - return var.equals( vst.var ) && - sese.equals( vst.sese ); + return var.equals( k.var ) && + sese.equals( k.sese ); } public int hashCode() { diff --git a/Robust/src/Analysis/MLP/VarSrcTokTable.java b/Robust/src/Analysis/MLP/VarSrcTokTable.java index 9a22b5b3..9950af24 100644 --- a/Robust/src/Analysis/MLP/VarSrcTokTable.java +++ b/Robust/src/Analysis/MLP/VarSrcTokTable.java @@ -92,10 +92,10 @@ public class VarSrcTokTable { public void merge( VarSrcTokTable table ) { trueSet.addAll( table.trueSet ); - Iterator i; + Iterator itr; Set s; - itr = sese2vst.getEntrySet().iterator(); + itr = sese2vst.entrySet().iterator(); while( itr.hasNext() ) { Map.Entry me = (Map.Entry) itr.next(); FlatSESEEnterNode sese = (FlatSESEEnterNode) me.getKey(); @@ -108,11 +108,11 @@ public class VarSrcTokTable { s1.addAll( s2 ); } } - s = table.sese2vst.getEntrySet(); - s.retainAll( sese2vst.getEntrySet() ); + s = table.sese2vst.entrySet(); + s.retainAll( sese2vst.entrySet() ); sese2vst.putAll( table.sese2vst ); - itr = var2vst.getEntrySet().iterator(); + itr = var2vst.entrySet().iterator(); while( itr.hasNext() ) { Map.Entry me = (Map.Entry) itr.next(); TempDescriptor var = (TempDescriptor) me.getKey(); @@ -125,11 +125,11 @@ public class VarSrcTokTable { s1.addAll( s2 ); } } - s = table.var2vst.getEntrySet(); - s.retainAll( var2vst.getEntrySet() ); + s = table.var2vst.entrySet(); + s.retainAll( var2vst.entrySet() ); var2vst.putAll( table.var2vst ); - itr = sv2vst.getEntrySet().iterator(); + itr = sv2vst.entrySet().iterator(); while( itr.hasNext() ) { Map.Entry me = (Map.Entry) itr.next(); SVKey key = (SVKey) me.getKey(); @@ -142,8 +142,8 @@ public class VarSrcTokTable { s1.addAll( s2 ); } } - s = table.sv2vst.getEntrySet(); - s.retainAll( sv2vst.getEntrySet() ); + s = table.sv2vst.entrySet(); + s.retainAll( sv2vst.entrySet() ); sv2vst.putAll( table.sv2vst ); } @@ -178,11 +178,13 @@ public class VarSrcTokTable { } trueSet.removeAll( s ); - sese2vst.remove( sese ); - var2vst .remove( var ); sv2vst .remove( key ); } + public void remove( VariableSourceToken vst ) { + trueSet.remove( vst ); + } + public boolean equals( Object o ) { if( o == null ) { return false; @@ -200,6 +202,10 @@ public class VarSrcTokTable { return trueSet.hashCode(); } + public Iterator iterator() { + return trueSet.iterator(); + } + public String toString() { return trueSet.toString(); }