From: jjenista Date: Mon, 4 May 2009 22:24:19 +0000 (+0000) Subject: This is BANANAS. How can a table that calls assertConsistency all right before being... X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=f7d16a7024f4676e494801d935b8318d0eb65394;p=IRC.git This is BANANAS. How can a table that calls assertConsistency all right before being put in a hashtable come out and fail the call? Anyway, this is a stable compile but still a crash, but I fixed a get operation that was actually modifying the table while retrieving data. --- diff --git a/Robust/src/Analysis/MLP/MLPAnalysis.java b/Robust/src/Analysis/MLP/MLPAnalysis.java index 1413fbc5..d4e9af6a 100644 --- a/Robust/src/Analysis/MLP/MLPAnalysis.java +++ b/Robust/src/Analysis/MLP/MLPAnalysis.java @@ -204,7 +204,11 @@ public class MLPAnalysis { } - private void livenessAnalysisBackward( FlatSESEEnterNode fsen, boolean toplevel, Hashtable> liveout, FlatExit fexit) { + private void livenessAnalysisBackward( FlatSESEEnterNode fsen, + boolean toplevel, + Hashtable< FlatSESEExitNode, Set > 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 @@ -284,7 +288,7 @@ public class MLPAnalysis { Set liveIn, FlatSESEEnterNode currentSESE, boolean toplevel, - Hashtable> liveout) { + Hashtable< FlatSESEExitNode, Set > liveout ) { switch( fn.kind() ) { @@ -352,16 +356,24 @@ public class MLPAnalysis { // 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++ ) { @@ -381,6 +393,9 @@ public class MLPAnalysis { FlatSESEEnterNode fsen = (FlatSESEEnterNode) fn; assert fsen.equals( currentSESE ); vstTable.age( currentSESE ); + + vstTable.assertConsistency(); + } break; case FKind.FlatSESEExitNode: { @@ -396,6 +411,9 @@ public class MLPAnalysis { virLiveIn.addAll( virLiveInOld ); } livenessVirtualReads.put( fn, virLiveIn ); + + vstTable.assertConsistency(); + } break; case FKind.FlatOpNode: { @@ -437,6 +455,9 @@ public class MLPAnalysis { // only break if this is an ASSIGN op node, // otherwise fall through to default case + + vstTable.assertConsistency(); + break; } } @@ -460,6 +481,9 @@ public class MLPAnalysis { ) ); } + + vstTable.assertConsistency(); + } break; } // end switch diff --git a/Robust/src/Analysis/MLP/VarSrcTokTable.java b/Robust/src/Analysis/MLP/VarSrcTokTable.java index f99627f5..f2ff7245 100644 --- a/Robust/src/Analysis/MLP/VarSrcTokTable.java +++ b/Robust/src/Analysis/MLP/VarSrcTokTable.java @@ -26,11 +26,13 @@ public class VarSrcTokTable { public VarSrcTokTable() { - trueSet = new HashSet(); + trueSet = new HashSet(); sese2vst = new Hashtable< FlatSESEEnterNode, Set >(); var2vst = new Hashtable< TempDescriptor, Set >(); sv2vst = new Hashtable< SVKey, Set >(); + + assertConsistency(); } @@ -145,7 +147,7 @@ public class VarSrcTokTable { } public Set get( FlatSESEEnterNode sese, - TempDescriptor refVar ) { + TempDescriptor refVar ) { SVKey key = new SVKey( sese, refVar ); Set s = sv2vst.get( key ); if( s == null ) { @@ -156,12 +158,15 @@ public class VarSrcTokTable { } public Set get( FlatSESEEnterNode sese, - Integer age ) { - Set s = sese2vst.get( sese ); - if( s == null ) { - s = new HashSet(); - sese2vst.put( sese, s ); + Integer age ) { + + HashSet s0 = (HashSet) sese2vst.get( sese ); + if( s0 == null ) { + s0 = new HashSet(); + sese2vst.put( sese, s0 ); } + + Set s = (Set) s0.clone(); Iterator sItr = s.iterator(); while( sItr.hasNext() ) { VariableSourceToken vst = sItr.next(); @@ -169,25 +174,28 @@ public class VarSrcTokTable { 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() ) { @@ -214,6 +222,7 @@ public class VarSrcTokTable { } } + // merge var2vst mappings itr = this.var2vst.entrySet().iterator(); while( itr.hasNext() ) { @@ -240,6 +249,7 @@ public class VarSrcTokTable { } } + // merge sv2vst mappings itr = this.sv2vst.entrySet().iterator(); while( itr.hasNext() ) { @@ -266,6 +276,9 @@ public class VarSrcTokTable { } } + System.out.println( "OUT="+this.toStringPrettyVerbose() ); + + assertConsistency(); } @@ -337,7 +350,7 @@ public class VarSrcTokTable { 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 refVars = vst.getRefVars(); refVars.remove( refVar ); @@ -346,7 +359,7 @@ public class VarSrcTokTable { } } - //var2vst.remove( var ); + var2vst.remove( refVar ); assertConsistency(); } @@ -354,6 +367,9 @@ public class VarSrcTokTable { public void remove( FlatSESEEnterNode sese, TempDescriptor var ) { + // dont' use this yet + assert false; + SVKey key = new SVKey( sese, var ); Set s = sv2vst.get( key ); if( s == null ) { @@ -372,14 +388,9 @@ public class VarSrcTokTable { } - - // 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 itr = trueSet.iterator(); while( itr.hasNext() ) { @@ -391,20 +402,19 @@ public class VarSrcTokTable { 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(); } @@ -420,7 +430,7 @@ public class VarSrcTokTable { VariableSourceToken vst = vstItr.next(); remove( vst ); - + add( new VariableSourceToken( vst.getRefVars(), curr, new Integer( 0 ), @@ -432,28 +442,28 @@ public class VarSrcTokTable { 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 removeParentAndSiblingTokens( FlatSESEEnterNode curr, Set liveIn ) { - + HashSet virtualLiveIn = new HashSet(); - + FlatSESEEnterNode parent = curr.getParent(); if( parent == null ) { // have no parent or siblings return virtualLiveIn; } - + remove_A_if_B( parent, curr, liveIn, virtualLiveIn ); Iterator childItr = parent.getChildren().iterator(); if( childItr.hasNext() ) { FlatSESEEnterNode child = childItr.next(); - + if( !child.equals( curr ) ) { remove_A_if_B( child, curr, liveIn, virtualLiveIn ); } @@ -494,19 +504,22 @@ public class VarSrcTokTable { VariableSourceToken vst = vstItr.next(); remove( vst ); } - } + assertConsistency(); + } + public Set getStallSet( FlatSESEEnterNode curr ) { - + Set out = new HashSet(); - + Iterator cItr = curr.getChildren().iterator(); while( cItr.hasNext() ) { FlatSESEEnterNode child = cItr.next(); out.addAll( get( child ) ); } + assertConsistency(); return out; }