changes
authorbdemsky <bdemsky>
Fri, 3 Apr 2009 09:15:15 +0000 (09:15 +0000)
committerbdemsky <bdemsky>
Fri, 3 Apr 2009 09:15:15 +0000 (09:15 +0000)
25 files changed:
Robust/src/IR/Flat/BuildCode.java
Robust/src/IR/Flat/BuildFlat.java
Robust/src/IR/Flat/FKind.java
Robust/src/IR/Flat/FlatAtomicEnterNode.java
Robust/src/IR/Flat/FlatAtomicExitNode.java
Robust/src/IR/Flat/FlatBackEdge.java
Robust/src/IR/Flat/FlatCall.java
Robust/src/IR/Flat/FlatCastNode.java
Robust/src/IR/Flat/FlatCondBranch.java
Robust/src/IR/Flat/FlatElementNode.java
Robust/src/IR/Flat/FlatExit.java [new file with mode: 0644]
Robust/src/IR/Flat/FlatFieldNode.java
Robust/src/IR/Flat/FlatInstanceOfNode.java
Robust/src/IR/Flat/FlatLiteralNode.java
Robust/src/IR/Flat/FlatMethod.java
Robust/src/IR/Flat/FlatNew.java
Robust/src/IR/Flat/FlatNode.java
Robust/src/IR/Flat/FlatNop.java
Robust/src/IR/Flat/FlatOffsetNode.java
Robust/src/IR/Flat/FlatOpNode.java
Robust/src/IR/Flat/FlatReturnNode.java
Robust/src/IR/Flat/FlatSESEEnterNode.java
Robust/src/IR/Flat/FlatSESEExitNode.java
Robust/src/IR/Flat/FlatSetElementNode.java
Robust/src/IR/Flat/FlatSetFieldNode.java

