add lookup tables for effects
authorbdemsky <bdemsky>
Thu, 24 Mar 2011 22:24:00 +0000 (22:24 +0000)
committerbdemsky <bdemsky>
Thu, 24 Mar 2011 22:24:00 +0000 (22:24 +0000)
Robust/src/Analysis/OoOJava/ConflictGraph.java
Robust/src/Util/Pair.java

index 0eeb454909fd00345c154d2e57b3c7a2bfee05c8..ac14cf4c27f716af0138b75984d66444c00ae3bf 100644 (file)
@@ -12,6 +12,7 @@ import java.util.Set;
 import java.util.Map.Entry;
 import IR.State;
 
+import Util.Pair;
 import Analysis.Disjoint.Alloc;
 import Analysis.Disjoint.AllocSite;
 import Analysis.Disjoint.DisjointAnalysis;
@@ -22,11 +23,14 @@ import IR.Flat.FlatNew;
 import IR.Flat.FlatNode;
 import IR.Flat.FlatSESEEnterNode;
 import IR.Flat.TempDescriptor;
+import IR.FieldDescriptor;
 
 public class ConflictGraph {
 
   protected Hashtable<String, ConflictNode> id2cn;
   protected Hashtable<FlatNode, Hashtable<Taint, Set<Effect>>> sese2te;
+  protected HashMap<Pair<Alloc, FieldDescriptor>, Integer> seseEffects;
+  protected HashMap<Pair<Alloc, FieldDescriptor>, Integer> stallEffects;
 
   protected DisjointAnalysis da;
   protected FlatMethod fmEnclosing;
@@ -41,6 +45,16 @@ public class ConflictGraph {
     this.state=state;
     id2cn = new Hashtable<String, ConflictNode>();
     sese2te = new Hashtable<FlatNode, Hashtable<Taint, Set<Effect>>>();
+    seseEffects = new HashMap<Pair<Alloc, FieldDescriptor>, Integer>();
+    stallEffects = new HashMap<Pair<Alloc, FieldDescriptor>, Integer>();
+  }
+
+  public int getStallEffects(Alloc affectedNode, FieldDescriptor fd) {
+    return stallEffects.get(new Pair<Alloc, FieldDescriptor>(affectedNode, fd)).intValue();
+  }
+
+  public int getSESEEffects(Alloc affectedNode, FieldDescriptor fd) {
+    return seseEffects.get(new Pair<Alloc, FieldDescriptor>(affectedNode, fd)).intValue();
   }
 
   public void setDisJointAnalysis(DisjointAnalysis da) {
@@ -103,8 +117,14 @@ public class ConflictGraph {
     }
     node.addEffect(as, e);
     node.addTaint(t);
-    
     id2cn.put(id, node);
+
+    Pair<Alloc, FieldDescriptor> p=new Pair<Alloc, FieldDescriptor>(e.getAffectedAllocSite(), e.getField());
+    int type=e.getType();
+    if (!stallEffects.containsKey(p))
+      stallEffects.put(p, new Integer(type));
+    else
+      stallEffects.put(p, new Integer(type|stallEffects.get(p).intValue()));
   }
 
   public void addLiveInNodeEffect(Taint t, Effect e) {
@@ -122,6 +142,13 @@ public class ConflictGraph {
     node.addTaint(t);
 
     id2cn.put(id, node);
+
+    Pair<Alloc, FieldDescriptor> p=new Pair<Alloc, FieldDescriptor>(e.getAffectedAllocSite(), e.getField());
+    int type=e.getType();
+    if (!seseEffects.containsKey(p))
+      seseEffects.put(p, new Integer(type));
+    else
+      seseEffects.put(p, new Integer(type|seseEffects.get(p).intValue()));
   }
 
   public void addConflictEdge(int type, ConflictNode nodeU, ConflictNode nodeV) {
index 061804f451455c6ca9a38648735625e03978b433..367411db910342572a2b70bb830e9ede79e71218 100644 (file)
@@ -14,12 +14,16 @@ public class Pair<A,B> {
     return b;
   }
   public int hashCode() {
-    return a.hashCode()*31+b.hashCode();
+    if (b!=null)
+      return a.hashCode()*31+b.hashCode();
+    else
+      return a.hashCode();
   }
   public boolean equals(Object o) {
     if (!(o instanceof Pair))
       return false;
     Pair t=(Pair)o;
-    return a.equals(t.a)&&b.equals(t.b);
+    return a.equals(t.a)&&(((b!=null)&&(t.b!=null)&&b.equals(t.b))||
+                          ((b==null)&&(t.b==null)));
   }
 }
\ No newline at end of file