From: jjenista Date: Fri, 25 Jun 2010 22:41:14 +0000 (+0000) Subject: getting effects analysis going, need a few more pieces before call site analysis... X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=eb4915a6e526272e2a3b5cb57130157e92377476;p=IRC.git getting effects analysis going, need a few more pieces before call site analysis will work --- diff --git a/Robust/src/Analysis/Disjoint/Canonical.java b/Robust/src/Analysis/Disjoint/Canonical.java index 4407e147..f11ac4a8 100644 --- a/Robust/src/Analysis/Disjoint/Canonical.java +++ b/Robust/src/Analysis/Disjoint/Canonical.java @@ -1445,7 +1445,7 @@ abstract public class Canonical { } - public static Taint makePredsTrue( Taint t ) { + public static Taint changePredsTo( Taint t, ExistPredSet preds ) { assert t != null; assert t.isCanonical(); @@ -1453,7 +1453,7 @@ abstract public class Canonical { // the empty reach state as the second, it's never used, // but makes the hashing happy CanonicalOp op = - new CanonicalOp( CanonicalOp.TAINT_MAKEPREDSTRUE, + new CanonicalOp( CanonicalOp.TAINT_CHANGEPREDSTO, t, t ); @@ -1467,7 +1467,7 @@ abstract public class Canonical { t.stallSite, t.var, t.allocSite, - ExistPredSet.factory( ExistPred.factory() ) + preds ); out = (Taint) makeCanonical( out ); @@ -1476,7 +1476,7 @@ abstract public class Canonical { } - public static TaintSet makePredsTrue( TaintSet ts ) { + public static TaintSet changePredsTo( TaintSet ts, ExistPredSet preds ) { assert ts != null; assert ts.isCanonical(); @@ -1484,9 +1484,9 @@ abstract public class Canonical { // the empty reach set as the second, it's never used, // but makes the hashing happy CanonicalOp op = - new CanonicalOp( CanonicalOp.TAINTSET_MAKEPREDSTRUE, + new CanonicalOp( CanonicalOp.TAINTSET_CHANGEPREDSTO, ts, - TaintSet.factory() ); + ts ); Canonical result = op2result.get( op ); if( result != null ) { @@ -1499,7 +1499,7 @@ abstract public class Canonical { while( itr.hasNext() ) { Taint t = itr.next(); out = Canonical.add( out, - Canonical.makePredsTrue( t ) + Canonical.changePredsTo( t, preds ) ); } diff --git a/Robust/src/Analysis/Disjoint/CanonicalOp.java b/Robust/src/Analysis/Disjoint/CanonicalOp.java index 81ad56d7..e280e33e 100644 --- a/Robust/src/Analysis/Disjoint/CanonicalOp.java +++ b/Robust/src/Analysis/Disjoint/CanonicalOp.java @@ -38,8 +38,8 @@ public class CanonicalOp { public static final int TAINTSET_ADD_TAINT = 0xcd17; public static final int TAINTSET_UNION_TAINTSET = 0xa835; public static final int TAINTSET_UNIONORPREDS_TAINTSET = 0x204f; - public static final int TAINT_MAKEPREDSTRUE = 0x3ab4; - public static final int TAINTSET_MAKEPREDSTRUE = 0x2ff1; + public static final int TAINT_CHANGEPREDSTO = 0x3ab4; + public static final int TAINTSET_CHANGEPREDSTO = 0x2ff1; protected int opCode; protected Canonical operand1; diff --git a/Robust/src/Analysis/Disjoint/DisjointAnalysis.java b/Robust/src/Analysis/Disjoint/DisjointAnalysis.java index 8cd77935..21c80a58 100644 --- a/Robust/src/Analysis/Disjoint/DisjointAnalysis.java +++ b/Robust/src/Analysis/Disjoint/DisjointAnalysis.java @@ -1089,7 +1089,7 @@ public class DisjointAnalysis { if( doEffectsAnalysis && fmContaining != fmAnalysisEntry ) { FlatSESEEnterNode seseContaining = rblockRel.getRBlockStacks( fmContaining, fn ).peek(); - + effectsAnalysis.analyzeFlatFieldNode( fmContaining, seseContaining, rg, rhs, fld ); @@ -1356,7 +1356,7 @@ public class DisjointAnalysis { ); if( doEffectsAnalysis && fmContaining != fmAnalysisEntry ) { - + FlatSESEEnterNode seseContaining = rblockRel.getRBlockStacks( fmContaining, fn ).peek(); diff --git a/Robust/src/Analysis/Disjoint/EffectsAnalysis.java b/Robust/src/Analysis/Disjoint/EffectsAnalysis.java index 70cf0fb1..cf9eaf38 100644 --- a/Robust/src/Analysis/Disjoint/EffectsAnalysis.java +++ b/Robust/src/Analysis/Disjoint/EffectsAnalysis.java @@ -40,7 +40,10 @@ public class EffectsAnalysis { ReachGraph rg, TempDescriptor rhs, FieldDescriptor fld) { VariableNode vn = rg.td2vn.get(rhs); - + if( vn == null ) { + return; + } + for (Iterator iterator = vn.iteratorToReferencees(); iterator.hasNext();) { RefEdge edge = iterator.next(); TaintSet taintSet = edge.getTaints(); @@ -66,6 +69,9 @@ public class EffectsAnalysis { ReachGraph rg, TempDescriptor lhs, FieldDescriptor fld, boolean strongUpdate) { VariableNode vn = rg.td2vn.get(lhs); + if( vn == null ) { + return; + } for (Iterator iterator = vn.iteratorToReferencees(); iterator.hasNext();) { RefEdge edge = iterator.next(); @@ -89,12 +95,7 @@ public class EffectsAnalysis { public void analyzeFlatCall(FlatMethod fmContaining, FlatSESEEnterNode seseContaining, FlatMethod fmCallee, Hashtable tCallee2tsCaller) { - - EffectSet esCaller = getEffectSet(fmContaining); - if( esCaller == null ) { - esCaller = new EffectSet(); - } - + EffectSet esCallee = getEffectSet(fmCallee); if( esCallee == null ) { esCallee = new EffectSet(); @@ -111,6 +112,8 @@ public class EffectsAnalysis { Iterator tItr = tCallee2tsCaller.get( tCallee ).iterator(); while( tItr.hasNext() ) { Taint tCaller = tItr.next(); + + EffectSet esCaller = new EffectSet(); Iterator eItr = effects.iterator(); while( eItr.hasNext() ) { @@ -120,7 +123,7 @@ public class EffectsAnalysis { } add( fmContaining, tCaller, esCaller ); - add( seseContaining, tCaller, esCaller ); + add( seseContaining, tCaller, esCaller ); } } } diff --git a/Robust/src/Analysis/Disjoint/ExistPred.java b/Robust/src/Analysis/Disjoint/ExistPred.java index 8db8adfc..604c0fb0 100644 --- a/Robust/src/Analysis/Disjoint/ExistPred.java +++ b/Robust/src/Analysis/Disjoint/ExistPred.java @@ -73,7 +73,7 @@ public class ExistPred extends Canonical { protected TypeDescriptor e_type; protected String e_field; - // edge uses same ReachState ne_state as node type above + diff --git a/Robust/src/Analysis/Disjoint/ReachGraph.java b/Robust/src/Analysis/Disjoint/ReachGraph.java index 702071cf..adf3a410 100644 --- a/Robust/src/Analysis/Disjoint/ReachGraph.java +++ b/Robust/src/Analysis/Disjoint/ReachGraph.java @@ -659,7 +659,8 @@ public class ReachGraph { ) ), predsTrue, - Canonical.makePredsTrue( edgeY.getTaints() ) + Canonical.changePredsTo( edgeY.getTaints(), + predsTrue ) ); addEdgeOrMergeWithExisting( edgeNew ); @@ -705,7 +706,10 @@ public class ReachGraph { HeapRegionNode referencee = edgeX.getDst(); RefEdge edgeNew = edgeX.copy(); edgeNew.setSrc( lnR ); - edgeNew.setTaints( Canonical.makePredsTrue( edgeNew.getTaints() ) ); + edgeNew.setTaints( Canonical.changePredsTo( edgeNew.getTaints(), + predsTrue + ) + ); addRefEdge( lnR, referencee, edgeNew ); } @@ -1299,8 +1303,8 @@ public class ReachGraph { Iterator isvItr = sese.getInVarSet().iterator(); while( isvItr.hasNext() ) { TempDescriptor isv = isvItr.next(); - VariableNode vn = td2vn.get( isv ); - + VariableNode vn = getVariableNodeFromTemp( isv ); + Iterator reItr = vn.iteratorToReferencees(); while( reItr.hasNext() ) { RefEdge re = reItr.next(); @@ -1329,7 +1333,7 @@ public class ReachGraph { ExistPredSet preds ) { - VariableNode vn = td2vn.get( td ); + VariableNode vn = getVariableNodeFromTemp( td ); Iterator reItr = vn.iteratorToReferencees(); while( reItr.hasNext() ) { @@ -2057,7 +2061,8 @@ public class ReachGraph { oocHrnIdOoc2callee ), preds, - TaintSet.factory() // no taints + Canonical.changePredsTo( reCaller.getTaints(), + preds ) ) ); @@ -2434,7 +2439,7 @@ public class ReachGraph { calleeEdge2calleeTaintsSatisfied.put( reCallee, calleeTaintsSatisfied ); } - calleeTaintsSatisfied.put( tCallee, predsIfSatis ); + calleeTaintsSatisfied.put( tCallee, predsIfSatis ); } } } diff --git a/Robust/src/Tests/disjoint/taintTest1/makefile b/Robust/src/Tests/disjoint/taintTest1/makefile index b000dbb2..ab015921 100644 --- a/Robust/src/Tests/disjoint/taintTest1/makefile +++ b/Robust/src/Tests/disjoint/taintTest1/makefile @@ -5,7 +5,7 @@ SOURCE_FILES=$(PROGRAM).java BUILDSCRIPT=~/research/Robust/src/buildscript BSFLAGS= -mainclass Test -justanalyze -ooojava -disjoint -disjoint-k 1 -enable-assertions -#DEBUGFLAGS= -disjoint-write-dots final -disjoint-write-initial-contexts -disjoint-write-ihms -disjoint-debug-snap-method main 0 10 true +DEBUGFLAGS= -disjoint-write-dots final -disjoint-write-initial-contexts -disjoint-write-ihms # -disjoint-debug-snap-method main 0 10 true all: $(PROGRAM).bin diff --git a/Robust/src/Tests/disjoint/taintTest1/test.java b/Robust/src/Tests/disjoint/taintTest1/test.java index f0f9b02a..f573d419 100644 --- a/Robust/src/Tests/disjoint/taintTest1/test.java +++ b/Robust/src/Tests/disjoint/taintTest1/test.java @@ -18,25 +18,24 @@ public class Test { */ rblock r1 { - a.f = new Foo(); - b.f = new Foo(); - doSomething( a, b ); } } static void doSomething( Foo a, Foo b ) { + + Foo x = b; + a.g = x; - a.g = new Foo(); - - a.f.f = a.g; + a.f = new Foo(); + b.f = new Foo(); - Foo f = doStuff( a, b ); + Foo f = doStuff( a.f, b.f ); } static Foo doStuff( Foo m, Foo n ) { - m.f.g = n.f; + m.g = n; return new Foo(); }