more DSTM interface work
authorbdemsky <bdemsky>
Thu, 16 Aug 2007 07:59:01 +0000 (07:59 +0000)
committerbdemsky <bdemsky>
Thu, 16 Aug 2007 07:59:01 +0000 (07:59 +0000)
Robust/src/IR/Flat/BuildCode.java
Robust/src/IR/MethodDescriptor.java
Robust/src/IR/Tree/SemanticCheck.java

index bd24b2f0e378daa17fa81a9d79fe6dde2c8ed36c..ee496ad9f7d3da1dfc44d9634f472ec27dc30b64 100644 (file)
@@ -816,6 +816,8 @@ public class BuildCode {
            while(allit.hasNext()) {
                FieldDescriptor fd=(FieldDescriptor)allit.next();
                TypeDescriptor type=fd.getType();
+               if (state.DSM&&fd.isGlobal()) //Don't GC the global objects for now
+                   continue;
                if (type.isPtr()||type.isArray())
                    count++;
            }
@@ -824,6 +826,8 @@ public class BuildCode {
            while(allit.hasNext()) {
                FieldDescriptor fd=(FieldDescriptor)allit.next();
                TypeDescriptor type=fd.getType();
+               if (state.DSM&&fd.isGlobal()) //Don't GC the global objects for now
+                   continue;
                if (type.isPtr()||type.isArray()) {
                    output.println(",");
                    output.print("((unsigned int)&(((struct "+cn.getSafeSymbol() +" *)0)->"+fd.getSafeSymbol()+"))");
index 79056252263b2468a6c773fde70d2547db2fcbcc..1f781f3fce3d63157925bea63c873f597adbd186 100644 (file)
@@ -70,6 +70,11 @@ public class MethodDescriptor extends Descriptor {
        thisvd=null;
     }
 
+
+    public boolean isGlobal() {
+       return isglobal;
+    }
+
     public void setThis(VarDescriptor vd) {
        thisvd=vd;
        paramtable.add(vd);
index af01c8861d89642ae9d29232572c2719d0a78cdc..12e5223c5a6d68345c1e19d9ff6fb4183c94fe2a 100644 (file)
@@ -543,8 +543,6 @@ public class SemanticCheck {
        if (td!=null&&!typeutil.isSuperorType(td, typetolookin))
            throw new Error(typetolookin + " isn't a "+td);
 
-
-
        /* Check flag effects */
        if (con.getFlagEffects()!=null) {
            FlagEffects fe=con.getFlagEffects();
@@ -574,37 +572,43 @@ public class SemanticCheck {
            }
        }
 
-
        if ((!typetolookin.isClass())&&(!typetolookin.isArray())) 
            throw new Error("Can't allocate primitive type:"+con.printNode(0));
 
        if (!typetolookin.isArray()) {
            //Array's don't need constructor calls
            ClassDescriptor classtolookin=typetolookin.getClassDesc();
-           //System.out.println("Looking for "+typetolookin.getSymbol());
-           //System.out.println(classtolookin.getMethodTable());
-           
+
            Set methoddescriptorset=classtolookin.getMethodTable().getSet(typetolookin.getSymbol());
            MethodDescriptor bestmd=null;
        NextMethod:
            for(Iterator methodit=methoddescriptorset.iterator();methodit.hasNext();) {
                MethodDescriptor currmd=(MethodDescriptor)methodit.next();
                /* Need correct number of parameters */
-               //System.out.println("Examining: "+currmd);
                if (con.numArgs()!=currmd.numParameters())
                    continue;
                for(int i=0;i<con.numArgs();i++) {
                    if (!typeutil.isSuperorType(currmd.getParamType(i),tdarray[i]))
                        continue NextMethod;
                }
+               /* Local allocations can't call global allocator */
+               if (!con.isGlobal()&&currmd.isGlobal())
+                   continue;
+
                /* Method okay so far */
                if (bestmd==null)
                    bestmd=currmd;
                else {
                    if (isMoreSpecific(currmd,bestmd)) {
                        bestmd=currmd;
-                   } else if (!isMoreSpecific(bestmd, currmd))
+                   } else if (con.isGlobal()&&match(currmd, bestmd)) {
+                       if (currmd.isGlobal()&&!bestmd.isGlobal())
+                           bestmd=currmd;
+                       else if (currmd.isGlobal()&&bestmd.isGlobal())
+                           throw new Error();
+                   } else if (!isMoreSpecific(bestmd, currmd)) {
                        throw new Error("No method is most specific");
+                   }
                    
                    /* Is this more specific than bestmd */
                }
@@ -637,6 +641,27 @@ public class SemanticCheck {
        return true;
     }
 
+    /** Check to see if md1 is the same specificity as md2.*/
+
+    boolean match(MethodDescriptor md1, MethodDescriptor md2) {
+       /* Checks if md1 is more specific than md2 */
+       if (md1.numParameters()!=md2.numParameters())
+           throw new Error();
+       for(int i=0;i<md1.numParameters();i++) {
+           if (!md2.getParamType(i).equals(md1.getParamType(i)))
+               return false;
+       }
+       if (!md2.getReturnType().equals(md1.getReturnType()))
+               return false;
+
+       if (!md2.getClassDesc().equals(md1.getClassDesc()))
+               return false;
+
+       return true;
+    }
+
+
+
     ExpressionNode translateNameDescriptorintoExpression(NameDescriptor nd) {
        String id=nd.getIdentifier();
        NameDescriptor base=nd.getBase();