Add beginning of support for dsm
authorbdemsky <bdemsky>
Thu, 26 Jul 2007 06:43:55 +0000 (06:43 +0000)
committerbdemsky <bdemsky>
Thu, 26 Jul 2007 06:43:55 +0000 (06:43 +0000)
12 files changed:
Robust/src/Analysis/Locality/LocalityAnalysis.java
Robust/src/Analysis/Locality/LocalityBinding.java
Robust/src/IR/Flat/BuildFlat.java
Robust/src/IR/Flat/FKind.java
Robust/src/IR/Flat/FlatAtomicEnterNode.java [new file with mode: 0644]
Robust/src/IR/Flat/FlatAtomicExitNode.java [new file with mode: 0644]
Robust/src/IR/Flat/FlatNew.java
Robust/src/IR/Flat/FlatOpNode.java
Robust/src/IR/State.java
Robust/src/IR/Tree/SemanticCheck.java
Robust/src/Main/Main.java
Robust/src/Makefile

index 8d74ae3935be8de645cbe1b2cc298510adc94bf3..3f2bcb97629e6da793b0a620e4c72647073e51cb 100644 (file)
@@ -9,6 +9,7 @@ import java.util.Arrays;
 import Analysis.CallGraph.CallGraph;
 import IR.SymbolTable;
 import IR.State;
+import IR.TypeUtil;
 import IR.MethodDescriptor;
 import IR.Flat.*;
 
@@ -39,30 +40,32 @@ public class LocalityAnalysis {
     }
     
     private void computeLocalityBindings() {
-       LocalityBinding lb=new LocalityBinding(typeutil.getMain(), false);
-       tovisit.add(lb);
-       discovered.put(lb, lb);
+       LocalityBinding lbmain=new LocalityBinding(typeutil.getMain(), false);
+       tovisit.add(lbmain);
+       discovered.put(lbmain, lbmain);
 
        while(!tovisit.empty()) {
            LocalityBinding lb=(LocalityBinding) tovisit.pop();
            MethodDescriptor md=lb.getMethod();
-           computeCallsFlags(md, lb);
+           Hashtable<FlatNode,Hashtable<TempDescriptor, Integer>> temptable=new Hashtable<FlatNode,Hashtable<TempDescriptor, Integer>>();
+           Hashtable<FlatNode, Integer> atomictable=new Hashtable<FlatNode, Integer>();
+           computeCallsFlags(md, lb, temptable, atomictable);
        }
     }
     
