Starting implementation for definite reachability analysis
authorjjenista <jjenista>
Wed, 21 Sep 2011 23:32:41 +0000 (23:32 +0000)
committerjjenista <jjenista>
Wed, 21 Sep 2011 23:32:41 +0000 (23:32 +0000)
Robust/src/Analysis/Disjoint/DefiniteReachAnalysis.java [new file with mode: 0644]
Robust/src/Analysis/Disjoint/DisjointAnalysis.java
Robust/src/Analysis/Disjoint/EdgeKey.java [new file with mode: 0644]
Robust/src/IR/State.java
Robust/src/Main/Main.java
Robust/src/Tests/disjoint/definite/makefile [new file with mode: 0644]
Robust/src/Tests/disjoint/definite/test.java [new file with mode: 0644]

diff --git a/Robust/src/Analysis/Disjoint/DefiniteReachAnalysis.java b/Robust/src/Analysis/Disjoint/DefiniteReachAnalysis.java
new file mode 100644 (file)
index 0000000..6987a3b
--- /dev/null
@@ -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<TempDescriptor> parameters) {
+    // R' := {}
+    // R.clear();
+
+    // Rs' := P x {unknown}
+  }
+
+  public void copy(TempDescriptor x,
+                   TempDescriptor y) {
+    // R' := (R - <x,*> - <*,x>)        U
+    //       {<x,z>->e | <y,z>->e in R} U
+    //       {<z,x>->e | <z,y>->e in R}
+    // R' = new Map(R)
+    // R'.remove(view0, x);
+    // R'.remove(view1, x);
+    // setYs = R.get(view0, y);
+    // for each <y,z>->e: R'.put(<x,z>, e);
+    // setYs = R.get(view1, y);
+    // for each <z,y>->e: R'.put(<z,x>, e);
+
+    // Rs' := (Rs - <x,*>) U {<x,v> | <y,v> in Rs}
+  }
+
+  public void load(TempDescriptor x,
+                   TempDescriptor y,
+                   FieldDescriptor f) {
+    // R' := (R - <x,*> - <*,x>) U
+    //       ({<x,y>} x Eo(y,f)) U
+    //       U        {<x,z>} x (Eo(y,f)U{e})
+    //   <y,z>->e in R
+    // R' = new Map(R)
+    // R'.remove(view0, x);
+    // R'.remove(view1, x);
+    // R'.put(<x,y>, eee!);
+    // setYs = R.get(view0, y);
+    // for each <y,z>->e: R'.put(<x,z>, eee!Ue);
+
+    // Rs' := (Rs - <x,*>) U {<x, unknown>}
+  }
+
+  public void store(TempDescriptor x,
+                   FieldDescriptor f,
+                   TempDescriptor y) {
+    // I think this should be if there is ANY <w,z>->e' IN Eremove, then kill all <w,z>
+    // R' := (R - {<w,z>->e | <w,z>->e in R, A<w,z>->e' in R, e' notin Eremove}) U
+    //       {<y,x>->e | e in E(x) x {f} x E(y)}
+    // R' = new Map(R)
+    // R'.remove(?); some e's...
+    // R'.put(<y,x>, E(x) x {f} x E(y));
+
+    // Rs' := Rs
+  }
+
+  public void newObject(TempDescriptor x) {
+    // R' := (R - <x,*> - <*,x>)
+    // R' = new Map(R)
+    // R'.remove(view0, x);
+    // R'.remove(view1, x);
+
+    // Rs' := (Rs - <x,*>) U {<x, new>}
+  }
+
+  public void methodCall(TempDescriptor x) {
+    // R' := (R - <x,*> - <*,x>)
+    // R' = new Map(R)
+    // R'.remove(view0, x);
+    // R'.remove(view1, x);
+
+    // Rs' := (Rs - <x,*>) U {<x, unknown>}
+  }
+
+  public void merge() {
+    // R' := <x,y>->e iff its in all incoming edges
+
+    // Rs' := <x, new> iff in all incoming edges, otherwie <x, unknown>
+  }
+}
index 6e002bbd7ac36a5f9a69e7066d6de0b5555427bf..5dd67e5b86ee1ca946f663b3c7bc0326302f38a8 100644 (file)
@@ -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<AllocSite> >
@@ -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 (file)
index 0000000..64617e9
--- /dev/null
@@ -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();
+  }
+}
index e5799435657ce856fe10bf9a89b13925cc640b05..9538ea455c696cd51113121c86d0b74c60953b0a 100644 (file)
@@ -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;
index e4343618c964e458cf9ffc9c8350d31385295370..61e898bc814160363e09799ae9fa2247d6bd4d8a 100644 (file)
@@ -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 (file)
index 0000000..7cebad3
--- /dev/null
@@ -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 (file)
index 0000000..57b4919
--- /dev/null
@@ -0,0 +1,8 @@
+
+public class Test {
+
+  static public void main( String args[] ) {
+    int x = 1;
+    System.out.println( "Hi!"+x );
+  }
+}