two methods for generating a reach graph at any desired program point, one is a dummy...
authorjjenista <jjenista>
Mon, 11 Oct 2010 19:11:16 +0000 (19:11 +0000)
committerjjenista <jjenista>
Mon, 11 Oct 2010 19:11:16 +0000 (19:11 +0000)
14 files changed:
Robust/src/Analysis/Disjoint/DisjointAnalysis.java
Robust/src/Analysis/Disjoint/PointerMethod.java
Robust/src/ClassLibrary/System.java
Robust/src/IR/Flat/BuildCode.java
Robust/src/IR/Flat/BuildFlat.java
Robust/src/IR/Flat/FKind.java
Robust/src/IR/Flat/FlatGenReachNode.java [new file with mode: 0644]
Robust/src/IR/Tree/BuildIR.java
Robust/src/IR/Tree/GenReachNode.java [new file with mode: 0644]
Robust/src/IR/Tree/Kind.java
Robust/src/IR/Tree/SemanticCheck.java
Robust/src/Lex/Keyword.java
Robust/src/Lex/Lexer.java
Robust/src/Parse/java14.cup

index a07a2a6ec7e9fbb48b63548e75c681337c3af57e..faae0e9e91e0fc69a5f3a7363b2596f6fa13dfec 100644 (file)
@@ -1110,6 +1110,19 @@ public class DisjointAnalysis {
     // to apply to the reachability graph
     switch( fn.kind() ) {
 
+    case FKind.FlatGenReachNode: {
+      System.out.println( "Generating a reach graph!" );
+      rg.writeGraph( "genReach"+d,
+                     true,    // write labels (variables)                
+                     true,    // selectively hide intermediate temp vars 
+                     true,    // prune unreachable heap regions          
+                     false,   // hide reachability altogether
+                     true,    // hide subset reachability states         
+                     true,    // hide predicates
+                     true );  // hide edge taints      
+    } break;
+
+
     case FKind.FlatMethod: {
       // construct this method's initial heap model (IHM)
       // since we're working on the FlatMethod, we know
@@ -1415,6 +1428,21 @@ public class DisjointAnalysis {
       FlatCall         fc       = (FlatCall) fn;
       MethodDescriptor mdCallee = fc.getMethod();
       FlatMethod       fmCallee = state.getMethodFlat( mdCallee );
+
+
+      if( mdCallee.getSymbol().equals( "genReach" ) ) {
+        rg.writeGraph( "genReach"+d,
+                       true,    // write labels (variables)                
+                       true,    // selectively hide intermediate temp vars 
+                       true,    // prune unreachable heap regions          
+                       false,   // hide reachability altogether
+                       true,    // hide subset reachability states         
+                       true,    // hide predicates
+                       true );  // hide edge taints      
+        break;
+      }
+
+
   
       boolean debugCallSite =
         mdCaller.getSymbol().equals( state.DISJOINTDEBUGCALLER ) &&
@@ -1654,7 +1682,14 @@ public class DisjointAnalysis {
       Descriptor  d = (Descriptor) me.getKey();
       ReachGraph rg = (ReachGraph) me.getValue();
 
-      rg.writeGraph( "COMPLETE"+d,
+      String graphName;
+      if( d instanceof TaskDescriptor ) {
+        graphName = "COMPLETEtask"+d;
+      } else {
+        graphName = "COMPLETE"+d;
+      }
+
+      rg.writeGraph( graphName,
                      true,    // write labels (variables)                
                      true,    // selectively hide intermediate temp vars 
                      true,    // prune unreachable heap regions          
@@ -1728,7 +1763,14 @@ public class DisjointAnalysis {
       }
       Integer n = mapDescriptorToNumUpdates.get( d );
       
-      rg.writeGraph( d+"COMPLETE"+String.format( "%05d", n ),
+      String graphName;
+      if( d instanceof TaskDescriptor ) {
+        graphName = d+"COMPLETEtask"+String.format( "%05d", n );
+      } else {
+        graphName = d+"COMPLETE"+String.format( "%05d", n );
+      }
+
+      rg.writeGraph( graphName,
                      true,   // write labels (variables)
                      true,   // selectively hide intermediate temp vars
                      true,   // prune unreachable heap regions
@@ -2540,7 +2582,7 @@ getFlaggedAllocationSitesReachableFromTaskPRIVATE(TaskDescriptor td) {
                      true,   // selectively hide intermediate temp vars
                      true,   // prune unreachable heap regions
                      false,  // hide reachability
-                     true,   // hide subset reachability states
+                     false,  // hide subset reachability states
                      true,   // hide predicates
                      false );// hide edge taints
     }
index 396474d3c2f9199bcf0179891171ef202eafba6d..c3625e942bf6ff58a72cb09654d3ab69f478f81d 100644 (file)
@@ -97,6 +97,7 @@ public class PointerMethod {
     case FKind.FlatBackEdge:
     case FKind.FlatSESEEnterNode:
     case FKind.FlatSESEExitNode:
+    case FKind.FlatGenReachNode:
       return true;
     case FKind.FlatCastNode:
       FlatCastNode fcn=(FlatCastNode)fn;
index 249a09e4d45b4c56604699d07bf65bcd6ecffb30..05443dac8b09140f7439dd32de004347d140277c 100644 (file)
@@ -79,4 +79,7 @@ public class System {
   /* Only used for microbenchmark testing of SingleTM version */
 
   public static native void arraycopy(Object src, int srcPos, Object dst, int destPos, int length);
+
+  // for disjoint reachability analysis
+  public static void genReach();
 }
index 4adce576a132b176c36b26a095caa6cf595e5d6f..bdf2b645d6ff86dcd0eead8154a6417d923fed4b 100644 (file)
@@ -1897,7 +1897,7 @@ public class BuildCode {
          while( dynSrcItr.hasNext() ) {
            TempDescriptor dynSrcVar = dynSrcItr.next();
            output.println("   SESEcommon*  "+dynSrcVar+"_srcSESE = NULL;");
-           output.println("   INTPTR       "+dynSrcVar+"_srcOffset;");
+           output.println("   INTPTR       "+dynSrcVar+"_srcOffset = 0x1;");
          }    
        }
       }
@@ -2245,7 +2245,7 @@ public class BuildCode {
     while( dynSrcItr.hasNext() ) {
       TempDescriptor dynSrcVar = dynSrcItr.next();
       output.println("   SESEcommon*  "+dynSrcVar+"_srcSESE = NULL;");
-      output.println("   INTPTR       "+dynSrcVar+"_srcOffset;");
+      output.println("   INTPTR       "+dynSrcVar+"_srcOffset = 0x1;");
     }    
 
     // declare local temps for in-set primitives, and if it is
@@ -2389,7 +2389,7 @@ public class BuildCode {
       }
       
       output.println("     "+generateTemp( fsen.getfmBogus(), temp, null )+
-                    " = *(("+typeStr+"*) ("+
+                    " = *(("+typeStr+"*) ((void*)"+
                     paramsprefix+"->"+temp+"_srcSESE + "+
                     paramsprefix+"->"+temp+"_srcOffset));");
 
@@ -2965,7 +2965,7 @@ public class BuildCode {
           }
       
          output.println("       "+generateTemp( fmContext, dynVar, null )+
-                         " = *(("+typeStr+"*) ("+
+                         " = *(("+typeStr+"*) ((void*)"+
                          dynVar+"_srcSESE + "+dynVar+"_srcOffset));");
           if( state.COREPROF ) {
             output.println("#ifdef CP_EVENTID_TASKSTALLVAR");
@@ -3215,6 +3215,11 @@ public class BuildCode {
       output.println("/* nop */");
       break;
 
+    case FKind.FlatGenReachNode:
+      // this node is just for generating a reach graph
+      // in disjointness analysis at a particular program point
+      break;
+
     case FKind.FlatExit:
       output.println("/* exit */");
       break;
index 584e876785a79cc44f8e106b6e03c21c8a41f848..5c70bf8b1bcaa603f47dd3cac1cb487e9a7aac1f 100644 (file)
@@ -1227,6 +1227,11 @@ public class BuildFlat {
     return new NodePair(faen, faexn);
   }
 
+  private NodePair flattenGenReachNode( GenReachNode grn ) {
+    FlatGenReachNode fgrn = new FlatGenReachNode( grn.getGraphName() );
+    return new NodePair( fgrn, fgrn );
+  }
+
   private NodePair flattenSESENode(SESENode sn) {
     if( sn.isStart() ) {
       FlatSESEEnterNode fsen=new FlatSESEEnterNode(sn);
@@ -1365,6 +1370,9 @@ public class BuildFlat {
     case Kind.SESENode:
       return flattenSESENode((SESENode)bsn);
 
+    case Kind.GenReachNode:
+      return flattenGenReachNode((GenReachNode)bsn);
+
     case Kind.ContinueBreakNode:
       return flattenContinueBreakNode((ContinueBreakNode)bsn);
     }
index 2ba61b50893f794bc58a8f588108414b8feba76e..89cbf47474c786afb2fd029cdb89e6cd8489855b 100644 (file)
@@ -28,4 +28,5 @@ public class FKind {
   public static final int FlatWriteDynamicVarNode=25;
   public static final int FlatInstanceOfNode=26;
   public static final int FlatExit=27;
+  public static final int FlatGenReachNode=28;
 }
diff --git a/Robust/src/IR/Flat/FlatGenReachNode.java b/Robust/src/IR/Flat/FlatGenReachNode.java
new file mode 100644 (file)
index 0000000..d72c2e3
--- /dev/null
@@ -0,0 +1,31 @@
+package IR.Flat;
+import IR.TypeDescriptor;
+
+public class FlatGenReachNode extends FlatNode {
+  String graphName;
+
+  public FlatGenReachNode( String graphName ) {
+    this.graphName = graphName;
+  }
+
+  public String getGraphName() {
+    return graphName;
+  }
+
+  public FlatNode clone(TempMap t){ return new FlatGenReachNode( graphName ); }
+  public void rewriteUse(TempMap t){}
+  public void rewriteDst(TempMap t) {}
+
+
+  public String toString() {
+    return "FlatGenReachNode_"+graphName;
+  }
+
+  public int kind() {
+    return FKind.FlatGenReachNode;
+  }
+
+  public TempDescriptor [] writesTemps() {
+    return new TempDescriptor[0];
+  }
+}
index b4d6b3bd27ca8c21b8d85deda5d4d1686272ea00..a2bd61e783aea8f2dd805b93e08450c971215d50 100644 (file)
@@ -779,9 +779,13 @@ public class BuildIR {
       blockstatements.addAll(parseSESEBlock(blockstatements,pn.getChild("body").getFirstChild()));
       blockstatements.add(end);
     } else if (isNode(pn,"continue")) {
-       blockstatements.add(new ContinueBreakNode(false));
+      blockstatements.add(new ContinueBreakNode(false));
     } else if (isNode(pn,"break")) {
-       blockstatements.add(new ContinueBreakNode(true));
+      blockstatements.add(new ContinueBreakNode(true));
+
+    } else if (isNode(pn,"genreach")) {
+      String graphName = pn.getChild("graphName").getTerminal();
+      blockstatements.add( new GenReachNode( graphName ) );
 
     } else {
       System.out.println("---------------");
diff --git a/Robust/src/IR/Tree/GenReachNode.java b/Robust/src/IR/Tree/GenReachNode.java
new file mode 100644 (file)
index 0000000..1335c51
--- /dev/null
@@ -0,0 +1,22 @@
+package IR.Tree;
+
+public class GenReachNode extends BlockStatementNode {
+  String graphName;
+
+  public GenReachNode( String graphName ) {
+    assert graphName != null;
+    this.graphName = graphName;
+  }
+
+  public String printNode(int indent) {
+    return "genReach "+graphName;
+  }
+
+  public String getGraphName() {
+    return graphName;
+  }
+
+  public int kind() {
+    return Kind.GenReachNode;
+  }
+}
index 40375f467103d4f025af6e8703cf03b4326693e5..4bbe21fa1de2e5015247e8546b6ce2fc0841a086 100644 (file)
@@ -29,4 +29,5 @@ public class Kind {
   public final static int InstanceOfNode=26;
   public final static int ArrayInitializerNode=27;
   public final static int SynchronizedNode=28;
+  public final static int GenReachNode=29;
 }
index 2e9a5e9e9658b8e5965c25a0b2635ca2d867d833..e8ddffce476a9e4fb1ac9055472fb0f810543cbd 100644 (file)
@@ -305,6 +305,7 @@ public class SemanticCheck {
        return;
 
     case Kind.SESENode:
+    case Kind.GenReachNode:
       // do nothing, no semantic check for SESEs
       return;
     }
index 763086ed6538dd7652a4fe8d2c78ea83f335f127..3b830c8d0ff3fafa6b8b7a0894b1f0517baecbe6 100644 (file)
@@ -41,6 +41,7 @@ class Keyword extends Token {
     key_table.put("finally", new Integer(Sym.FINALLY));
     key_table.put("float", new Integer(Sym.FLOAT));
     key_table.put("for", new Integer(Sym.FOR));
+    key_table.put("genreach", new Integer(Sym.GENREACH));
     key_table.put("goto", new Integer(Sym.GOTO));
     key_table.put("if", new Integer(Sym.IF));
     key_table.put("import", new Integer(Sym.IMPORT));
index 2d16e68ad7b35148de9286849c4a8c9049e0e380..34f24fdef0c523dfcbc492e2e8c33f0396dd6453 100644 (file)
@@ -261,7 +261,7 @@ public class Lexer {
     "else", "enum",
     "extends", "external", "final", "finally",
     "flag", //keyword for failure aware computation
-    "float", "for","getoffset", "global", "goto", "if",
+    "float", "for", "genreach", "getoffset", "global", "goto", "if",
     //"implements",
     "import", "instanceof", "int",
     //"interface",
index 4831dee39206975f9f04fd1265a898b6545a20e8..3b03115c31a12944a63252c31a36b1c16d4c1442 100644 (file)
@@ -103,6 +103,9 @@ terminal ASSERT; // assert_statement
 terminal ELLIPSIS;
 terminal ENUM;
 
+// added for disjoint reachability analysis
+terminal GENREACH;
+
 
 // 19.2) The Syntactic Grammar
 non terminal ParseNode goal;
@@ -194,6 +197,7 @@ non terminal ParseNode synchronized_statement;
 //non terminal ParseNode catches, catch_clause;
 //non terminal ParseNode finally;
 //non terminal ParseNode assert_statement;
+non terminal ParseNode genreach_statement;
 // 19.12) Expressions
 non terminal ParseNode primary, primary_no_new_array;
 non terminal ParseNode class_instance_creation_expression;
@@ -1195,6 +1199,7 @@ statement_without_trailing_substatement ::=
        |       atomic_statement:st {: RESULT=st; :}
        |       sese_statement:st {: RESULT=st; :}
        |       synchronized_statement:st {: RESULT=st; :}
+       |       genreach_statement:st {: RESULT=st; :}
 //     |       throw_statement
 //     |       try_statement
 //     |       assert_statement
@@ -1990,3 +1995,11 @@ expression ::=   assignment_expression:exp {:
 //constant_expression ::=
 //             expression
 //     ;
+
+
+genreach_statement ::=
+               GENREACH IDENTIFIER:graphName SEMICOLON {: 
+               ParseNode pn=new ParseNode("genreach");
+               pn.addChild("graphName").addChild(graphName);
+               RESULT=pn; :}
+       ;