From: jjenista Date: Fri, 25 Jun 2010 18:59:20 +0000 (+0000) Subject: rblock effects dont collect over method call, but its close X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=661c257edbd0ba1c3ee129000b59349dbb1d1f3d;p=IRC.git rblock effects dont collect over method call, but its close --- diff --git a/Robust/src/Analysis/Disjoint/DisjointAnalysis.java b/Robust/src/Analysis/Disjoint/DisjointAnalysis.java index e4dbabfc..8cd77935 100644 --- a/Robust/src/Analysis/Disjoint/DisjointAnalysis.java +++ b/Robust/src/Analysis/Disjoint/DisjointAnalysis.java @@ -674,7 +674,7 @@ public class DisjointAnalysis { } if( doEffectsAnalysis ) { - effectsAnalysis.writeEffectsPerMethod( "effects-per-method.txt" ); + effectsAnalysis.writeEffectsPerMethodAndRBlock( "effects.txt" ); } } @@ -1013,7 +1013,7 @@ public class DisjointAnalysis { //rg.nullifyDeadVars( liveness.getLiveInTemps( fmContaining, fn ) ); /* - if( doEffectsAnalysis && + if( doEffectsAnalysis && && fmContaining != fmAnalysisEntry rra.isEndOfRegion(fn)){ rg.clearAccessibleVarSet(); also need to clear stall mapping @@ -1064,24 +1064,6 @@ public class DisjointAnalysis { lhs = fon.getDest(); rhs = fon.getLeft(); rg.assignTempXEqualToTempY( lhs, rhs ); - - /* - if( doEffectsAnalysis ) { - // current sese is top of stack at this program point - FlatSESEEnterNode sese = - rblockRel.getRBlockStacks( fmContaining, fn ).peek(); - - // if we are assigning to an out-set var, the taint - // on the out-set var edges should be TRUE (and propagate - // back to callers - - rg.taintTemp( sese, - null, - lhs, - ReachGraph.predsTrue - ); - } - */ } break; @@ -1104,8 +1086,13 @@ public class DisjointAnalysis { if( shouldAnalysisTrack( fld.getType() ) ) { rg.assignTempXEqualToTempYFieldF( lhs, rhs, fld ); - if( doEffectsAnalysis ) { - effectsAnalysis.analyzeFlatFieldNode( fmContaining, rg, rhs, fld ); + if( doEffectsAnalysis && fmContaining != fmAnalysisEntry ) { + FlatSESEEnterNode seseContaining = + rblockRel.getRBlockStacks( fmContaining, fn ).peek(); + + effectsAnalysis.analyzeFlatFieldNode( fmContaining, + seseContaining, + rg, rhs, fld ); } } break; @@ -1119,8 +1106,13 @@ public class DisjointAnalysis { if( shouldAnalysisTrack( fld.getType() ) ) { boolean strongUpdate = rg.assignTempXFieldFEqualToTempY( lhs, fld, rhs ); - if( doEffectsAnalysis ) { - effectsAnalysis.analyzeFlatSetFieldNode( fmContaining, rg, lhs, fld, strongUpdate ); + if( doEffectsAnalysis && fmContaining != fmAnalysisEntry ) { + FlatSESEEnterNode seseContaining = + rblockRel.getRBlockStacks( fmContaining, fn ).peek(); + + effectsAnalysis.analyzeFlatSetFieldNode( fmContaining, + seseContaining, + rg, lhs, fld, strongUpdate ); } } break; @@ -1138,6 +1130,15 @@ public class DisjointAnalysis { FieldDescriptor fdElement = getArrayField( tdElement ); rg.assignTempXEqualToTempYFieldF( lhs, rhs, fdElement ); + + if( doEffectsAnalysis && fmContaining != fmAnalysisEntry ) { + FlatSESEEnterNode seseContaining = + rblockRel.getRBlockStacks( fmContaining, fn ).peek(); + + effectsAnalysis.analyzeFlatFieldNode( fmContaining, + seseContaining, + rg, rhs, fdElement ); + } } break; @@ -1160,6 +1161,16 @@ public class DisjointAnalysis { FieldDescriptor fdElement = getArrayField( tdElement ); rg.assignTempXFieldFEqualToTempY( lhs, fdElement, rhs ); + + if( doEffectsAnalysis && fmContaining != fmAnalysisEntry ) { + FlatSESEEnterNode seseContaining = + rblockRel.getRBlockStacks( fmContaining, fn ).peek(); + + effectsAnalysis.analyzeFlatSetFieldNode( fmContaining, + seseContaining, + rg, lhs, fdElement, + false ); + } } break; @@ -1173,14 +1184,14 @@ public class DisjointAnalysis { break; case FKind.FlatSESEEnterNode: - if( doEffectsAnalysis ) { + if( doEffectsAnalysis && fmContaining != fmAnalysisEntry ) { FlatSESEEnterNode sese = (FlatSESEEnterNode) fn; rg.taintInSetVars( sese ); } break; case FKind.FlatSESEExitNode: - if( doEffectsAnalysis ) { + if( doEffectsAnalysis && fmContaining != fmAnalysisEntry ) { FlatSESEExitNode fsexn = (FlatSESEExitNode) fn; rg.removeInContextTaints( fsexn.getFlatEnter() ); } @@ -1332,7 +1343,7 @@ public class DisjointAnalysis { Hashtable tCallee2tsCaller = null; - if( doEffectsAnalysis ) { + if( doEffectsAnalysis && fmContaining != fmAnalysisEntry ) { tCallee2tsCaller = new Hashtable(); } @@ -1344,8 +1355,13 @@ public class DisjointAnalysis { writeDebugDOTs ); - if( doEffectsAnalysis ) { + if( doEffectsAnalysis && fmContaining != fmAnalysisEntry ) { + + FlatSESEEnterNode seseContaining = + rblockRel.getRBlockStacks( fmContaining, fn ).peek(); + effectsAnalysis.analyzeFlatCall( fmContaining, + seseContaining, fmPossible, tCallee2tsCaller ); } diff --git a/Robust/src/Analysis/Disjoint/EffectsAnalysis.java b/Robust/src/Analysis/Disjoint/EffectsAnalysis.java index 0e81f1b8..70cf0fb1 100644 --- a/Robust/src/Analysis/Disjoint/EffectsAnalysis.java +++ b/Robust/src/Analysis/Disjoint/EffectsAnalysis.java @@ -27,16 +27,20 @@ import IR.Flat.FlatSESEEnterNode; public class EffectsAnalysis { - private Hashtable fm2effectSet; + private Hashtable fm2effectSet; + private Hashtable sese2effectSet; public EffectsAnalysis() { - fm2effectSet = new Hashtable(); + fm2effectSet = new Hashtable(); + sese2effectSet = new Hashtable(); } - public void analyzeFlatFieldNode(FlatMethod fmContaining, ReachGraph rg, TempDescriptor rhs, FieldDescriptor fld) { + public void analyzeFlatFieldNode(FlatMethod fmContaining, + FlatSESEEnterNode seseContaining, + ReachGraph rg, TempDescriptor rhs, FieldDescriptor fld) { VariableNode vn = rg.td2vn.get(rhs); - + for (Iterator iterator = vn.iteratorToReferencees(); iterator.hasNext();) { RefEdge edge = iterator.next(); TaintSet taintSet = edge.getTaints(); @@ -50,14 +54,16 @@ public class EffectsAnalysis { } Effect effect = new Effect(affectedAlloc, Effect.read, fld); - effectSet.addEffect(taint, effect); - fm2effectSet.put(fmContaining, effectSet); + add( fmContaining, taint, effect ); + add( seseContaining, taint, effect ); } } } - public void analyzeFlatSetFieldNode(FlatMethod fmContaining, ReachGraph rg, TempDescriptor lhs, FieldDescriptor fld, boolean strongUpdate) { + public void analyzeFlatSetFieldNode(FlatMethod fmContaining, + FlatSESEEnterNode seseContaining, + ReachGraph rg, TempDescriptor lhs, FieldDescriptor fld, boolean strongUpdate) { VariableNode vn = rg.td2vn.get(lhs); @@ -67,29 +73,22 @@ public class EffectsAnalysis { AllocSite affectedAlloc = edge.getDst().getAllocSite(); for (Iterator taintSetIter = taintSet.iterator(); taintSetIter.hasNext();) { Taint taint = taintSetIter.next(); - - EffectSet effectSet = fm2effectSet.get(fmContaining); - if (effectSet == null) { - effectSet = new EffectSet(); - } - Effect effect = new Effect(affectedAlloc, Effect.write, fld); - effectSet.addEffect(taint, effect); - + Effect effect = new Effect(affectedAlloc, Effect.write, fld); + add( fmContaining, taint, effect ); + add( seseContaining, taint, effect ); + if (strongUpdate) { - effectSet.addEffect(taint, - new Effect(affectedAlloc, - Effect.strongupdate, - fld) - ); + Effect effectSU = new Effect(affectedAlloc, Effect.strongupdate, fld); + add( fmContaining, taint, effect ); + add( seseContaining, taint, effect ); } - - fm2effectSet.put(fmContaining, effectSet); } } } - public void analyzeFlatCall(FlatMethod fmContaining, FlatMethod fmCallee, Hashtable tCallee2tsCaller) { + public void analyzeFlatCall(FlatMethod fmContaining, FlatSESEEnterNode seseContaining, + FlatMethod fmCallee, Hashtable tCallee2tsCaller) { EffectSet esCaller = getEffectSet(fmContaining); if( esCaller == null ) { @@ -119,22 +118,23 @@ public class EffectsAnalysis { esCaller.addEffect( tCaller, e ); } + + add( fmContaining, tCaller, esCaller ); + add( seseContaining, tCaller, esCaller ); } } } - - fm2effectSet.put(fmContaining, esCaller); } public EffectSet getEffectSet(FlatMethod fm) { return fm2effectSet.get(fm); } - public void writeEffectsPerMethod( String outfile ) { + public void writeEffectsPerMethodAndRBlock( String outfile ) { try { BufferedWriter bw = new BufferedWriter(new FileWriter(outfile)); - bw.write( "Effects\n\n" ); + bw.write( "Effects Per Method\n\n" ); Iterator meItr1 = fm2effectSet.entrySet().iterator(); while( meItr1.hasNext() ) { @@ -159,10 +159,114 @@ public class EffectsAnalysis { } } + + bw.write( "\n\nEffects Per RBlock\n\n" ); + + meItr1 = sese2effectSet.entrySet().iterator(); + while( meItr1.hasNext() ) { + Map.Entry me1 = (Map.Entry) meItr1.next(); + FlatSESEEnterNode sese = (FlatSESEEnterNode) me1.getKey(); + EffectSet es = (EffectSet) me1.getValue(); + + bw.write( "\n"+sese.toPrettyString()+"\n--------------\n" ); + + Iterator meItr2 = es.getAllEffectPairs(); + while( meItr2.hasNext() ) { + Map.Entry me2 = (Map.Entry) meItr2.next(); + Taint taint = (Taint) me2.getKey(); + HashSet effects = (HashSet) me2.getValue(); + + Iterator eItr = effects.iterator(); + while( eItr.hasNext() ) { + Effect e = eItr.next(); + + bw.write( " "+taint+"-->"+e+"\n" ); + } + } + } + bw.close(); } catch( IOException e ) {} } + protected void add( FlatMethod fm, Taint t, Effect e ) { + EffectSet es = fm2effectSet.get( fm ); + if( es == null ) { + es = new EffectSet(); + } + es.addEffect( t, e ); + + fm2effectSet.put( fm, es ); + } + + protected void add( FlatSESEEnterNode sese, Taint t, Effect e ) { + + if( sese.getIsCallerSESEplaceholder() ) { + return; + } + + EffectSet es = sese2effectSet.get( sese ); + if( es == null ) { + es = new EffectSet(); + } + es.addEffect( t, e ); + + sese2effectSet.put( sese, es ); + } + + protected void add( FlatMethod fm, Taint t, EffectSet es ) { + EffectSet esExisting = fm2effectSet.get( fm ); + if( esExisting == null ) { + esExisting = new EffectSet(); + } + + Iterator meItr = es.getAllEffectPairs(); + while( meItr.hasNext() ) { + Map.Entry me = (Map.Entry) meItr.next(); + Taint taint = (Taint) me.getKey(); + HashSet effects = (HashSet) me.getValue(); + + Iterator eItr = effects.iterator(); + while( eItr.hasNext() ) { + Effect e = eItr.next(); + + esExisting.addEffect( taint, e ); + } + } + + fm2effectSet.put( fm, esExisting ); + } + + protected void add( FlatSESEEnterNode sese, Taint t, EffectSet es ) { + + if( sese.getIsCallerSESEplaceholder() ) { + return; + } + + EffectSet esExisting = sese2effectSet.get( sese ); + + if( esExisting == null ) { + esExisting = new EffectSet(); + } + + Iterator meItr = es.getAllEffectPairs(); + while( meItr.hasNext() ) { + Map.Entry me = (Map.Entry) meItr.next(); + Taint taint = (Taint) me.getKey(); + HashSet effects = (HashSet) me.getValue(); + + Iterator eItr = effects.iterator(); + while( eItr.hasNext() ) { + Effect e = eItr.next(); + + esExisting.addEffect( taint, e ); + } + } + + sese2effectSet.put( sese, esExisting ); + } + + /* * public MethodEffects getMethodEffectsByMethodContext(MethodContext mc){ * return mapMethodContextToMethodEffects.get(mc); } diff --git a/Robust/src/Analysis/Disjoint/ReachGraph.java b/Robust/src/Analysis/Disjoint/ReachGraph.java index dbb1d4ed..702071cf 100644 --- a/Robust/src/Analysis/Disjoint/ReachGraph.java +++ b/Robust/src/Analysis/Disjoint/ReachGraph.java @@ -1292,8 +1292,11 @@ public class ReachGraph { public void taintInSetVars( FlatSESEEnterNode sese ) { - Iterator isvItr = sese.getInVarSet().iterator() -; + if( sese.getIsCallerSESEplaceholder() ) { + return; + } + + Iterator isvItr = sese.getInVarSet().iterator(); while( isvItr.hasNext() ) { TempDescriptor isv = isvItr.next(); VariableNode vn = td2vn.get( isv ); @@ -1340,6 +1343,10 @@ public class ReachGraph { } public void removeInContextTaints( FlatSESEEnterNode sese ) { + if( sese.getIsCallerSESEplaceholder() ) { + return; + } + Iterator meItr = id2hrn.entrySet().iterator(); while( meItr.hasNext() ) { Map.Entry me = (Map.Entry) meItr.next();