index 4b4498856b48b3489fc3b0efd98782b6f7649800..576b3872827c1c9bd75f4e447c36004d3dfaf89a 100644 (file)
@@ -1581,6 +1581,10 @@ public class BuildCode {
       output.println("/* nop */");
       return;
 
+    case FKind.FlatExit:
+      output.println("/* exit */");
+      return;
+
     case FKind.FlatBackEdge:
       if ((state.THREAD||state.DSM)&&GENERATEPRECISEGC) {
        if(state.DSM&&locality.getAtomic(lb).get(fn).intValue()>0) {
index ff9553f4df5776db2565f30cc602fd4b59777ffb..681afda2b8be83615b8a7fd5e30bb852ed47d824 100644 (file)
@@ -9,8 +9,9 @@ public class BuildFlat {
   MethodDescriptor currmd;
   TypeUtil typeutil;
 
-    HashSet breakset;
-    HashSet continueset;
+  HashSet breakset;
+  HashSet continueset;
+  FlatExit fe;
 
   public BuildFlat(State st, TypeUtil typeutil) {
     state=st;
@@ -42,9 +43,11 @@ public class BuildFlat {
     BlockNode bn=state.getMethodBody(td);
     NodePair np=flattenBlockNode(bn);
     FlatNode fn=np.getBegin();
+    fe=new FlatExit();
     if (np.getEnd().kind()!=FKind.FlatReturnNode) {
       FlatReturnNode rnflat=new FlatReturnNode(null);
       np.getEnd().addNext(rnflat);
+      rnflat.addNext(fe);
     }
 
     FlatFlagActionNode ffan=new FlatFlagActionNode(FlatFlagActionNode.PRE);
@@ -112,6 +115,7 @@ public class BuildFlat {
   private void flattenClass(ClassDescriptor cn) {
     Iterator methodit=cn.getMethods();
     while(methodit.hasNext()) {
+      fe=new FlatExit();
       currmd=(MethodDescriptor)methodit.next();
       BlockNode bn=state.getMethodBody(currmd);
 
@@ -133,6 +137,7 @@ public class BuildFlat {
          np.getEnd().addNext(fcunlock);
          FlatReturnNode rnflat=new FlatReturnNode(null);
          fcunlock.addNext(rnflat);
+         rnflat.addNext(fe);
        }
       } else if (state.DSM&&currmd.getModifiers().isAtomic()) {
        curran.addNext(fn);
@@ -142,10 +147,12 @@ public class BuildFlat {
          np.getEnd().addNext(aen);
          FlatReturnNode rnflat=new FlatReturnNode(null);
          aen.addNext(rnflat);
+         rnflat.addNext(fe);
        }
-      } else if (np.getEnd().kind()!=FKind.FlatReturnNode) {
+      } else if (np.getEnd()!=null&&np.getEnd().kind()!=FKind.FlatReturnNode) {
        FlatReturnNode rnflat=new FlatReturnNode(null);
        np.getEnd().addNext(rnflat);
+       rnflat.addNext(fe);
       }
 
       FlatMethod fm=new FlatMethod(currmd);
@@ -961,7 +968,8 @@ public class BuildFlat {
       FlatNop nopend=new FlatNop();
       FlatBackEdge backedge=new FlatBackEdge();
 
-      body.getEnd().addNext(condition.getBegin());
+      if (body.getEnd()!=null)
+       body.getEnd().addNext(condition.getBegin());
       condition.getEnd().addNext(fcb);
       fcb.addFalseNext(nopend);
       fcb.addTrueNext(backedge);
@@ -992,6 +1000,7 @@ public class BuildFlat {
     }
 
     FlatReturnNode rnflat=new FlatReturnNode(retval);
+    rnflat.addNext(fe);
     FlatNode ln=rnflat;
     if (state.THREAD&&currmd.getModifiers().isSynchronized()) {
       MethodDescriptor memd=(MethodDescriptor)typeutil.getClass("Object").getMethodTable().get("MonitorExit");
@@ -1008,9 +1017,9 @@ public class BuildFlat {
 
     if (cond!=null) {
       cond.getEnd().addNext(ln);
-      return new NodePair(cond.getBegin(),rnflat);
+      return new NodePair(cond.getBegin(),null);
     } else
-      return new NodePair(ln,rnflat);
+      return new NodePair(ln,null);
   }
 
   private NodePair flattenTaskExitNode(TaskExitNode ten) {
@@ -1020,8 +1029,9 @@ public class BuildFlat {
     NodePair fcn=flattenConstraintCheck(ten.getChecks());
     ffan.addNext(fcn.getBegin());
     FlatReturnNode rnflat=new FlatReturnNode(null);
+    rnflat.addNext(fe);
     fcn.getEnd().addNext(rnflat);
-    return new NodePair(ffan, rnflat);
+    return new NodePair(ffan, null);
   }
 
   private NodePair flattenConstraintCheck(Vector ccs) {
index 467337a53abee2901de5ebd5bdbca34451802b0a..58f81158a11ff971ff03fd39bddb5acda60d6c70 100644 (file)
@@ -26,4 +26,5 @@ public class FKind {
   public static final int FlatSESEEnterNode=23;
   public static final int FlatSESEExitNode=24;
   public static final int FlatInstanceOfNode=25;
+  public static final int FlatExit=26;
 }
index b1426437304432f7bbbcd6c529b63577720a421f..a58cfcd1ff3384d5869f9d4031a6baf1640e2b7e 100644 (file)
@@ -10,6 +10,11 @@ public class FlatAtomicEnterNode extends FlatNode {
     this.id=identifier++;
   }
 
+  public void rewriteUse() {
+  }
+  public void rewriteDef() {
+  }
+
   /* Returns an unique identifier for this atomic enter node */
 
   public int getIdentifier() {
index d8c109528a10e80c098e3e4af1ca3d7c4825feca..edcb93b4dd605a6ac613ecb60bda7f364deb9e06 100644 (file)
@@ -6,10 +6,13 @@ public class FlatAtomicExitNode extends FlatNode {
   public FlatAtomicExitNode(FlatAtomicEnterNode faen) {
     this.faen=faen;
   }
-
   public FlatAtomicEnterNode getAtomicEnter() {
     return faen;
   }
+  public void rewriteUse() {
+  }
+  public void rewriteDef() {
+  }
 
   public String toString() {
     return "atomicexit";
index cca91b29b4e74937cbf250b5da65ab75e5886c44..e6905cfe9a2e9433e581521100c9af6052e8faa4 100644 (file)
@@ -4,7 +4,10 @@ import java.util.Vector;
 public class FlatBackEdge extends FlatNode {
   public FlatBackEdge() {
   }
-
+  public void rewriteUse() {
+  }
+  public void rewriteDst() {
+  }
   public String toString() {
     return "backedge";
   }
index 8b18abe67c98a4d328b61010e8403fdda8cd6db8..f8a5d39e7bc18dbd8838b9976f3332efbf060fe4 100644 (file)
@@ -13,6 +13,22 @@ public class FlatCall extends FlatNode {
     this.this_temp=this_temp;
     this.args=args;
   }
+  public void rewriteUse(TempMap t) {
+    for(int i=0;i<args.length;i++)
+      args[i]=t.tempMap(args[i]);
+    this_temp=t.tempMap(this_temp);
+  }
+  public void rewriteDef(TempMap t) {
+    dst=t.tempMap(dst);
+  }
+  public FlatNode clone(TempMap t) {
+    TempDescriptor ndst=t.tempMap(dst);
+    TempDescriptor nthis=t.tempMap(this_temp);
+    TempDescriptor[] nargs=new TempDescriptor[args.length];
+    for(int i=0;i<nargs.length;i++)
+      nargs[i]=t.tempMap(args[i]);
+    return new FlatCall(method, ndst, nthis, nargs);
+  }
 
   public MethodDescriptor getMethod() {
     return method;
index 73f5a6eb2efbfd1290fe790ae5cf7778563253e8..ee10d4d31dd8afdb370e7e847f4f9e222967839e 100644 (file)
@@ -12,6 +12,16 @@ public class FlatCastNode extends FlatNode {
     this.dst=dst;
   }
 
+  public FlatNode clone(TempMap t) {
+    return new FlatCastNode(type, t.tempMap(src), t.tempMap(dst));
+  }
+  public void rewriteUse(TempMap t) {
+    src=t.tempMap(src);
+  }
+  public void rewriteDef(TempMap t) {
+    dst=t.tempMap(dst);
+  }
+
   public String toString() {
     return "FlatCastNode_"+dst.toString()+"=("+type.toString()+")"+src.toString();
   }
index b481a5e241c8517979cb0ff9dcd83370a97c99ad..34b0d9038400b1fe6211daf3e95206c8d30e7d14 100644 (file)
@@ -9,6 +9,18 @@ public class FlatCondBranch extends FlatNode {
   public FlatCondBranch(TempDescriptor td) {
     test_cond=td;
   }
+  public void rewriteDef(TempMap t) {
+  }
+  public void rewriteUse(TempMap t) {
+    test_cond=t.tempMap(test_cond);
+  }
+
+  public FlatNode clone(TempMap t) {
+    FlatCondBranch fcb=new FlatCondBranch(t.tempMap(test_cond));
+    fcb.trueprob=trueprob;
+    fcb.loop=loop;
+    return fcb;
+  }
 
   public void setLoop() {
     loop=true;
index 2e42d744273c9dbec8ee48a806f58e20dd1ecb9a..9eee5eea2b76be48dcd0d912c335ba455a729f66 100644 (file)
@@ -16,6 +16,17 @@ public class FlatElementNode extends FlatNode {
     return true;
   }
 
+  public FlatNode clone(TempMap t) {
+    return new FlatElementNode(t.tempMap(src), t.tempMap(index), t.tempMap(dst));
+  }
+  public void rewriteDef(TempMap t) {
+    dst=t.tempMap(dst);
+  }
+  public void rewriteUse(TempMap t) {
+    index=t.tempMap(index);
+    src=t.tempMap(src);
+  }
+
   public TempDescriptor getIndex() {
     return index;
   }
diff --git a/Robust/src/IR/Flat/FlatExit.java b/Robust/src/IR/Flat/FlatExit.java
new file mode 100644 (file)
index 0000000..1102c5b
--- /dev/null
@@ -0,0 +1,22 @@
+package IR.Flat;
+import java.util.Vector;
+
+public class FlatExit extends FlatNode {
+  public FlatExit() {
+  }
+
+  public String toString() {
+    return "exit";
+  }
+
+  public int kind() {
+    return FKind.FlatExit;
+  }
+  public FlatNode clone() {
+    return new FlatExit();
+  }
+  public void rewriteUse(TempMap t) {
+  }
+  public void rewriteDst(TempMap t) {
+  }
+}
index 60462df9e15aa516b3bbe9a74ffe777f21cd86bb..d74d8582745955c8fd755b07a006113eea46be56 100644 (file)
@@ -12,6 +12,16 @@ public class FlatFieldNode extends FlatNode {
     this.dst=dst;
   }
 
+  public FlatNode clone(TempMap t) {
+    return new FlatFieldNode(field, t.tempMap(src), t.tempMap(dst));
+  }
+  public void rewriteUse(TempMap t) {
+    src=t.tempMap(src);
+  }
+  public void rewriteDef(TempMap t) {
+    dst=t.tempMap(dst);
+  }
+
   public FieldDescriptor getField() {
     return field;
   }
index 8389bea6a0885f3691e166348f41023f1b1d59f9..0cc70f73eb7bd85ccee6c1e13526e6ad1fbd9a0b 100644 (file)
@@ -12,6 +12,15 @@ public class FlatInstanceOfNode extends FlatNode {
     this.dst=dst;
   }
 
+  public FlatNode clone(TempMap m) {
+    return new FlatInstanceOfNode(t, m.tempMap(src), m.tempMap(dst));
+  }
+  public void rewriteUse(TempMap t) {
+    src=t.tempMap(src);
+  }
+  public void rewriteDef(TempMap t) {
+    dst=t.tempMap(dst);
+  }
   public TypeDescriptor getType() {
     return t;
   }
index fba83bfb14ef7caa60087a1b03370f1274de19b2..a141ebdfdcb261167bd7ff20df44af659aad52d7 100644 (file)
@@ -12,6 +12,14 @@ public class FlatLiteralNode extends FlatNode {
     this.dst=dst;
   }
 
+  public FlatNode clone(TempMap t) {
+    return new FlatLiteralNode(type, value, t.tempMap(dst));
+  }
+  public void rewriteUse(TempMap t) {
+  }
+  public void rewriteDst(TempMap t) {
+    dst=t.tempMap(dst);
+  }
   public TypeDescriptor getType() {
     return type;
   }
index 4955f28ae5b99ef8556bb28bcc12bb27c5131d83..0cd5e7b2e71fff70cc56a16ff68dd65a6109fcab 100644 (file)
@@ -141,10 +141,18 @@ public class FlatMethod extends FlatNode {
       if (current_node==null) {
        current_node=(FlatNode)tovisit.iterator().next();
        tovisit.remove(current_node);
+      } else {
+       if (tovisit.contains(current_node))
+         tovisit.remove(current_node);
       }
       visited.add(current_node);
-      if (nodetolabel.containsKey(current_node))
+      if (nodetolabel.containsKey(current_node)) {
        st+="L"+nodetolabel.get(current_node)+":\n";
+       for(int i=0;i<current_node.numPrev();i++) {
+         st+="i="+i+" "+current_node.getPrev(i);
+       }
+       st+="\n";
+      }
       if (current_node.numNext()==0) {
        if (map==null)
          st+="   "+current_node.toString()+"\n";
index 5061607590cb79fd37424fb3aa1236e958323218..27e9a935565674cb134904fdadafd00576dd1ce7 100644 (file)
@@ -16,6 +16,17 @@ public class FlatNew extends FlatNode {
     this.disjointId=null;
   }
 
+  public void rewriteUse(TempMap t) {
+    size=t.tempMap(size);
+  }
+  public void rewriteDef(TempMap t) {
+    dst=t.tempMap(dst);
+  }
+
+  public FlatNode clone(TempMap t) {
+    return new FlatNew(type, t.tempMap(dst), t.tempMap(size), isglobal, disjointId);
+  }
+
   public FlatNew(TypeDescriptor type, TempDescriptor dst, boolean isglobal, String disjointId) {
     this.type=type;
     this.dst=dst;
index 57dcb73645cc3ebd914cebcba8971320e61d1fe2..7f82c2d70875764237585b72e1b63cb91d84da8c 100644 (file)
@@ -26,12 +26,13 @@ public class FlatNode {
   public FlatNode getPrev(int i) {
     return (FlatNode) prev.get(i);
   }
-
   public void addNext(FlatNode n) {
     next.add(n);
     n.addPrev(this);
   }
-
+  public void removePrev(FlatNode n) {
+    prev.remove(n);
+  }
   /** This function modifies the graph */
   public void setNext(int i, FlatNode n) {
     FlatNode old=getNext(i);
@@ -39,19 +40,60 @@ public class FlatNode {
     old.prev.remove(this);
     n.addPrev(this);
   }
-
-  protected void addPrev(FlatNode p) {
+  /** This function modifies the graph */
+  public void setprev(int i, FlatNode n) {
+    prev.set(i, n);
+  }
+  /** This function modifies the graph */
+  public void setnext(int i, FlatNode n) {
+    next.set(i, n);
+  }
+  public void addPrev(FlatNode p) {
     prev.add(p);
   }
   public int kind() {
     throw new Error();
   }
-
   public TempDescriptor [] readsTemps() {
     return new TempDescriptor[0];
   }
-
   public TempDescriptor [] writesTemps() {
     return new TempDescriptor[0];
   }
+  public FlatNode clone(TempMap t) {
+    throw new Error();
+  }
+
+  public void rewriteUse(TempMap t) {
+    System.out.println(toString());
+    throw new Error();
+  }
+
+  public void rewriteDef(TempMap t) {
+    System.out.println(toString());
+    throw new Error();
+  }
+
+  public void replace(FlatNode fnnew) {
+    fnnew.prev.setSize(prev.size());
+    fnnew.next.setSize(next.size());
+    for(int i=0;i<prev.size();i++) {
+      FlatNode nprev=(FlatNode)prev.get(i);
+      fnnew.prev.set(i,nprev);
+      for(int j=0;j<nprev.numNext();j++) {
+       FlatNode n=nprev.getNext(j);
+       if (n==this)
+         nprev.next.set(j, fnnew);
+      }
+    }
+    for(int i=0;i<next.size();i++) {
+      FlatNode nnext=(FlatNode)next.get(i);
+      fnnew.next.set(i,nnext);;
+      for(int j=0;j<nnext.numPrev();j++) {
+       FlatNode n=nnext.getPrev(j);
+       if (n==this)
+         nnext.prev.set(j, fnnew);
+      }
+    }
+  }
 }
index fdcab4edf95fb088cc6c0fc6e8726d5a144f7ae5..7b79dac3f73785b253be0a1ae283a3321f15455a 100644 (file)
@@ -12,4 +12,9 @@ public class FlatNop extends FlatNode {
   public int kind() {
     return FKind.FlatNop;
   }
+  public FlatNode clone() {
+    return new FlatNop();
+  }
+  public void rewriteUse(TempMap t) {
+  }
 }
index e9c61db2c5ebaf0c4f545b8aa22f22192cbf9d15..7fa88996ca56d6cd0d1f283a6a26bd5368732e88 100644 (file)
@@ -13,6 +13,14 @@ public class FlatOffsetNode extends FlatNode {
     this.dst = dst;
   }
 
+  public FlatNode clone(TempMap t) {
+    return new FlatOffsetNode(baseclass, field, t.tempMap(dst));
+  }
+  public void rewriteUse(TempMap t) {
+  }
+  public void rewriteDef(TempMap t) {
+    dst=t.tempMap(dst);
+  }
   public TypeDescriptor getClassType() {
     return baseclass;
   }
index ade5931508cec0ec394718b9283e3b74135fb700..87d13521e32ddd091570da7f22df59200e989688 100644 (file)
@@ -15,6 +15,17 @@ public class FlatOpNode extends FlatNode {
     this.op=op;
   }
 
+  public FlatNode clone(TempMap t) {
+    return new FlatOpNode(t.tempMap(dest), t.tempMap(left), t.tempMap(right), op);
+  }
+  public void rewriteDef(TempMap t) {
+    dest=t.tempMap(dest);
+  }
+  public void rewriteUse(TempMap t) {
+    left=t.tempMap(left);
+    right=t.tempMap(right);
+  }
+
   public TempDescriptor getDest() {
     return dest;
   }
index f90fd7512e2ace0cd1dc88de901ff7ca18aabba3..bc98ba5549e2ef56f325b80b10dcae6c34e4470a 100644 (file)
@@ -7,6 +7,14 @@ public class FlatReturnNode extends FlatNode {
     this.tempdesc=td;
   }
 
+  public FlatNode clone(TempMap t) {
+    return new FlatReturnNode(t.tempMap(tempdesc));
+  }
+  public void rewriteUse(TempMap t) {
+    tempdesc=t.tempMap(tempdesc);
+  }
+  public void rewriteDef(TempMap t) {
+  }
   public String toString() {
     return "FlatReturnNode_return "+tempdesc;
   }
index 15a1606ff5933676e6b56babc1e2e94ba71306bf..7c521a3deb4705da201721a8216247bc21635860 100644 (file)
@@ -12,7 +12,10 @@ public class FlatSESEEnterNode extends FlatNode {
     this.id=identifier++;
     treeNode = sn;    
   }
-
+  public void rewriteUse() {
+  }
+  public void rewriteDef() {
+  }
   public SESENode getTreeNode() {
     return treeNode;
   }
index bcfd0451ff32b0f158bef59fb671486feba9a945..eb77cbcebbc6962640d87daba42987c9477e68ec 100644 (file)
@@ -9,7 +9,10 @@ public class FlatSESEExitNode extends FlatNode {
   public FlatSESEExitNode( SESENode sn ) {
     treeNode = sn;
   }
-
+  public void rewriteUse() {
+  }
+  public void rewriteDef() {
+  }
   public SESENode getTreeNode() {
     return treeNode;
   }
index 6dd4a6245f9d7cbb871017def89429f949e1f490..3fdfb0850598f5fccc82b4c1730e55031fd0d509 100644 (file)
@@ -12,6 +12,16 @@ public class FlatSetElementNode extends FlatNode {
     this.dst=dst;
   }
 
+  public FlatNode clone(TempMap t) {
+    return new FlatSetElementNode(t.tempMap(dst), t.tempMap(index), t.tempMap(src));
+  }
+  public void rewriteUse(TempMap t) {
+    src=t.tempMap(src);
+    dst=t.tempMap(dst);
+    index=t.tempMap(index);
+  }
+  public void rewriteDef(TempMap t) {
+  }
   public boolean needsBoundsCheck() {
     return true;
   }
index 50e834ed5dcb6e1a885be1a5dbfa168a886b799e..f57d69e18203b4d30892cb40b6ccdc9b6805aaf1 100644 (file)
@@ -12,6 +12,15 @@ public class FlatSetFieldNode extends FlatNode {
     this.dst=dst;
   }
 
+  public FlatNode clone(TempMap t) {
+    return new FlatSetFieldNode(t.tempMap(dst), field, t.tempMap(src));
+  }
+  public void rewriteUse(TempMap t) {
+    dst=t.tempMap(dst);
+    src=t.tempMap(src);
+  }
+  public void rewriteDef(TempMap t) {
+  }
   public TempDescriptor getSrc() {
     return src;
   }