From: jjenista Date: Wed, 21 Sep 2011 23:32:41 +0000 (+0000) Subject: Starting implementation for definite reachability analysis X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=ebd4254a09e78c8c2a6c365330f9d7681bcd8a79;p=IRC.git Starting implementation for definite reachability analysis --- diff --git a/Robust/src/Analysis/Disjoint/DefiniteReachAnalysis.java b/Robust/src/Analysis/Disjoint/DefiniteReachAnalysis.java new file mode 100644 index 00000000..6987a3bd --- /dev/null +++ b/Robust/src/Analysis/Disjoint/DefiniteReachAnalysis.java @@ -0,0 +1,108 @@ +package Analysis.Disjoint; + +import java.util.*; + +import IR.*; +import IR.Flat.*; +import Util.*; + + +public class DefiniteReachAnalysis { + + // R + // + // Maps variables and an edge (x, y, e) to an unused value when the + // object of x is already reachable from the object of y, and the + // set of edges conservatively gives the path. + // NOTE: Use EdgeKey instead of edges because this analysis's + // scope is beyond the scope of a single reach graph. + + // Fs + // Just a hashmap of variable to enum (unknown, new). + + // Fu + + // Fd + + public DefiniteReachAnalysis() { + } + + // what are the transfer functions that are relevant for this analyis? + + public void methodEntry(Set parameters) { + // R' := {} + // R.clear(); + + // Rs' := P x {unknown} + } + + public void copy(TempDescriptor x, + TempDescriptor y) { + // R' := (R - - <*,x>) U + // {->e | ->e in R} U + // {->e | ->e in R} + // R' = new Map(R) + // R'.remove(view0, x); + // R'.remove(view1, x); + // setYs = R.get(view0, y); + // for each ->e: R'.put(, e); + // setYs = R.get(view1, y); + // for each ->e: R'.put(, e); + + // Rs' := (Rs - ) U { | in Rs} + } + + public void load(TempDescriptor x, + TempDescriptor y, + FieldDescriptor f) { + // R' := (R - - <*,x>) U + // ({} x Eo(y,f)) U + // U {} x (Eo(y,f)U{e}) + // ->e in R + // R' = new Map(R) + // R'.remove(view0, x); + // R'.remove(view1, x); + // R'.put(, eee!); + // setYs = R.get(view0, y); + // for each ->e: R'.put(, eee!Ue); + + // Rs' := (Rs - ) U {} + } + + public void store(TempDescriptor x, + FieldDescriptor f, + TempDescriptor y) { + // I think this should be if there is ANY ->e' IN Eremove, then kill all + // R' := (R - {->e | ->e in R, A->e' in R, e' notin Eremove}) U + // {->e | e in E(x) x {f} x E(y)} + // R' = new Map(R) + // R'.remove(?); some e's... + // R'.put(, E(x) x {f} x E(y)); + + // Rs' := Rs + } + + public void newObject(TempDescriptor x) { + // R' := (R - - <*,x>) + // R' = new Map(R) + // R'.remove(view0, x); + // R'.remove(view1, x); + + // Rs' := (Rs - ) U {} + } + + public void methodCall(TempDescriptor x) { + // R' := (R - - <*,x>) + // R' = new Map(R) + // R'.remove(view0, x); + // R'.remove(view1, x); + + // Rs' := (Rs - ) U {} + } + + public void merge() { + // R' := ->e iff its in all incoming edges + + // Rs' := iff in all incoming edges, otherwie + } +} diff --git a/Robust/src/Analysis/Disjoint/DisjointAnalysis.java b/Robust/src/Analysis/Disjoint/DisjointAnalysis.java index 6e002bbd..5dd67e5b 100644 --- a/Robust/src/Analysis/Disjoint/DisjointAnalysis.java +++ b/Robust/src/Analysis/Disjoint/DisjointAnalysis.java @@ -412,6 +412,9 @@ public class DisjointAnalysis implements HeapAnalysis { protected EffectsAnalysis effectsAnalysis; protected BuildStateMachines buildStateMachines; + protected boolean doDefiniteReachAnalysis = false; + protected DefiniteReachAnalysis definiteReachAnalysis; + // data structure for public interface private Hashtable< Descriptor, HashSet > @@ -846,6 +849,10 @@ public class DisjointAnalysis implements HeapAnalysis { ReachGraph.debugCallSiteVisitCounter = 0; // count visits from 1, is incremented before first visit + if( state.DO_DEFINITE_REACH_ANALYSIS ) { + doDefiniteReachAnalysis = true; + definiteReachAnalysis = new DefiniteReachAnalysis(); + } if( suppressOutput ) { diff --git a/Robust/src/Analysis/Disjoint/EdgeKey.java b/Robust/src/Analysis/Disjoint/EdgeKey.java new file mode 100644 index 00000000..64617e90 --- /dev/null +++ b/Robust/src/Analysis/Disjoint/EdgeKey.java @@ -0,0 +1,46 @@ +public class EdgeKey { + private Integer srcId; + private Integer dstId; + private FieldDescriptor f; + + public EdgeKey(Integer srcId, Integer dstId, FieldDescriptor f) { + this.srcId = srcId; + this.dstId = dstId; + this.f = f; + } + + public Integer getSrcId() { + return srcId; + } + + public Integer getDstId() { + return dstId; + } + + public FieldDescriptor getField() { + return f; + } + + public boolean equals(Object o) { + if(this == o) { + return true; + } + if(o == null) { + return false; + } + if(!(o instanceof EdgeKey)) { + return false; + } + + EdgeKey ek = (EdgeKey) o; + + return + this.srcId.equals(ek.srcId) && + this.dstId.equals(ek.dstId) && + this.f.equals(ek.f); + } + + public int hashCode() { + return srcId.hashCode() ^ dstId.hashCode() ^ f.hashCode(); + } +} diff --git a/Robust/src/IR/State.java b/Robust/src/IR/State.java index e5799435..9538ea45 100644 --- a/Robust/src/IR/State.java +++ b/Robust/src/IR/State.java @@ -130,6 +130,8 @@ public class State { public boolean POINTSTO_CHECK_V_RUNTIME=false; + public boolean DO_DEFINITE_REACH_ANALYSIS=false; + public boolean OOOJAVA=false; public boolean OOODEBUG=false; diff --git a/Robust/src/Main/Main.java b/Robust/src/Main/Main.java index e4343618..61e898bc 100644 --- a/Robust/src/Main/Main.java +++ b/Robust/src/Main/Main.java @@ -291,6 +291,10 @@ public class Main { state.POINTSTO_CHECK_V_RUNTIME = true; + } else if( option.equals("-do-definite-reach-analysis") ) { + state.DO_DEFINITE_REACH_ANALYSIS = true; + + } else if (option.equals("-optional")) state.OPTIONAL=true; else if (option.equals("-optimize")) diff --git a/Robust/src/Tests/disjoint/definite/makefile b/Robust/src/Tests/disjoint/definite/makefile new file mode 100644 index 00000000..7cebad31 --- /dev/null +++ b/Robust/src/Tests/disjoint/definite/makefile @@ -0,0 +1,25 @@ +PROGRAM=Test + +SOURCE_FILES=test.java + +BUILDSCRIPT=../../../buildscript + +DISJOINT= -disjoint -disjoint-k 1 -enable-assertions -do-definite-reach-analysis + +BSFLAGS= -justanalyze -mainclass $(PROGRAM) -heapsize-mb 1024 -noloop -joptimize -debug + + +all: + $(BUILDSCRIPT) -thread $(BSFLAGS) $(DISJOINT) -o $(PROGRAM)s -builddir sing $(SOURCE_FILES) + +clean: + rm -f $(PROGRAM)s.bin + rm -fr sing + rm -f *~ + rm -f *.dot + rm -f *.png + rm -f *.txt + rm -f aliases.txt + rm -f mlpReport*txt + rm -f results*txt + rm -f coreprof.dat diff --git a/Robust/src/Tests/disjoint/definite/test.java b/Robust/src/Tests/disjoint/definite/test.java new file mode 100644 index 00000000..57b49195 --- /dev/null +++ b/Robust/src/Tests/disjoint/definite/test.java @@ -0,0 +1,8 @@ + +public class Test { + + static public void main( String args[] ) { + int x = 1; + System.out.println( "Hi!"+x ); + } +}