From 9e0601a3c2495436fa391815bab140087a0eda84 Mon Sep 17 00:00:00 2001 From: jjenista Date: Wed, 15 Apr 2009 21:27:31 +0000 Subject: [PATCH] fixed liveness analysis --- Robust/src/Analysis/MLP/MLPAnalysis.java | 71 +------------------ Robust/src/Analysis/MLP/VarSrcTokTable.java | 27 +++++++ .../src/Analysis/MLP/VariableSourceToken.java | 2 +- Robust/src/Tests/mlp/tinyTest/test.java | 2 +- 4 files changed, 32 insertions(+), 70 deletions(-) diff --git a/Robust/src/Analysis/MLP/MLPAnalysis.java b/Robust/src/Analysis/MLP/MLPAnalysis.java index c64542c4..5abe02d7 100644 --- a/Robust/src/Analysis/MLP/MLPAnalysis.java +++ b/Robust/src/Analysis/MLP/MLPAnalysis.java @@ -125,15 +125,13 @@ public class MLPAnalysis { FlatSESEEnterNode fsenChild = childItr.next(); computeReadAndWriteSetBackward( fsenChild ); } - - System.out.println( "backwards on "+fsen ); // 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 // because child SESE enter node has all necessary info Set flatNodesToVisit = new HashSet(); - flatNodesToVisit.add( fsen ); + //flatNodesToVisit.add( fsen ); FlatSESEExitNode fsexn = fsen.getFlatExit(); for( int i = 0; i < fsexn.numPrev(); i++ ) { @@ -160,10 +158,6 @@ public class MLPAnalysis { VarSrcTokTable curr = analyzeFlatNodeBackward( fn, inUnion, fsen ); - - //System.out.println( "\nConsidering "+fn+" and\n prev="+prev+"\n curr="+curr ); - - // if a new result, schedule backward nodes for analysis if( !curr.equals( prev ) ) { @@ -179,8 +173,6 @@ public class MLPAnalysis { } } - if( pointResults.get( fsen ) == null ) { System.out.println( "UGH" ); } - fsen.addInVarSet( pointResults.get( fsen ).get() ); if( state.MLPDEBUG ) { @@ -239,36 +231,17 @@ public class MLPAnalysis { case FKind.FlatSESEEnterNode: { FlatSESEEnterNode fsen = (FlatSESEEnterNode) fn; - vstTable.addAll( fsen.getInVarSet() ); + //vstTable.addAll( fsen.getInVarSet() ); + vstTable = vstTable.age( currentSESE ); } break; case FKind.FlatSESEExitNode: { FlatSESEExitNode fsexn = (FlatSESEExitNode) fn; - //FlatSESEEnterNode fsen = fsexn.getFlatEnter(); - //assert fsen == seseStack.pop(); - //seseStack.peek().addInVarSet ( fsen.getInVarSet() ); - //seseStack.peek().addOutVarSet( fsen.getOutVarSet() ); } break; - /* - case FKind.FlatMethod: { - FlatMethod fm = (FlatMethod) fn; - } break; - */ - - /* - case FKind.FlatOpNode: - case FKind.FlatCastNode: - case FKind.FlatFieldNode: - case FKind.FlatSetFieldNode: - case FKind.FlatElementNode: - case FKind.FlatSetElementNode: - */ - default: { - // handle effects of statement in reverse, writes then reads TempDescriptor [] writeTemps = fn.writesTemps(); for( int i = 0; i < writeTemps.length; ++i ) { @@ -286,46 +259,8 @@ public class MLPAnalysis { } } break; - /* - case FKind.FlatNew: { - FlatNew fnn = (FlatNew) fn; - lhs = fnn.getDst(); - if( !lhs.getType().isImmutable() || lhs.getType().isArray() ) { - //AllocationSite as = getAllocationSiteFromFlatNewPRIVATE( fnn ); - } - } break; - */ - - /* - case FKind.FlatCall: { - FlatCall fc = (FlatCall) fn; - MethodDescriptor md = fc.getMethod(); - FlatMethod flatm = state.getMethodFlat( md ); - - - if( md.isStatic() ) { - - } else { - // if the method descriptor is virtual, then there could be a - // set of possible methods that will actually be invoked, so - // find all of them and merge all of their results together - TypeDescriptor typeDesc = fc.getThis().getType(); - Set possibleCallees = callGraph.getMethods( md, typeDesc ); - - Iterator i = possibleCallees.iterator(); - while( i.hasNext() ) { - MethodDescriptor possibleMd = (MethodDescriptor) i.next(); - FlatMethod pflatm = state.getMethodFlat( possibleMd ); - - } - } - - } break; - */ - } // end switch - return vstTable; } } diff --git a/Robust/src/Analysis/MLP/VarSrcTokTable.java b/Robust/src/Analysis/MLP/VarSrcTokTable.java index 296c8ece..dac2cfc0 100644 --- a/Robust/src/Analysis/MLP/VarSrcTokTable.java +++ b/Robust/src/Analysis/MLP/VarSrcTokTable.java @@ -201,6 +201,33 @@ public class VarSrcTokTable { trueSet.remove( vst ); } + + // return a new table based on this one and + // age tokens with respect to SESE curr, where + // any child becomes curr with age 0, and any + // curr tokens increase age by 1 + public VarSrcTokTable age( FlatSESEEnterNode curr ) { + VarSrcTokTable out = new VarSrcTokTable(); + + Iterator itr = trueSet.iterator(); + while( itr.hasNext() ) { + VariableSourceToken vst = itr.next(); + if( vst.getSESE().equals( curr ) ) { + out.add( new VariableSourceToken( curr, + vst.getVar(), + vst.getAge()+1 ) ); + } else { + assert curr.getChildren().contains( vst.getSESE() ); + out.add( new VariableSourceToken( curr, + vst.getVar(), + new Integer( 0 ) ) ); + } + } + + return out; + } + + public boolean equals( Object o ) { if( o == null ) { return false; diff --git a/Robust/src/Analysis/MLP/VariableSourceToken.java b/Robust/src/Analysis/MLP/VariableSourceToken.java index 089ea914..251a31e9 100644 --- a/Robust/src/Analysis/MLP/VariableSourceToken.java +++ b/Robust/src/Analysis/MLP/VariableSourceToken.java @@ -54,6 +54,6 @@ public class VariableSourceToken { public String toString() { - return "["+sese+", "+var+", "+age+"]"; + return "["+sese.getPrettyIdentifier()+", "+var+", "+age+"]"; } } diff --git a/Robust/src/Tests/mlp/tinyTest/test.java b/Robust/src/Tests/mlp/tinyTest/test.java index 239734bb..dd09c80a 100644 --- a/Robust/src/Tests/mlp/tinyTest/test.java +++ b/Robust/src/Tests/mlp/tinyTest/test.java @@ -5,7 +5,7 @@ public class Test { // in the main method sese root { int n = 10; - + sese top { int x = 0; -- 2.34.1