changing to new traversers/examiners
authorjjenista <jjenista>
Fri, 18 Mar 2011 21:14:45 +0000 (21:14 +0000)
committerjjenista <jjenista>
Fri, 18 Mar 2011 21:14:45 +0000 (21:14 +0000)
Robust/src/Analysis/Disjoint/BuildStateMachines.java
Robust/src/Analysis/Disjoint/DisjointAnalysis.java
Robust/src/Analysis/OoOJava/ConflictGraph.java
Robust/src/Analysis/OoOJava/OoOJavaAnalysis.java
Robust/src/IR/Flat/RuntimeConflictResolver.java

index d7e404f21ae8f18bdc4d6c88f75c48908230127c..bed70eec9afd6a26f1afc1597b5aa53a2a2f2a5e 100644 (file)
@@ -5,6 +5,8 @@ import java.io.*;
 
 import IR.*;
 import IR.Flat.*;
+import Analysis.OoOJava.*;
+
 
 //////////////////////////////////////////////
 //
@@ -31,6 +33,7 @@ public class BuildStateMachines {
       Hashtable< FlatNode, Hashtable<TempDescriptor, StateMachineForEffects> >();
   }
 
+
   protected StateMachineForEffects getStateMachine( FlatNode       fn,
                                                     TempDescriptor var ) {
 
@@ -50,7 +53,6 @@ public class BuildStateMachines {
   }
 
 
-
   public void addToStateMachine( Taint t, 
                                  Effect e, 
                                  FlatNode currentProgramPoint ) {
index 75d0646f62865cc75dc2f20ec0ebd7ffa5433fac..06818affcbb65bfe12105a2d749a5d773f3181ff 100644 (file)
@@ -623,7 +623,7 @@ public class DisjointAnalysis implements HeapAnalysis {
                            Set<FlatNew> sitesToFlag,
                            RBlockRelationAnalysis rra
                            ) {
-    init( s, tu, cg, l, ar, sitesToFlag, rra, false );
+    init( s, tu, cg, l, ar, sitesToFlag, rra, null, false );
   }
 
   public DisjointAnalysis( State            s,
@@ -635,7 +635,20 @@ public class DisjointAnalysis implements HeapAnalysis {
                            RBlockRelationAnalysis rra,
                            boolean suppressOutput
                            ) {
-    init( s, tu, cg, l, ar, sitesToFlag, rra, suppressOutput );
+    init( s, tu, cg, l, ar, sitesToFlag, rra, null, suppressOutput );
+  }
+
+  public DisjointAnalysis( State            s,
+                          TypeUtil         tu,
+                          CallGraph        cg,
+                          Liveness         l,
+                          ArrayReferencees ar,
+                           Set<FlatNew> sitesToFlag,
+                           RBlockRelationAnalysis rra,
+                           BuildStateMachines bsm,
+                           boolean suppressOutput
+                           ) {
+    init( s, tu, cg, l, ar, sitesToFlag, rra, bsm, suppressOutput );
   }
   
   protected void init( State            state,
@@ -645,29 +658,27 @@ public class DisjointAnalysis implements HeapAnalysis {
                        ArrayReferencees arrayReferencees,
                        Set<FlatNew> sitesToFlag,
                        RBlockRelationAnalysis rra,
+                       BuildStateMachines bsm,
                        boolean suppressOutput
                        ) {
          
     analysisComplete = false;
     
-    this.state            = state;
-    this.typeUtil         = typeUtil;
-    this.callGraph        = callGraph;
-    this.liveness         = liveness;
-    this.arrayReferencees = arrayReferencees;
-    this.sitesToFlag      = sitesToFlag;
-    this.rblockRel        = rra;
-    this.suppressOutput   = suppressOutput;
+    this.state              = state;
+    this.typeUtil           = typeUtil;
+    this.callGraph          = callGraph;
+    this.liveness           = liveness;
+    this.arrayReferencees   = arrayReferencees;
+    this.sitesToFlag        = sitesToFlag;
+    this.rblockRel          = rra;
+    this.suppressOutput     = suppressOutput;
+    this.buildStateMachines = bsm;
 
     if( rblockRel != null ) {
       doEffectsAnalysis = true;
       effectsAnalysis   = new EffectsAnalysis();
     }
 
-    if( state.RCR ) {
-      buildStateMachines = new BuildStateMachines();
-    }
-
     this.allocationDepth         = state.DISJOINTALLOCDEPTH;
     this.releaseMode             = state.DISJOINTRELEASEMODE;
     this.determinismDesired      = state.DISJOINTDETERMINISM;
index 50ddd6c316e35a1c403dc04ded28b3b7f15a9648..9492990e0b74ffc1618a6b164f75d96ac3a26cc7 100644 (file)
@@ -206,8 +206,8 @@ public class ConflictGraph {
 
       if ((!currentNode.getID().equals(entryNodeID))
           && !(analyzedIDSet.contains(currentNode.getID() + entryNodeID) || analyzedIDSet
-              .contains(entryNodeID + currentNode.getID()))) {
-
+               .contains(entryNodeID + currentNode.getID()))) {
+        
         conflictType = calculateConflictType(currentNode, entryNode, useReachInfo);
         if (conflictType > ConflictGraph.NON_WRITE_CONFLICT) {
           addConflictEdge(conflictType, currentNode, entryNode);
@@ -224,11 +224,12 @@ public class ConflictGraph {
   }
 
   private int calculateConflictType(ConflictNode node, boolean useReachInfo) {
-
+    
     int conflictType = ConflictGraph.NON_WRITE_CONFLICT;
-    Hashtable<Alloc, Set<Effect>> alloc2readEffects = node.getReadEffectSet();
-    Hashtable<Alloc, Set<Effect>> alloc2writeEffects = node.getWriteEffectSet();
-    Hashtable<Alloc, Set<Effect>> alloc2SUEffects = node.getStrongUpdateEffectSet();
+
+    Hashtable<Alloc, Set<Effect>> alloc2readEffects = node.getReadEffectSet();      
+    Hashtable<Alloc, Set<Effect>> alloc2writeEffects = node.getWriteEffectSet();    
+    Hashtable<Alloc, Set<Effect>> alloc2SUEffects = node.getStrongUpdateEffectSet(); 
 
     conflictType =
         updateConflictType(conflictType, determineConflictType(node, alloc2writeEffects, node,
index c73f7fa64100b9c7a37b747e683fa3a44a8b627c..8f1e9b794a5ca6167513571bff705b200237b09e 100644 (file)
@@ -1,46 +1,15 @@
 package Analysis.OoOJava;
 
-import java.io.BufferedWriter;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.util.Enumeration;
-import java.util.HashSet;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-import java.util.Stack;
-import java.util.Map.Entry;
-
-import Analysis.Pointer.Pointer;
-import Analysis.ArrayReferencees;
-import Analysis.Liveness;
-import Analysis.CallGraph.CallGraph;
-import Analysis.Disjoint.HeapAnalysis;
-import Analysis.Disjoint.DisjointAnalysis;
-import Analysis.Disjoint.Effect;
-import Analysis.Disjoint.EffectsAnalysis;
-import Analysis.Disjoint.Taint;
-import IR.Descriptor;
-import IR.MethodDescriptor;
-import IR.Operation;
-import IR.State;
-import IR.TypeUtil;
-import IR.Flat.FKind;
-import IR.Flat.FlatCall;
-import IR.Flat.FlatEdge;
-import IR.Flat.FlatElementNode;
-import IR.Flat.FlatFieldNode;
-import IR.Flat.FlatMethod;
-import IR.Flat.FlatNew;
-import IR.Flat.FlatNode;
-import IR.Flat.FlatOpNode;
-import IR.Flat.FlatSESEEnterNode;
-import IR.Flat.FlatSESEExitNode;
-import IR.Flat.FlatSetElementNode;
-import IR.Flat.FlatSetFieldNode;
-import IR.Flat.FlatWriteDynamicVarNode;
-import IR.Flat.TempDescriptor;
+import java.io.*;
+import java.util.*;
+
+import Analysis.*;
+import Analysis.CallGraph.*;
+import Analysis.Disjoint.*;
+import Analysis.Pointer.*;
+import IR.*;
+import IR.Flat.*;
+
 
 public class OoOJavaAnalysis {
 
@@ -51,6 +20,7 @@ public class OoOJavaAnalysis {
   private RBlockRelationAnalysis rblockRel;
   private HeapAnalysis disjointAnalysisTaints;
   private DisjointAnalysis disjointAnalysisReach;
+  private BuildStateMachines buildStateMachines;
 
   private Set<MethodDescriptor> descriptorsToAnalyze;
 
@@ -143,6 +113,11 @@ public class OoOJavaAnalysis {
     fn2contextTaskNames    = new Hashtable<FlatNode, ContextTaskNames>();
     fn2fm                  = new Hashtable<FlatNode, FlatMethod>();
 
+    // state machines support heap examiners with
+    // state transitions to improve precision
+    if( state.RCR ) {
+      buildStateMachines = new BuildStateMachines();
+    }
 
     // add all methods transitively reachable from the
     // source's main to set for analysis
@@ -205,7 +180,7 @@ public class OoOJavaAnalysis {
     } else
       disjointAnalysisTaints =
         new DisjointAnalysis(state, typeUtil, callGraph, liveness, arrayReferencees, null, 
-                             rblockRel,
+                             rblockRel, buildStateMachines,
                              true ); // suppress output--this is an intermediate pass
 
     // 6th pass, not available analysis FOR VARIABLES!
@@ -237,11 +212,21 @@ public class OoOJavaAnalysis {
       disjointAnalysisReach =
         new DisjointAnalysis(state, typeUtil, callGraph, liveness, 
                              arrayReferencees, sitesToFlag,
-                            null // don't do effects analysis again!
+                            null, // don't do effects analysis again!
+                             null, // no BuildStateMachines needed
+                             false // don't suppress progress output
                             );
 
       // 10th pass, calculate conflicts with reachability info
       calculateConflicts(null, true);
+
+    } else {
+      // in RCR/DFJ we want to do some extra processing on the
+      // state machines before they get handed off to code gen,
+      // and we're doing the same effect-conflict traversal needed
+      // to identify heap examiners that are weakly connected, so
+      // accomplish both at the same time
+      pruneMachinesAndFindWeaklyConnectedExaminers();
     }
 
     // 11th pass, compiling memory Qs!  The name "lock" is a legacy
@@ -1283,12 +1268,51 @@ public class OoOJavaAnalysis {
   }
 
 
+
+  // the traversal for pruning state machines and finding
+  // machines that are weakly connected BOTH consider conflicting
+  // effects between heap roots, so it is smart to compute all of
+  // this together
+  public void pruneMachinesAndFindWeaklyConnectedExaminers() {
+
+    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
+      Set<ConflictEdge> conflictEdges = conflictGraph.getEdgeSet();
+      for( Iterator edgeItr = conflictEdges.iterator(); edgeItr.hasNext(); ) {
+        ConflictEdge conflictEdge = (ConflictEdge) edgeItr.next();
+        
+        
+      }
+      
+    }
+    
+  }
+
+
+
   private void synthesizeLocks() {
     // for every conflict graph, generate a set of memory queues
     // (called SESELock in this code!) to cover the graph
-    Set<Entry<FlatNode, ConflictGraph>> graphEntrySet = sese2conflictGraph.entrySet();
+    Set<Map.Entry<FlatNode, ConflictGraph>> graphEntrySet = sese2conflictGraph.entrySet();
     for (Iterator iterator = graphEntrySet.iterator(); iterator.hasNext();) {
-      Entry<FlatNode, ConflictGraph> graphEntry = (Entry<FlatNode, ConflictGraph>) iterator.next();
+      Map.Entry<FlatNode, ConflictGraph> graphEntry = (Map.Entry<FlatNode, ConflictGraph>) iterator.next();
       FlatNode sese = graphEntry.getKey();
       ConflictGraph conflictGraph = graphEntry.getValue();
       calculateCovering(conflictGraph);
index 994e9b31d59beef160f9734f8e11b98f4910062e..ba6d5dfb3601a90d9b9250298f860014b9d03cda 100644 (file)
@@ -370,33 +370,32 @@ public class RuntimeConflictResolver {
   }
   
   //This is Pass 1 of internal graph creation. 
-       private void createPrunedGraph(
-                       Hashtable<Integer, ConcreteRuntimeObjNode> created,
-                       VariableNode varNode, 
-                       Taint t) {
-               // For every inset HRN, create a graph node, and run a DFT (buildPrunedGraphFromRG)
-               Iterator<RefEdge> possibleEdges = varNode.iteratorToReferencees();
-               while (possibleEdges.hasNext()) {
-                       RefEdge edge = possibleEdges.next();
-                       assert edge != null;
+  private void createPrunedGraph(Hashtable<Integer, ConcreteRuntimeObjNode> created,
+                                 VariableNode varNode, 
+                                 Taint t) {
+    // For every inset HRN, create a graph node, and run a DFT (buildPrunedGraphFromRG)
+    Iterator<RefEdge> possibleEdges = varNode.iteratorToReferencees();
+    while (possibleEdges.hasNext()) {
+      RefEdge edge = possibleEdges.next();
+      assert edge != null;
 
-                       ConcreteRuntimeObjNode singleRoot = new ConcreteRuntimeObjNode(edge.getDst(), true);
-                       int rootKey = singleRoot.allocSite.getUniqueAllocSiteID();
+      ConcreteRuntimeObjNode singleRoot = new ConcreteRuntimeObjNode(edge.getDst(), true);
+      int rootKey = singleRoot.allocSite.getUniqueAllocSiteID();
 
-                       if (!created.containsKey(rootKey)) {
-                               created.put(rootKey, singleRoot);
-                               buildPrunedGraphFromRG(singleRoot, edge.getDst().iteratorToReferencees(), created, t);
-                       }
-               }
-       }
+      if (!created.containsKey(rootKey)) {
+        created.put(rootKey, singleRoot);
+        buildPrunedGraphFromRG(singleRoot, edge.getDst().iteratorToReferencees(), created, t);
+      }
+    }
+  }
        
   //Performs Depth First Traversal on the ReachGraph to build an
   //internal representation of it. It prunes ptrs not reachable
   //by read Effects and stores in each node the effects by it.
   private void buildPrunedGraphFromRG(  ConcreteRuntimeObjNode curr, 
-                            Iterator<RefEdge> edges, 
-                            Hashtable<Integer, ConcreteRuntimeObjNode> created,
-                            Taint taint) {
+                                        Iterator<RefEdge> edges, 
+                                        Hashtable<Integer, ConcreteRuntimeObjNode> created,
+                                        Taint taint) {
     EffectsGroup currEffects = effectsLookupTable.getEffects(curr.allocSite, taint); 
     
     if (currEffects == null || currEffects.isEmpty())