changes to process/prune state machines
authorbdemsky <bdemsky>
Fri, 25 Mar 2011 00:10:05 +0000 (00:10 +0000)
committerbdemsky <bdemsky>
Fri, 25 Mar 2011 00:10:05 +0000 (00:10 +0000)
Robust/src/Analysis/Disjoint/BuildStateMachines.java
Robust/src/Analysis/Disjoint/Effect.java
Robust/src/Analysis/Disjoint/SMFEState.java
Robust/src/Analysis/Disjoint/StateMachineForEffects.java
Robust/src/Analysis/OoOJava/ConflictGraph.java
Robust/src/Analysis/OoOJava/OoOJavaAnalysis.java
Robust/src/Analysis/OoOJava/RBlockRelationAnalysis.java

index 9360226bef54a8c23c81990155d359435f0797c8..525b58c1fe817e395039cb6b3319f4449b59e1ef 100644 (file)
@@ -31,16 +31,19 @@ public class BuildStateMachines {
   
   // remember all the FlatNode/TempDescriptor pairs that have a state machines
   // for easy retrieval of all machines
-  protected Set<Pair> allMachineNamePairs;
+  protected Set<Pair<FlatNode, TempDescriptor>> allMachineNamePairs;
 
 
   public BuildStateMachines() {
     fn2var2smfe = new
       Hashtable< FlatNode, Hashtable<TempDescriptor, StateMachineForEffects> >();
 
-    allMachineNamePairs = new HashSet<Pair>();
+    allMachineNamePairs = new HashSet<Pair<FlatNode, TempDescriptor>>();
   }
 
+  public StateMachineForEffects getStateMachine(Pair<FlatNode, TempDescriptor> fnpair) {
+    return getStateMachine(fnpair.getFirst(), fnpair.getSecond());
+  }
 
   public StateMachineForEffects getStateMachine( FlatNode       fn,
                                                  TempDescriptor var ) {
@@ -56,14 +59,14 @@ public class BuildStateMachines {
       smfe = new StateMachineForEffects( fn );
       var2smfe.put( var, smfe );
 
-      allMachineNamePairs.add( new Pair( fn, var ) );
+      allMachineNamePairs.add( new Pair<FlatNode, TempDescriptor>( fn, var ) );
     }
 
     return smfe;
   }
 
 
-  public Set<Pair> getAllMachineNames() {
+  public Set<Pair<FlatNode, TempDescriptor>> getAllMachineNames() {
     return allMachineNamePairs;
   }
 
@@ -118,8 +121,6 @@ public class BuildStateMachines {
       }
     }
   }