-    public Hashtable<FlatNode, Hashtable<TempDescriptor,Integer>> computeCallsFlags(MethodDescriptor md, LocalityBinding lb) {
+    public void computeCallsFlags(MethodDescriptor md, LocalityBinding lb, Hashtable<FlatNode, Hashtable<TempDescriptor, Integer>> temptable, Hashtable<FlatNode, Integer> atomictable) {
        FlatMethod fm=state.getMethodFlat(md);
        HashSet<FlatNode> tovisit=new HashSet<FlatNode>();
-       Hashtable<FlatNode,Hashtable<TempDescriptor, Integer>> temptable=new Hashtable<FlatNode,Hashtable<TempDescriptor, Integer>>();
        tovisit.add(fm.getNext(0));
        
        {
            // Build table for initial node
            Hashtable<TempDescriptor,Integer> table=new Hashtable<TempDescriptor,Integer>();
            temptable.put(fm, table);
+           atomictable.put(fm, lb.isAtomic()?1:0);
            for(int i=0;i<fm.numParameters();i++) {
                TempDescriptor temp=fm.getParameter(i);
-               b=lb.isGlobal(i);
+               Integer b=lb.isGlobal(i);
                table.put(temp,b);
            }
        }
@@ -70,8 +73,12 @@ public class LocalityAnalysis {
        while(!tovisit.isEmpty()) {
            FlatNode fn=tovisit.iterator().next();
            Hashtable<TempDescriptor, Integer> currtable=new Hashtable<TempDescriptor, Integer>();
+           int atomicstate=0;
            for(int i=0;i<fn.numPrev();i++) {
                FlatNode prevnode=fn.getPrev(i);
+               if (atomictable.containsKey(prevnode)) {
+                   atomicstate=atomictable.get(prevnode).intValue();
+               }
                if (!temptable.containsKey(prevnode))
                    continue;
                Hashtable<TempDescriptor, Integer> prevtable=temptable.get(prevnode);
@@ -83,49 +90,55 @@ public class LocalityAnalysis {
                    currtable.put(temp, newint);
                }
            }
+           atomictable.put(fn, atomicstate);
            // Process this node
            switch(fn.kind()) {
-           case FlatCall:
-               processCall(md, (FlatCall)fn, currtable);
+           case FKind.FlatAtomicEnterNode:
+               processAtomicEnterNode((FlatAtomicEnterNode)fn, atomictable);
+               break;
+           case FKind.FlatAtomicExitNode:
+               processAtomicExitNode((FlatAtomicExitNode)fn, atomictable);
+               break;
+           case FKind.FlatCall:
+               processCall(lb, (FlatCall)fn, currtable, isAtomic(atomictable, fn));
                break;
-           case FlatFieldNode:
-               processFieldNode((FlatFieldNode)fn, currtable);
+           case FKind.FlatFieldNode:
+               processFieldNode((FlatFieldNode)fn, isAtomic(atomictable, fn), currtable);
                break;
-           case FlatSetFieldNode:
-               processSetFieldNode((FlatSetFieldNode)fn, currtable);
+           case FKind.FlatSetFieldNode:
+               processSetFieldNode((FlatSetFieldNode)fn, isAtomic(atomictable,fn), currtable);
                break;
-           case FlatNew:
-               processNew((FlatNew)fn, currtable);
+           case FKind.FlatNew:
+               processNew((FlatNew)fn, isAtomic(atomictable, fn), currtable);
                break;
-           case FlatOpNode:
+           case FKind.FlatOpNode:
                processOpNode((FlatOpNode)fn, currtable);
                break;
-           case FlatCastNode:
+           case FKind.FlatCastNode:
                processCastNode((FlatCastNode)fn, currtable);
                break;
-           case FlatLiteralNode:
+           case FKind.FlatLiteralNode:
                processLiteralNode((FlatLiteralNode)fn, currtable);
                break;
-           case FlatReturnNode:
-               processReturnNode((FlatReturnNode)fn, currtable);
+           case FKind.FlatReturnNode:
+               processReturnNode(lb, (FlatReturnNode)fn, currtable);
                break;
-           case FlatSetElementNode:
-               processSetElement((FlatSetElementNode)fn, currtable);
+           case FKind.FlatSetElementNode:
+               processSetElementNode((FlatSetElementNode)fn, currtable, isAtomic(atomictable, fn));
                break;
-           case FlatElementNode:
-               processElement((FlatElementNode)fn, currtable);
+           case FKind.FlatElementNode:
+               processElementNode((FlatElementNode)fn, currtable, isAtomic(atomictable, fn));
                break;
-
-           case FlatCondBranch:
-           case FlatBackEdge:
-           case FlatNop:
+           case FKind.FlatCondBranch:
+           case FKind.FlatBackEdge:
+           case FKind.FlatNop:
                //No action needed for these
                break;
-           case FlatFlagActionNode:
-           case FlatCheckNode:
-           case FlatTagDeclaration:
+           case FKind.FlatFlagActionNode:
+           case FKind.FlatCheckNode:
+           case FKind.FlatTagDeclaration:
                throw new Error("Incompatible with tasks!");
-           case FlatMethod:
+           case FKind.FlatMethod:
            default:
                throw new Error();
            }
@@ -134,12 +147,16 @@ public class LocalityAnalysis {
                // Update table for this node
                temptable.put(fn, currtable);
                for(int i=0;i<fn.numNext();i++) {
-                   tovisit.add(fn.next(i));
+                   tovisit.add(fn.getNext(i));
                }
            }
        }
     }
 
+    private static boolean isAtomic(Hashtable<FlatNode, Integer> atomictable, FlatNode fn) {
+       return atomictable.get(fn).intValue()>0;
+    }
+
     private static Integer merge(Integer a, Integer b) {
        if (a==null||a.equals(EITHER))
            return b;
@@ -150,14 +167,14 @@ public class LocalityAnalysis {
        return CONFLICT;
     }
        
-    void processCall(LocalityBinding currlb, FlatCall fc, boolean transaction, Hashtable<TempDescriptor, Integer> currtable) {
+    void processCall(LocalityBinding currlb, FlatCall fc, Hashtable<TempDescriptor, Integer> currtable, boolean isatomic) {
        MethodDescriptor nodemd=fc.getMethod();
        Set methodset=fc.getThis()==null?callgraph.getMethods(nodemd):
            callgraph.getMethods(nodemd, fc.getThis().getType());
        Integer currreturnval=null;
        for(Iterator methodit=methodset.iterator();methodit.hasNext();) {
            MethodDescriptor md=(MethodDescriptor) methodit.next();
-           LocalityBinding lb=new LocalityBinding(md, transaction);
+           LocalityBinding lb=new LocalityBinding(md, isatomic);
            for(int i=0;i<fc.numArgs();i++) {
                TempDescriptor arg=fc.getArg(i);
                lb.setGlobal(i,currtable.get(arg));
@@ -166,7 +183,7 @@ public class LocalityAnalysis {
                Integer thistype=currtable.get(fc.getThis());
                if(thistype.equals(CONFLICT))
                    throw new Error("Using type that can be either local or global");
-               if(thistype.equals(GLOBAL)&&!transaction)
+               if(thistype.equals(GLOBAL)&&!isatomic)
                    throw new Error("Using global object outside of transaction");
                lb.setGlobalThis(thistype);
            } else
@@ -185,7 +202,7 @@ public class LocalityAnalysis {
        currtable.put(fc.getReturnTemp(), currreturnval);
     }
 
-    void processFieldNode(LocalityBinding lb, FlatFieldNode ffn, boolean transaction, Hashtable<TempDescriptor, Integer> currtable) {
+    void processFieldNode(FlatFieldNode ffn, boolean transaction, Hashtable<TempDescriptor, Integer> currtable) {
        Integer type=currtable.get(ffn.getSrc());
        TempDescriptor dst=ffn.getDst();
        if (type.equals(LOCAL)) {
@@ -195,7 +212,7 @@ public class LocalityAnalysis {
                currtable.put(dst,LOCAL);                   
        } else if (type.equals(GLOBAL)) {
            if (!transaction)
-               throw Error("Global access outside of a transaction");
+               throw new Error("Global access outside of a transaction");
            if (ffn.getField().getType().isPrimitive())
                currtable.put(dst, LOCAL); // primitives are local
            else
@@ -211,12 +228,12 @@ public class LocalityAnalysis {
     }
 
     //need to handle primitives
-    void processSetFieldNode(LocalityBinding lb, FlatSetFieldNode fsfn, boolean transaction, Hashtable<TempDescriptor, Integer> currtable) {
-       Integer srctype=currtable.get(ffn.getSrc());
-       Integer dsttype=currtable.get(ffn.getDst());
+    void processSetFieldNode(FlatSetFieldNode fsfn, boolean transaction, Hashtable<TempDescriptor, Integer> currtable) {
+       Integer srctype=currtable.get(fsfn.getSrc());
+       Integer dsttype=currtable.get(fsfn.getDst());
 
        if (dsttype.equals(LOCAL)) {
-           if (ffn.getField().isGlobal()) {
+           if (fsfn.getField().isGlobal()) {
                if (!(srctype.equals(GLOBAL)||srctype.equals(EITHER)))
                    throw new Error("Writing possible local reference to global field");
            } else {
@@ -225,7 +242,7 @@ public class LocalityAnalysis {
            }
        } else if (dsttype.equals(GLOBAL)) {
            if (!transaction)
-               throw Error("Global access outside of a transaction");
+               throw new Error("Global access outside of a transaction");
            //okay to store primitives in global object
            if (srctype.equals(LOCAL) && fsfn.getField().getType().isPrimitive())
                return;
@@ -239,7 +256,7 @@ public class LocalityAnalysis {
        }
     }
 
-    void processNew(LocalityBinding lb, FlatNew fn, boolean transaction, Hashtable<TempDescriptor, Integer> currtable) {
+    void processNew(FlatNew fn, boolean transaction, Hashtable<TempDescriptor, Integer> currtable) {
        if (fn.isGlobal()&&!transaction) {
            throw new Error("Allocating global object outside of transaction");
        }
@@ -255,7 +272,7 @@ public class LocalityAnalysis {
     }
 
     void processCastNode(FlatCastNode fcn, Hashtable<TempDescriptor, Integer> currtable) {
-       currtable.put(fon.getDest(), currtable.get(fon.getSrc()));
+       currtable.put(fcn.getDst(), currtable.get(fcn.getSrc()));
     }
 
     void processLiteralNode(FlatLiteralNode fln, Hashtable<TempDescriptor, Integer> currtable) {
@@ -273,7 +290,7 @@ public class LocalityAnalysis {
        }
     }
 
-    void processSetElementNode(FlatSetElementNode fsen, Hashtable<TempDescriptor, Integer> currtable) {
+    void processSetElementNode(FlatSetElementNode fsen, Hashtable<TempDescriptor, Integer> currtable, boolean isatomic) {
        Integer srctype=currtable.get(fsen.getSrc());
        Integer dsttype=currtable.get(fsen.getDst());
 
@@ -283,8 +300,8 @@ public class LocalityAnalysis {
        } else if (dsttype.equals(GLOBAL)) {
            if (!(srctype.equals(GLOBAL)||srctype.equals(EITHER)))
                throw new Error("Writing possible local reference to global object");
-           if (!transaction)
-               throw Error("Global access outside of a transaction");
+           if (!isatomic)
+               throw new Error("Global access outside of a transaction");
        } else if (dsttype.equals(EITHER)) {
            if (srctype.equals(CONFLICT))
                throw new Error("Using reference that could be local or global");
@@ -293,14 +310,14 @@ public class LocalityAnalysis {
        }
     }
 
-    void processElementNode(FlatElementNode fen, Hashtable<TempDescriptor, Integer> currtable) {
+    void processElementNode(FlatElementNode fen, Hashtable<TempDescriptor, Integer> currtable, boolean isatomic) {
        Integer type=currtable.get(fen.getSrc());
        TempDescriptor dst=fen.getDst();
        if (type.equals(LOCAL)) {
            currtable.put(dst,LOCAL);               
        } else if (type.equals(GLOBAL)) {
-           if (!transaction)
-               throw Error("Global access outside of a transaction");
+           if (!isatomic)
+               throw new Error("Global access outside of a transaction");
            currtable.put(dst, GLOBAL);
        } else if (type.equals(EITHER)) {
            currtable.put(dst, EITHER);
@@ -308,4 +325,13 @@ public class LocalityAnalysis {
            throw new Error("Access to object that could be either global or local");
        }
     }
+    void processAtomicEnterNode(FlatAtomicEnterNode fen, Hashtable<FlatNode, Integer> atomictable) {
+       int atomic=atomictable.get(fen).intValue();
+       atomictable.put(fen, new Integer(atomic+1));
+    }
+    
+    void processAtomicExitNode(FlatAtomicExitNode fen, Hashtable<FlatNode, Integer> atomictable) {
+       int atomic=atomictable.get(fen).intValue();
+       atomictable.put(fen, new Integer(atomic-1));
+    }
 }
index 5df96d9e3d04015862597d447916af81c9a45bc1..b89a46b151a738416ca28ceab1c8f2d93ddc97f3 100644 (file)
@@ -4,23 +4,27 @@ import IR.MethodDescriptor;
 public class LocalityBinding {
     private MethodDescriptor md;
     private Integer[] isglobal;
-    private boolean istransaction;
+    private boolean isatomic;
     private Integer isglobalreturn;
     private Integer isglobalthis;
 
-    public LocalityBinding(MethodDescriptor md, boolean transaction) {
+    public LocalityBinding(MethodDescriptor md, boolean atomic) {
        this.md=md;
-       isglobal=new boolean[md.numParameters()];
-       istransaction=transaction;
+       isglobal=new Integer[md.numParameters()];
+       isatomic=atomic;
     }
 
     public String toString() {
        String st=md.toString()+" ";
        for(int i=0;i<isglobal.length;i++)
-           if (isglobal[i])
-               st+="global ";
-           else
+           if (isglobal[i].equals(LocalityAnalysis.LOCAL))
                st+="local ";
+           else if (isglobal[i].equals(LocalityAnalysis.GLOBAL))
+               st+="global ";
+           else if (isglobal[i].equals(LocalityAnalysis.EITHER))
+               st+="either ";
+           else if (isglobal[i].equals(LocalityAnalysis.CONFLICT))
+               st+="conflict ";
        return st;
     }
 
@@ -52,8 +56,8 @@ public class LocalityBinding {
        return md;
     }
 
-    public boolean isTransaction() {
-       return istransaction;
+    public boolean isAtomic() {
+       return isatomic;
     }
 
     public boolean equals(Object o) {
@@ -66,7 +70,7 @@ public class LocalityBinding {
                    return false;
            if (!isglobalthis.equals(lb.isglobalthis))
                return false;
-           return !istransaction.equals(lb.istransaction);
+           return (isatomic==lb.isatomic);
        }
        return false;
     }
@@ -74,9 +78,9 @@ public class LocalityBinding {
     public int hashCode() {
        int hashcode=md.hashCode();
        for(int i=0;i<isglobal.length;i++) {
-           hashcode=hashcode*31+(isglobal[i]?0:1);
+           hashcode=hashcode*31+(isglobal[i].intValue());
        }
-       hashcode=hashcode*31+(istransaction?0:1);
+       hashcode=hashcode*31+(isatomic?1:0);
        return hashcode;
     }
 }
index e35799a131d831a2f0002b9254eb1ed43d722169..be735ffa9bed702a094d7838daab5596e928fdcb 100644 (file)
@@ -122,6 +122,16 @@ public class BuildFlat {
                    FlatReturnNode rnflat=new FlatReturnNode(null);
                    fcunlock.addNext(rnflat);
                }
+           } else if (state.DSM&&currmd.getModifiers().isAtomic()) {
+               FlatAtomicEnterNode an=new FlatAtomicEnterNode();
+               an.addNext(fn);
+               fn=an;
+               if (np.getEnd().kind()!=FKind.FlatReturnNode) {
+                   FlatAtomicExitNode aen=new FlatAtomicExitNode();
+                   np.getEnd().addNext(aen);
+                   FlatReturnNode rnflat=new FlatReturnNode(null);
+                   aen.addNext(rnflat);
+               }
            } else if (np.getEnd().kind()!=FKind.FlatReturnNode) {
                FlatReturnNode rnflat=new FlatReturnNode(null);
                np.getEnd().addNext(rnflat);
@@ -182,7 +192,7 @@ public class BuildFlat {
     private NodePair flattenCreateObjectNode(CreateObjectNode con,TempDescriptor out_temp) {
        TypeDescriptor td=con.getType();
        if (!td.isArray()) {
-           FlatNew fn=new FlatNew(td, out_temp);
+           FlatNew fn=new FlatNew(td, out_temp, con.isGlobal());
            TempDescriptor[] temps=new TempDescriptor[con.numArgs()];
            FlatNode last=fn;
            if (td.getClassDesc().hasFlags()) {
@@ -241,10 +251,10 @@ public class BuildFlat {
                    out_temp:
                TempDescriptor.tempFactory("arg",en.getType());
            }
-           FlatNew fn=new FlatNew(td, out_temp, temps[0]);
+           FlatNew fn=new FlatNew(td, out_temp, temps[0], con.isGlobal());
            last.addNext(fn);
            if (temps.length>1) {
-               NodePair np=generateNewArrayLoop(temps, td.dereference(), out_temp, 0);
+               NodePair np=generateNewArrayLoop(temps, td.dereference(), out_temp, 0, con.isGlobal());
                fn.addNext(np.getBegin());
                return new NodePair(first,np.getEnd()); 
            } else
@@ -252,7 +262,7 @@ public class BuildFlat {
        }
     }
 
-    private NodePair generateNewArrayLoop(TempDescriptor[] temparray, TypeDescriptor td, TempDescriptor tmp, int i) {
+    private NodePair generateNewArrayLoop(TempDescriptor[] temparray, TypeDescriptor td, TempDescriptor tmp, int i, boolean isglobal) {
        TempDescriptor index=TempDescriptor.tempFactory("index",new TypeDescriptor(TypeDescriptor.INT));
        TempDescriptor tmpone=TempDescriptor.tempFactory("index",new TypeDescriptor(TypeDescriptor.INT));
        FlatNop fnop=new FlatNop();//last node
@@ -268,7 +278,7 @@ public class BuildFlat {
        FlatCondBranch fcb=new FlatCondBranch(tmpbool);
        //is index<temp[i]
        TempDescriptor new_tmp=TempDescriptor.tempFactory("tmp",td);
-       FlatNew fn=new FlatNew(td, new_tmp, temparray[i+1]);
+       FlatNew fn=new FlatNew(td, new_tmp, temparray[i+1], isglobal);
        FlatSetElementNode fsen=new FlatSetElementNode(tmp,index,new_tmp);
        // index=index+1
        FlatOpNode fon=new FlatOpNode(index,index,tmpone,new Operation(Operation.ADD));
@@ -281,7 +291,7 @@ public class BuildFlat {
        fn.addNext(fsen);
        //Recursive call here
        if ((i+2)<temparray.length) {
-           NodePair np2=generateNewArrayLoop(temparray, td.dereference(), new_tmp, i+1);
+           NodePair np2=generateNewArrayLoop(temparray, td.dereference(), new_tmp, i+1, isglobal);
            fsen.addNext(np2.getBegin());
            np2.getEnd().addNext(fon);
        } else {
@@ -900,6 +910,15 @@ public class BuildFlat {
        return flattenBlockNode(sbn.getBlockNode());
     }
 
+    private NodePair flattenAtomicNode(AtomicNode sbn) {
+       NodePair np=flattenBlockNode(sbn.getBlockNode());
+       FlatAtomicEnterNode faen=new FlatAtomicEnterNode();
+       FlatAtomicExitNode faexn=new FlatAtomicExitNode();
+       faen.addNext(np.getBegin());
+       np.getEnd().addNext(faexn);
+       return new NodePair(faen, faexn);
+    }
+
     private NodePair flattenBlockStatementNode(BlockStatementNode bsn) {
        switch(bsn.kind()) {
        case Kind.BlockExpressionNode:
@@ -925,6 +944,9 @@ public class BuildFlat {
            
        case Kind.SubBlockNode:
            return flattenSubBlockNode((SubBlockNode)bsn);
+
+       case Kind.AtomicNode:
+           return flattenAtomicNode((AtomicNode)bsn);
            
        }
        throw new Error();
index e8d46d8f5b6173ee610100f4a36316f7594ab5e0..b30de0d2651b2eb3b5ba4aae6811ceea7c3c4512 100644 (file)
@@ -18,4 +18,6 @@ public class FKind {
     public static final int FlatBackEdge=15;    
     public static final int FlatTagDeclaration=16;
     public static final int FlatMethod=17;
+    public static final int FlatAtomicEnterNode=18;
+    public static final int FlatAtomicExitNode=19;
 }
diff --git a/Robust/src/IR/Flat/FlatAtomicEnterNode.java b/Robust/src/IR/Flat/FlatAtomicEnterNode.java
new file mode 100644 (file)
index 0000000..48f86dd
--- /dev/null
@@ -0,0 +1,15 @@
+package IR.Flat;
+import java.util.Vector;
+
+public class FlatAtomicEnterNode extends FlatNode {
+    public FlatAtomicEnterNode() {
+    }
+
+    public String toString() {
+       return "atomicenter";
+    }
+
+    public int kind() {
+       return FKind.FlatAtomicEnterNode;
+    }
+}
diff --git a/Robust/src/IR/Flat/FlatAtomicExitNode.java b/Robust/src/IR/Flat/FlatAtomicExitNode.java
new file mode 100644 (file)
index 0000000..2effb30
--- /dev/null
@@ -0,0 +1,15 @@
+package IR.Flat;
+import java.util.Vector;
+
+public class FlatAtomicExitNode extends FlatNode {
+    public FlatAtomicExitNode() {
+    }
+
+    public String toString() {
+       return "atomicexit";
+    }
+
+    public int kind() {
+       return FKind.FlatAtomicExitNode;
+    }
+}
index e4e0d00a5146dea5411d74ccbe43affad9459b20..f728e2ef9d0347d424c3015d094ff823bb1451ce 100644 (file)
@@ -5,17 +5,24 @@ public class FlatNew extends FlatNode {
     TempDescriptor dst;
     TypeDescriptor type;
     TempDescriptor size;
+    boolean isglobal;
     
-    public FlatNew(TypeDescriptor type, TempDescriptor dst) {
+    public FlatNew(TypeDescriptor type, TempDescriptor dst, boolean isglobal) {
        this.type=type;
        this.dst=dst;
        this.size=null;
+       this.isglobal=isglobal;
     }
 
-    public FlatNew(TypeDescriptor type, TempDescriptor dst, TempDescriptor size) {
+    public FlatNew(TypeDescriptor type, TempDescriptor dst, TempDescriptor size, boolean isglobal) {
        this.type=type;
        this.dst=dst;
        this.size=size;
+       this.isglobal=isglobal;
+    }
+
+    public boolean isGlobal() {
+       return isglobal;
     }
 
     public String toString() {
index 096929060f60a9690b8ab83fe5c23ae4c81ef661..4c8bcbaa28897cf089d3e666b28acaf98e1c30d4 100644 (file)
@@ -15,19 +15,19 @@ public class FlatOpNode extends FlatNode {
        this.op=op;
     }
     
-    TempDescriptor getDest() {
+    public TempDescriptor getDest() {
        return dest;
     }
 
-    TempDescriptor getLeft() {
+    public TempDescriptor getLeft() {
        return left;
     }
 
-    TempDescriptor getRight() {
+    public TempDescriptor getRight() {
        return right;
     }
     
-    Operation getOp() {
+    public Operation getOp() {
        return op;
     }
 
index 8d399600a623e371737175790eeeed89dcd8fcb3..c6ebbb32a4a894dfc855c12da93a153295f302b5 100644 (file)
@@ -22,17 +22,16 @@ public class State {
 
     /** Boolean flag which indicates whether compiler is compiling a task-based
      * program. */
-    public boolean WEBINTERFACE;
-    public boolean TASK;
+    public boolean WEBINTERFACE=false;
+    public boolean TASK=false;
+    public boolean DSM=false;
     public boolean TASKSTATE=false;
-
     public boolean OPTIONAL=false;
-
     public boolean THREAD=false;
+    public boolean CONSCHECK=false;
     public boolean INSTRUCTIONFAILURE=false;
     public String structfile;
     public String main;
-    public boolean CONSCHECK=false;
 
     public SymbolTable classes;
     public SymbolTable tasks;
index 2e2bd5e2076a60d3ca252ba2f78ae53d0faa3281..af01c8861d89642ae9d29232572c2719d0a78cdc 100644 (file)
@@ -250,6 +250,10 @@ public class SemanticCheck {
        case Kind.SubBlockNode:
            checkSubBlockNode(md, nametable, (SubBlockNode)bsn);
            return;
+
+       case Kind.AtomicNode:
+           checkAtomicNode(md, nametable, (AtomicNode)bsn);
+           return;
        }
        throw new Error();
     }
@@ -285,6 +289,10 @@ public class SemanticCheck {
        checkBlockNode(md, nametable, sbn.getBlockNode());
     }
 
+    void checkAtomicNode(Descriptor md, SymbolTable nametable, AtomicNode sbn) {
+       checkBlockNode(md, nametable, sbn.getBlockNode());
+    }
+
     void checkReturnNode(Descriptor d, SymbolTable nametable, ReturnNode rn) {
        if (d instanceof TaskDescriptor)
            throw new Error("Illegal return appears in Task: "+d.getSymbol());
index 7567db432f5a79a026cabadf06ab240366678f8b..1dc2d334583a22c970a29374e70a6ed893f137c8 100644 (file)
@@ -17,6 +17,7 @@ import Analysis.TaskStateAnalysis.TagAnalysis;
 import Analysis.TaskStateAnalysis.GarbageAnalysis;
 import Analysis.TaskStateAnalysis.ExecutionGraph;
 import Analysis.TaskStateAnalysis.SafetyAnalysis;
+import Analysis.Locality.LocalityAnalysis;
 import Interface.*;
 
 public class Main {
@@ -49,6 +50,8 @@ public class Main {
              state.OPTIONAL=true;
          else if (option.equals("-thread"))
              state.THREAD=true;
+         else if (option.equals("-dsm"))
+             state.DSM=true;
          else if (option.equals("-webinterface"))
              state.WEBINTERFACE=true;
          else if (option.equals("-instructionfailures"))
@@ -58,6 +61,7 @@ public class Main {
              System.out.println("-dir outputdirectory -- output code in outputdirectory");
              System.out.println("-struct structfile -- output structure declarations for repair tool");
              System.out.println("-mainclass -- main function to call");
+             System.out.println("-dsm -- distributed shared memory support");
              System.out.println("-precise -- use precise garbage collection");
              System.out.println("-conscheck -- turn on consistency checking");
              System.out.println("-task -- compiler for tasks");
@@ -146,10 +150,11 @@ public class Main {
 
 
       }
-
-      
+      if (state.DSM) {
+         CallGraph callgraph=new CallGraph(state);
+         LocalityAnalysis la=new LocalityAnalysis(state, callgraph, tu);
+      }
       
-
       BuildCode bc=new BuildCode(state, bf.getMap(), tu);
       bc.buildCode();
       System.exit(0);
index aa6ba471ae69beda5b0c9312d13bd7b51d397a15..6d3f35a0734d2d0babffd9c05fe5a0321a7afc8c 100644 (file)
@@ -79,7 +79,7 @@ javadoc:
        javadoc -classpath ../cup:.:$(CLASSPATH) -sourcepath . -private -d javadoc Lex Util IR IR.Tree IR.Flat Analysis Analysis.CallGraph Analysis.Flag Analysis.TaskStateAnalysis Main 
 
 clean:
-       rm IR/*.class IR/Tree/*.class Main/*.class Lex/*.class Parse/*.class Parse/Sym.java Parse/Parser.java IR/Flat/*.class classdefs.h methodheaders.h methods.c structdefs.h virtualtable.h task.h taskdefs.c taskdefs.h Analysis/*.class Analysis/Flag/*.class Analysis/CallGraph/*.class  Analysis/TaskStateAnalysis/*.class Interface/*.class Util/*.class
+       rm IR/*.class IR/Tree/*.class Main/*.class Lex/*.class Parse/*.class Parse/Sym.java Parse/Parser.java IR/Flat/*.class classdefs.h methodheaders.h methods.c structdefs.h virtualtable.h task.h taskdefs.c taskdefs.h Analysis/*.class Analysis/Flag/*.class Analysis/CallGraph/*.class  Analysis/TaskStateAnalysis/*.class Interface/*.class Util/*.class Analysis/Locality/*.class
 
 cleandoc:
        rm -rf javadoc
\ No newline at end of file