implementing def reach transfer funcs for R
authorjjenista <jjenista>
Tue, 25 Oct 2011 17:42:33 +0000 (17:42 +0000)
committerjjenista <jjenista>
Tue, 25 Oct 2011 17:42:33 +0000 (17:42 +0000)
Robust/src/Analysis/Disjoint/DefiniteReachAnalysis.java
Robust/src/Analysis/Disjoint/DefiniteReachState.java
Robust/src/Analysis/Disjoint/DisjointAnalysis.java
Robust/src/Analysis/Disjoint/ReachGraph.java
Robust/src/Util/MultiViewMap.java

index f22da374f78d6c9a4b298679567bbd10ccd76cd6..0ebfbdd2a8340f2d82c397a08d32336bf9414231 100644 (file)
@@ -40,9 +40,10 @@ public class DefiniteReachAnalysis {
   public void load( FlatNode fn, 
                     TempDescriptor  x,
                     TempDescriptor  y,
-                    FieldDescriptor f ) {
+                    FieldDescriptor f,
+                    Set<EdgeKey> edgeKeysForLoad ) {
     DefiniteReachState state = makeIn( fn );
-    state.load( x, y, f );
+    state.load( x, y, f, edgeKeysForLoad );
     fn2state.put( fn, state ); 
   }
 
index 699ea9aecd8cb472cca30a6b4627d66924df6eb3..710a6954bbd2c4abce0bb3ea06b32bc1796d011e 100644 (file)
@@ -133,8 +133,9 @@ public class DefiniteReachState {
 
   public void load( TempDescriptor x,
                     TempDescriptor y,
-                    FieldDescriptor f ) {
-    loadR( x, y, f );
+                    FieldDescriptor f,
+                    Set<EdgeKey> edgeKeysForLoad ) {
+    loadR( x, y, f, edgeKeysForLoad );
     // Rs' := (Rs - <x,*>) U {<x, unknown>}
     //Rs.put( x, DefReachKnown.UNKNOWN );
   }
@@ -180,31 +181,66 @@ public class DefiniteReachState {
 
   public void copyR( 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);
+    // consider that x and y can be the same, so do the
+    // parts of the update in the right order:
+
+    // first get all info for update
+    MultiKey keyY = MultiKey.factory( y );
+    Map<MultiKey, Object> mapY0 = R.get( viewR0, keyY );
+    Map<MultiKey, Object> mapY1 = R.get( viewR1, keyY );
+
+    // then remove anything
+    MultiKey keyX = MultiKey.factory( x );
+    R.remove( viewR0, keyX );
+    R.remove( viewR1, keyX );
+
+    // then insert new stuff
+    for( MultiKey fullKeyY : mapY0.keySet() ) {
+      MultiKey fullKeyX = MultiKey.factory( x, 
+                                            fullKeyY.get( 1 ), 
+                                            fullKeyY.get( 2 ) );
+      R.put( fullKeyX, MultiViewMap.dummyValue );
+    }
+    for( MultiKey fullKeyY : mapY1.keySet() ) {
+      MultiKey fullKeyX = MultiKey.factory( fullKeyY.get( 0 ), 
+                                            x,
+                                            fullKeyY.get( 2 ) );
+      R.put( fullKeyX, MultiViewMap.dummyValue );
+    }
   }
   
   public void loadR( 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);
+                     FieldDescriptor f,
+                     Set<EdgeKey> edgeKeysForLoad ) {
+    // consider that x and y can be the same, so do the
+    // parts of the update in the right order:
+
+    // first get all info for update
+    MultiKey keyY = MultiKey.factory( y );
+    Map<MultiKey, Object> mapY0 = R.get( viewR0, keyY );
+
+    // then remove anything
+    MultiKey keyX = MultiKey.factory( x );
+    R.remove( viewR0, keyX );
+    R.remove( viewR1, keyX );
+
+    // then insert new stuff
+    for( EdgeKey e : edgeKeysForLoad ) {
+      R.put( MultiKey.factory( x, y, e ), MultiViewMap.dummyValue );
+
+      for( MultiKey fullKeyY : mapY0.keySet() ) {
+        R.put( MultiKey.factory( x,
+                                 fullKeyY.get( 1 ), 
+                                 e ), 
+               MultiViewMap.dummyValue );
+
+        R.put( MultiKey.factory( x, 
+                                 fullKeyY.get( 1 ), 
+                                 fullKeyY.get( 2 ) ), 
+               MultiViewMap.dummyValue );
+      }
+    }
   }
 
   public void storeR( TempDescriptor x,
index 00f0735f648b9a0d5e476f1046fd7b5fe0c0b639..176bba262f46ed95596e58d7afdffc2f4b92ee1b 100644 (file)
@@ -1302,6 +1302,7 @@ public class DisjointAnalysis implements HeapAnalysis {
     FlatSESEEnterNode sese;
     FlatSESEExitNode fsexn;
 
+    Set<EdgeKey> edgeKeysForLoad;
     Set<EdgeKey> edgeKeysRemoved;
 
     //Stores the flatnode's reach graph at enter
@@ -1455,12 +1456,17 @@ public class DisjointAnalysis implements HeapAnalysis {
         }
       }
 
+      edgeKeysForLoad = null;
+      if( doDefiniteReachAnalysis ) {
+        edgeKeysForLoad = new HashSet<EdgeKey>();
+      }
+
       if( shouldAnalysisTrack(fld.getType() ) ) {
         // transfer func
-        rg.assignTempXEqualToTempYFieldF(lhs, rhs, fld, fn);
+        rg.assignTempXEqualToTempYFieldF( lhs, rhs, fld, fn, edgeKeysForLoad );
 
         if( doDefiniteReachAnalysis ) {
-          definiteReachAnalysis.load( fn, lhs, rhs, fld );
+          definiteReachAnalysis.load( fn, lhs, rhs, fld, edgeKeysForLoad );
         }
       }
 
@@ -1549,12 +1555,17 @@ public class DisjointAnalysis implements HeapAnalysis {
         }
       }
 
+      edgeKeysForLoad = null;
+      if( doDefiniteReachAnalysis ) {
+        edgeKeysForLoad = new HashSet<EdgeKey>();
+      }
+
       if( shouldAnalysisTrack(lhs.getType() ) ) {
         // transfer func
-        rg.assignTempXEqualToTempYFieldF(lhs, rhs, fdElement, fn);
+        rg.assignTempXEqualToTempYFieldF( lhs, rhs, fdElement, fn, edgeKeysForLoad );
 
         if( doDefiniteReachAnalysis ) {
-          definiteReachAnalysis.load( fn, lhs, rhs, fdElement );
+          definiteReachAnalysis.load( fn, lhs, rhs, fdElement, edgeKeysForLoad );
         }
       }
 
index 02037c79c7adff9105f6c4d6392358945bf337e2..8d5038c07b003a2422f785bfe3b4b66f60b24d43 100644 (file)
@@ -494,7 +494,8 @@ public class ReachGraph {
   public void assignTempXEqualToTempYFieldF(TempDescriptor x,
                                             TempDescriptor y,
                                             FieldDescriptor f,
-                                            FlatNode currentProgramPoint
+                                            FlatNode currentProgramPoint,
+                                            Set<EdgeKey> edgeKeysForLoad
                                             ) {
 
     VariableNode lnX = getVariableNodeFromTemp(x);
@@ -533,6 +534,16 @@ public class ReachGraph {
           continue;
         }
 
+        // for definite reach analysis only
+        if( edgeKeysForLoad != null ) {
+          assert f != null;
+          edgeKeysForLoad.add( new EdgeKey( hrnY.getID(), 
+                                            hrnHrn.getID(),
+                                            f )
+                               );
+        }
+
+
         TypeDescriptor tdNewEdge =
           mostSpecificType(edgeHrn.getType(),
                            hrnHrn.getType()
index 79e4eac24ebecd03a024ba125c38f7f75b4e8ea8..a9ee707fee44b9b47bb4b6c4873a6ba080902ba5 100644 (file)
@@ -35,7 +35,7 @@ public class MultiViewMap<T> {
 \r
   // for MultiViewMaps that don't need to use the value,\r
   // template on type Object and map every key to this dummy\r
-  public static Object dummy = new Integer( -12345 );\r
+  public static Object dummyValue = new Integer( -12345 );\r
 \r
 \r
   //  If the entire contents of this map are fullKey -> value:\r