-
-
   //TODO JIM! Give me the REAALL number here. 
   public int getTotalNumOfWeakGroups() {
     // TODO Auto-generated method stub
index 5e59e005ba6ec650d6f462712df5ec5b3b91c592..fe07ebcc5086bd59999c1620a36da74df91125cd 100644 (file)
@@ -8,7 +8,7 @@ public class Effect {
   // operation type
   public static final int read = 1;
   public static final int write = 2;
-  public static final int strongupdate = 3;
+  public static final int strongupdate = 4;
 
   // identify an allocation site of affected object
   protected Alloc affectedAllocSite;
@@ -25,6 +25,10 @@ public class Effect {
     this.field = field;
   }
 
+  public static boolean isWrite(int effect) {
+    return (effect & Effect.write)==Effect.write;
+  }
+
   public Alloc getAffectedAllocSite() {
     return affectedAllocSite;
   }
index 2250d05d5f6339931a70d1d70b2905ac85230a73..dbb793dab506d28e8a61c461784472bc96daf8ed 100644 (file)
@@ -76,8 +76,7 @@ public class SMFEState {
       e2states.put( effect, states );
     }
     states.add( stateTo );
-
-    ++stateTo.refCount;
+    stateTo.refCount++;
   }
 
 
@@ -92,10 +91,12 @@ public class SMFEState {
     return effects;
   }
   
+  public void addConflict(Effect e) {
+    conflicts.add(e);
+  }
+
   public Set<Effect> getConflicts() {
-    //TODO JIM! Fix this when have a chance!
-    conflicts.addAll(effects);
-    return this.conflicts;
+    return conflicts;
   }
   
   public Set<Effect> getTransistionEffects() {
@@ -112,6 +113,16 @@ public class SMFEState {
     return statesOut;
   }
 
+  // some subset of the above effects may transition to
+  // other states
+  public Set<SMFEState> transitionsTo() {
+    Set<SMFEState> statesOut = new HashSet<SMFEState>();
+    for(Map.Entry<Effect, Set<SMFEState>> entry:e2states.entrySet()) {
+      statesOut.addAll(entry.getValue());
+    }
+    return statesOut;
+  }
+
   public int getRefCount() {
     return refCount;
   }
index af0c6e9a06245d690f1573f741f81651fb159af9..360a1d28a64ba171de2c59fb1ebd901769626005 100644 (file)
@@ -5,6 +5,7 @@ import java.io.*;
 
 import IR.*;
 import IR.Flat.*;
+import Util.Pair;
 
 //////////////////////////////////////////////
 //
@@ -17,6 +18,7 @@ import IR.Flat.*;
 
 public class StateMachineForEffects {
   public final static FlatNode startNode=new FlatNop();
+  protected HashMap<Pair<Alloc, FieldDescriptor>, Integer> effectsMap;
 
   // states in the machine are uniquely identified 
   // by a flat node (program point)
@@ -26,21 +28,41 @@ public class StateMachineForEffects {
   protected Hashtable<FlatNode, Integer> fn2weaklyConnectedGroupID;
 
   protected SMFEState initialState;
-
+  protected FlatNode fn;
 
   public StateMachineForEffects( FlatNode fnInitial ) {
     fn2state = new Hashtable<FlatNode, SMFEState>();
-
+    effectsMap = new HashMap<Pair<Alloc, FieldDescriptor>, Integer>();
     initialState = getState( fnInitial );
+    this.fn=fnInitial;
+  }
+
+  public Set<SMFEState> getStates() {
+    HashSet<SMFEState> set=new HashSet<SMFEState>();
+    set.addAll(fn2state.values());
+    return set;
+  }
+
+  public FlatNode getStallorSESE() {
+    return fn;
+  }
+
+  public int getEffects(Alloc affectedNode, FieldDescriptor fd) {
+    return effectsMap.get(new Pair<Alloc, FieldDescriptor>(affectedNode, fd)).intValue();
   }
 
   public void addEffect( FlatNode fnState,
                          Effect e ) {
-
     if (fnState==null)
       fnState=startNode;
     SMFEState state = getState( fnState );
     state.addEffect( e );
+    Pair<Alloc, FieldDescriptor> p=new Pair<Alloc, FieldDescriptor>(e.getAffectedAllocSite(), e.getField());
+    int type=e.getType();
+    if (!effectsMap.containsKey(p))
+      effectsMap.put(p, new Integer(type));
+    else
+      effectsMap.put(p, new Integer(type|effectsMap.get(p).intValue()));
   }
 
   public void addTransition( FlatNode fnFrom,
@@ -75,7 +97,6 @@ public class StateMachineForEffects {
     return 0;
   }
 
-
   public void writeAsDOT( String graphName ) {
     //String graphName = initialState.getID().toString();
     graphName = graphName.replaceAll( "[\\W]", "" );
index ac14cf4c27f716af0138b75984d66444c00ae3bf..d8e725294a1a1c986c75fabc162dd2c1d0d88b8f 100644 (file)
@@ -29,8 +29,6 @@ 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;
@@ -45,16 +43,6 @@ 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) {
@@ -118,13 +106,6 @@ 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) {
@@ -143,12 +124,6 @@ public class ConflictGraph {
 
     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 3162ab2295dba576dabe224e6b96bb09227560c6..db55e6f74811f25b9efa518de218dd2b06318a12 100644 (file)
@@ -10,7 +10,6 @@ import Analysis.Pointer.*;
 import IR.*;
 import IR.Flat.*;
 
-
 public class OoOJavaAnalysis {
 
   // data from the compiler
@@ -1288,34 +1287,8 @@ public class OoOJavaAnalysis {
   // effects between heap roots, so it is smart to compute all of
   // this together
   public void pruneMachinesAndFindWeaklyConnectedExaminers() {
-
-    /*
-    // TODO, calcualte the set of taints that lead to conflicts (for which
-    // traversers must be built...)
-
-    EffectsAnalysis effectsAnalysis = disjointAnalysisTaints.getEffectsAnalysis();
-
-    // visit every conflict graph once, so iterate through the
-    // the non-leaf tasks to find them all
-    Set<FlatSESEEnterNode> allSESEs = rblockRel.getAllSESEs();
-    for( Iterator allItr = allSESEs.iterator(); allItr.hasNext(); ) {
-      
-      FlatSESEEnterNode parent = (FlatSESEEnterNode) allItr.next();
-      if( parent.getIsLeafSESE() ) {
-        continue;
-      }
-      
-      ConflictGraph conflictGraph = sese2conflictGraph.get( parent );
-      assert conflictGraph != null;
-      
-      // from the conflict graph we want to extract all conflicting effects
-      // and use them to identify (1) weakly connected heap examiners and
-      // (2) states/examiner nodes with a conflicting effect that will later
-      // support the examiner pruning process
-      Hashtable<Taint, Set<Effect>> conflicts = conflictGraph.getConflictEffectSet( fsen ) );
-      
-    }
-    */
+    ProcessStateMachines psm=new ProcessStateMachines(buildStateMachines, rblockRel);
+    psm.doProcess();
   }
 
 
index 951e4cd8bba97640fb3e8451854e6c6292ed80f5..080203c4450e53db40f15c68de403630fabcbaca 100644 (file)
@@ -89,8 +89,8 @@ public class RBlockRelationAnalysis {
   // node it will be in this set
   protected Hashtable< FlatNode, Set<FlatSESEEnterNode> > fn2currentSESEs;
 
-  // if you want to know which rblocks might be executing a given flat
-  // node it will be in this set
+  // if you want to know which rblocks might be TRANSITIVELY executing
+  // a given flat node it will be in this set
   protected Hashtable< FlatNode, Set<FlatSESEEnterNode> > fn2allSESEs;
 
   // if you want to know the method-local, inner-most nested task that