From 3d76b42356094477e647a8fdd2e1a1f4c70c3317 Mon Sep 17 00:00:00 2001 From: jjenista Date: Thu, 7 May 2009 18:28:08 +0000 Subject: [PATCH] Curious. Found a bug in liveness where liveIn set becomes empty erroneously. While tracing bug back the output started producing the correct liveIn set, but the code diff confirms to me that I haven't made a functional change to the system. I've been trying to understand what happened, but for now I'll check in this working, stable capture and keep an eye on liveness results in case the bug is just latent now. --- Robust/src/Analysis/MLP/MLPAnalysis.java | 41 ++++++++++++++++++++---- Robust/src/Tests/mlp/tinyTest/test.java | 7 ++-- 2 files changed, 39 insertions(+), 9 deletions(-) diff --git a/Robust/src/Analysis/MLP/MLPAnalysis.java b/Robust/src/Analysis/MLP/MLPAnalysis.java index 77de936c..fbf9b5d9 100644 --- a/Robust/src/Analysis/MLP/MLPAnalysis.java +++ b/Robust/src/Analysis/MLP/MLPAnalysis.java @@ -351,7 +351,8 @@ public class MLPAnalysis { if( virtualReadTemps != null ) { Iterator vrItr = virtualReadTemps.iterator(); while( vrItr.hasNext() ) { - liveIn.add( vrItr.next() ); + TempDescriptor vrt = vrItr.next(); + liveIn.add( vrt ); } } } break; @@ -531,7 +532,9 @@ public class MLPAnalysis { for( int i = 0; i < fn.numPrev(); i++ ) { FlatNode nn = fn.getPrev( i ); Set availIn = isAvailableResults.get( nn ); - inIntersect.retainAll( availIn ); + if( availIn != null ) { + inIntersect.retainAll( availIn ); + } } Set curr = isAvailable_nodeActions( fn, inIntersect, seseStack.peek() ); @@ -551,6 +554,10 @@ public class MLPAnalysis { private Set isAvailable_nodeActions( FlatNode fn, Set isAvailSet, FlatSESEEnterNode currentSESE ) { + // any temps that get added to the available set + // at this node should be marked in this node's + // code plan as temps to be grabbed at runtime! + switch( fn.kind() ) { case FKind.FlatSESEEnterNode: { @@ -562,10 +569,15 @@ public class MLPAnalysis { FlatSESEExitNode fsexn = (FlatSESEExitNode) fn; FlatSESEEnterNode fsen = fsexn.getFlatEnter(); assert currentSESE.getChildren().contains( fsen ); + isAvailSet.addAll( fsen.getOutVarSet() ); } break; default: { - TempDescriptor [] writeTemps = fn.writesTemps(); + TempDescriptor [] readTemps = fn.readsTemps(); + for( int i = 0; i < readTemps.length; i++ ) { + TempDescriptor rTemp = readTemps[i]; + isAvailSet.add( rTemp ); + } } break; } // end switch @@ -610,10 +622,12 @@ public class MLPAnalysis { flatNodesToVisit.add( nn ); } } - } + } if( state.MLPDEBUG ) { - System.out.println( fm.printMethod( codePlans ) ); + System.out.println( fm.printMethod( livenessRootView ) ); + //System.out.println( fm.printMethod( isAvailableResults ) ); + //System.out.println( fm.printMethod( codePlans ) ); } } @@ -637,6 +651,7 @@ public class MLPAnalysis { Set stallSet = vstTable.getStallSet( currentSESE ); TempDescriptor[] readarray = fn.readsTemps(); for( int i = 0; i < readarray.length; i++ ) { + Set forRemoval = new HashSet(); TempDescriptor readtmp = readarray[i]; Set readSet = vstTable.get( readtmp ); //containsAny @@ -648,8 +663,22 @@ public class MLPAnalysis { before = "**STALL for:"; } before += "("+vst+" "+readtmp+")"; + + // mark any other variables from the static SESE for + // removal, because after this stall we'll have them + // all for later statements + forRemoval.addAll( vstTable.get( vst.getSESE(), + vst.getAge() + ) + ); } - } + } + + Iterator vstItr = forRemoval.iterator(); + while( vstItr.hasNext() ) { + VariableSourceToken vst = vstItr.next(); + vstTable.remove( vst ); + } } } break; diff --git a/Robust/src/Tests/mlp/tinyTest/test.java b/Robust/src/Tests/mlp/tinyTest/test.java index 1593134c..be14764f 100644 --- a/Robust/src/Tests/mlp/tinyTest/test.java +++ b/Robust/src/Tests/mlp/tinyTest/test.java @@ -18,17 +18,18 @@ public class Test { int z = n + j; */ - + int x = 1; int y = 1; sese fi { if( true ) { - x = y + 2; + x = y + 2; + y = 3; } } x = x + 1; - y = x + 1; + y = y + 1; } } -- 2.34.1