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) {
MethodDescriptor currmd;
TypeUtil typeutil;
- HashSet breakset;
- HashSet continueset;
+ HashSet breakset;
+ HashSet continueset;
+ FlatExit fe;
public BuildFlat(State st, TypeUtil typeutil) {
state=st;
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);
private void flattenClass(ClassDescriptor cn) {
Iterator methodit=cn.getMethods();
while(methodit.hasNext()) {
+ fe=new FlatExit();
currmd=(MethodDescriptor)methodit.next();
BlockNode bn=state.getMethodBody(currmd);
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);
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);
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);
}
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");
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) {
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) {
public static final int FlatSESEEnterNode=23;
public static final int FlatSESEExitNode=24;
public static final int FlatInstanceOfNode=25;
+ public static final int FlatExit=26;
}
this.id=identifier++;
}
+ public void rewriteUse() {
+ }
+ public void rewriteDef() {
+ }
+
/* Returns an unique identifier for this atomic enter node */
public int getIdentifier() {
public FlatAtomicExitNode(FlatAtomicEnterNode faen) {
this.faen=faen;
}
-
public FlatAtomicEnterNode getAtomicEnter() {
return faen;
}
+ public void rewriteUse() {
+ }
+ public void rewriteDef() {
+ }
public String toString() {
return "atomicexit";
public class FlatBackEdge extends FlatNode {
public FlatBackEdge() {
}
-
+ public void rewriteUse() {
+ }
+ public void rewriteDst() {
+ }
public String toString() {
return "backedge";
}
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;
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();
}
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;
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;
}
--- /dev/null
+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) {
+ }
+}
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;
}
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;
}
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;
}
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";
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;
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);
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);
+ }
+ }
+ }
}
public int kind() {
return FKind.FlatNop;
}
+ public FlatNode clone() {
+ return new FlatNop();
+ }
+ public void rewriteUse(TempMap t) {
+ }
}
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;
}
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;
}
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;
}
this.id=identifier++;
treeNode = sn;
}
-
+ public void rewriteUse() {
+ }
+ public void rewriteDef() {
+ }
public SESENode getTreeNode() {
return treeNode;
}
public FlatSESEExitNode( SESENode sn ) {
treeNode = sn;
}
-
+ public void rewriteUse() {
+ }
+ public void rewriteDef() {
+ }
public SESENode getTreeNode() {
return treeNode;
}
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;
}
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;
}