Fix compilation problems for multicore code
authorjzhou <jzhou>
Thu, 17 Mar 2011 00:49:19 +0000 (00:49 +0000)
committerjzhou <jzhou>
Thu, 17 Mar 2011 00:49:19 +0000 (00:49 +0000)
Robust/src/IR/Flat/BuildCode.java
Robust/src/IR/Flat/BuildCodeMultiCore.java
Robust/src/IR/State.java
Robust/src/IR/Virtual.java
Robust/src/Runtime/bamboo/multicoreruntime.h
Robust/src/Runtime/runtime.h

index beb4593a2137609d0782d477a46658ee846b54b8..dfeef8d1ffd8d81d8438c9573db07d6c88e51009 100644 (file)
@@ -254,7 +254,7 @@ public class BuildCode {
    * invoked and should be generated
    */
   protected void checkMethods2Gen() {
-    MethodDescriptor md=typeutil.getMain();
+    MethodDescriptor md=(state.main==null)?null:typeutil.getMain();
     
     if(md != null) {
       // check the methods to be generated
@@ -530,17 +530,19 @@ public class BuildCode {
       while(methodit.hasNext()) {
        /* Classify parameters */
        MethodDescriptor md=(MethodDescriptor)methodit.next();
-    Set vec_md = this.state.getMethod2gen().getSet(md.getSymbol());
-    boolean foundmatch = false;
-    for(Iterator matchit=vec_md.iterator(); matchit.hasNext();) {
-      MethodDescriptor matchmd=(MethodDescriptor)matchit.next();
-      if (md.matches(matchmd)) {
-        foundmatch=true;
-        break;
+    if(!this.state.genAllMethods) {
+      boolean foundmatch = false;
+      Set vec_md = this.state.getMethod2gen().getSet(md.getSymbol());
+      for(Iterator matchit=vec_md.iterator(); matchit.hasNext();) {
+        MethodDescriptor matchmd=(MethodDescriptor)matchit.next();
+        if (md.matches(matchmd)) {
+          foundmatch=true;
+          break;
+        }
+      }
+      if(!foundmatch) {
+        continue;
       }
-    }
-    if(!foundmatch) {
-      continue;
     }
        FlatMethod fm=state.getMethodFlat(md);
        if (!md.getModifiers().isNative()) {
@@ -968,13 +970,17 @@ public class BuildCode {
       MethodDescriptor md=(MethodDescriptor)it.next();
       if (md.isStatic()||md.getReturnType()==null)
        continue;
-      Set vec_md = this.state.getMethod2gen().getSet(md.getSymbol());
       boolean foundmatch = false;
-      for(Iterator matchit=vec_md.iterator(); matchit.hasNext();) {
-        MethodDescriptor matchmd=(MethodDescriptor)matchit.next();
-        if (md.matches(matchmd)) {
-          foundmatch=true;
-          break;
+      if(this.state.genAllMethods) {
+        foundmatch = true;
+      } else {
+        Set vec_md = this.state.getMethod2gen().getSet(md.getSymbol());
+        for(Iterator matchit=vec_md.iterator(); matchit.hasNext();) {
+          MethodDescriptor matchmd=(MethodDescriptor)matchit.next();
+          if (md.matches(matchmd)) {
+            foundmatch=true;
+            break;
+          }
         }
       }
       if(!foundmatch) {
@@ -1674,13 +1680,17 @@ public class BuildCode {
   protected void generateCallStructsMethods(ClassDescriptor cn, PrintWriter output, PrintWriter headersout) {
     for(Iterator methodit=cn.getMethods(); methodit.hasNext(); ) {
       MethodDescriptor md=(MethodDescriptor)methodit.next();
-      Set vec_md = this.state.getMethod2gen().getSet(md.getSymbol());
       boolean foundmatch = false;
-      for(Iterator matchit=vec_md.iterator(); matchit.hasNext();) {
-        MethodDescriptor matchmd=(MethodDescriptor)matchit.next();
-        if (md.matches(matchmd)) {
-          foundmatch=true;
-          break;
+      if(this.state.genAllMethods) {
+        foundmatch = true;
+      } else {
+        Set vec_md = this.state.getMethod2gen().getSet(md.getSymbol());
+        for(Iterator matchit=vec_md.iterator(); matchit.hasNext();) {
+          MethodDescriptor matchmd=(MethodDescriptor)matchit.next();
+          if (md.matches(matchmd)) {
+            foundmatch=true;
+            break;
+          }
         }
       }
       if(foundmatch) {
@@ -2423,7 +2433,7 @@ public class BuildCode {
     // if the called method is a static block or a static method or a constructor
     // need to check if it can be invoked inside some static block
     if((md.isStatic() || md.isStaticBlock() || md.isConstructor()) &&
-       ((fm.getMethod().isStaticBlock()) || (fm.getMethod().isInvokedByStatic()))) {
+       ((fm.getMethod() != null) && ((fm.getMethod().isStaticBlock()) || (fm.getMethod().isInvokedByStatic())))) {
       if(!md.isInvokedByStatic()) {
        System.err.println("Error: a method that is invoked inside a static block is not tagged!");
       }
index 7ce0e07d81520aa42115de2fa93a37efecb6b6fd..05010567130012bf89c7b2448fd4a7d1da13835b 100644 (file)
@@ -110,6 +110,7 @@ public class BuildCodeMultiCore extends BuildCode {
       outstructs=new PrintWriter(new FileOutputStream(PREFIX+"structdefs.h"), true);
       outmethodheader=new PrintWriter(new FileOutputStream(PREFIX+"methodheaders.h"), true);
       outclassdefs=new PrintWriter(new FileOutputStream(PREFIX+"classdefs.h"), true);
+      outglobaldefs=new PrintWriter(new FileOutputStream(PREFIX+"globaldefs.h"), true);
       outglobaldefsprim=new PrintWriter(new FileOutputStream(PREFIX+"globaldefsprim.h"), true);
       outvirtual=new PrintWriter(new FileOutputStream(PREFIX+"virtualtable.h"), true);
       outmethod=new PrintWriter(new FileOutputStream(PREFIX+"methods.c"), true);
@@ -149,6 +150,18 @@ public class BuildCodeMultiCore extends BuildCode {
 
     /* Output Structures */
     outputStructs(outstructs);
+    
+    outglobaldefs.println("#ifndef __GLOBALDEF_H_");
+    outglobaldefs.println("#define __GLOBALDEF_H_");
+    outglobaldefs.println("");
+    outglobaldefs.println("struct global_defs_t {");
+    outglobaldefs.println("  int size;");
+    outglobaldefs.println("  void * next;");
+
+    outglobaldefsprim.println("#ifndef __GLOBALDEFPRIM_H_");
+    outglobaldefsprim.println("#define __GLOBALDEFPRIM_H_");
+    outglobaldefsprim.println("");
+    outglobaldefsprim.println("struct global_defsprim_t {");
 
     // Output the C class declarations
     // These could mutually reference each other
@@ -163,8 +176,23 @@ public class BuildCodeMultiCore extends BuildCode {
       ClassDescriptor cn=(ClassDescriptor)it.next();
       generateCallStructs(cn, outclassdefs, outstructs, outmethodheader, outglobaldefs, outglobaldefsprim);
     }
+    outclassdefs.println("#include \"globaldefs.h\"");
+    outclassdefs.println("#include \"globaldefsprim.h\"");
     outclassdefs.println("#endif");
     outclassdefs.close();
+    outglobaldefs.println("};");
+    outglobaldefs.println("");
+    outglobaldefs.println("extern struct global_defs_t * global_defs_p;");
+    outglobaldefs.println("#endif");
+    outglobaldefs.flush();
+    outglobaldefs.close();
+
+    outglobaldefsprim.println("};");
+    outglobaldefsprim.println("");
+    outglobaldefsprim.println("extern struct global_defsprim_t * global_defsprim_p;");
+    outglobaldefsprim.println("#endif");
+    outglobaldefsprim.flush();
+    outglobaldefsprim.close();
 
     if (state.TASK) {
       /* Map flags to integers */
index 54df5b664f5667cccfb7270b31ad92f8c0e37abf..eb61444024c5c3874a858c4e3d2fdec2f77e6d87 100644 (file)
@@ -183,7 +183,7 @@ public class State {
   public Hashtable treemethodmap;
   public Hashtable flatmethodmap;
   SymbolTable methods2gen;
-  boolean genAllMethods;
+  public boolean genAllMethods;
   private HashSet arraytypes;
   public Hashtable arraytonumber;
   private int numclasses=1; // start from 1 instead of 0 for multicore gc
index 52c7310408c3554293531849114d1966ca8644a8..456fb45ed2ed29472d15f800f1c384948f0f6eb9 100644 (file)
@@ -127,13 +127,17 @@ public class Virtual {
       MethodDescriptor md=(MethodDescriptor)it.next();
       if (md.isStatic()||md.getReturnType()==null)
         continue;
-      Set vec_md = this.state.getMethod2gen().getSet(md.getSymbol());
       boolean foundmatch = false;
-      for(Iterator matchit=vec_md.iterator(); matchit.hasNext();) {
-        MethodDescriptor matchmd=(MethodDescriptor)matchit.next();
-        if (md.matches(matchmd)) {
-          foundmatch=true;
-          break;
+      if(this.state.genAllMethods) {
+        foundmatch = true;
+      } else {
+        Set vec_md = this.state.getMethod2gen().getSet(md.getSymbol());
+        for(Iterator matchit=vec_md.iterator(); matchit.hasNext();) {
+          MethodDescriptor matchmd=(MethodDescriptor)matchit.next();
+          if (md.matches(matchmd)) {
+            foundmatch=true;
+            break;
+          }
         }
       }
       if(!foundmatch) {
@@ -175,13 +179,17 @@ public class Virtual {
       MethodDescriptor md=(MethodDescriptor)it.next();
       if (md.isStatic()||md.getReturnType()==null)
         continue;
-      Set vec_md = this.state.getMethod2gen().getSet(md.getSymbol());
       boolean foundmatch = false;
-      for(Iterator matchit=vec_md.iterator(); matchit.hasNext();) {
-        MethodDescriptor matchmd=(MethodDescriptor)matchit.next();
-        if (md.matches(matchmd)) {
-          foundmatch=true;
-          break;
+      if(this.state.genAllMethods) {
+        foundmatch = true;
+      } else {
+        Set vec_md = this.state.getMethod2gen().getSet(md.getSymbol());
+        for(Iterator matchit=vec_md.iterator(); matchit.hasNext();) {
+          MethodDescriptor matchmd=(MethodDescriptor)matchit.next();
+          if (md.matches(matchmd)) {
+            foundmatch=true;
+            break;
+          }
         }
       }
       if(!foundmatch) {
index 4ca9ec565878f7049990ef0f4eb00eaf21f14687..9be910f7b138b9c565e5dda3190d7e88b4fc1a52 100644 (file)
@@ -24,6 +24,16 @@ int totalexetime;
 bool reside;
 #endif
 
+#ifdef MULTICORE
+#ifdef GC_SMALLPAGESIZE
+#define BAMBOO_GLOBAL_DEFS_SIZE (1024 * 1024)
+#define BAMBOO_GLOBAL_DEFS_PRIM_SIZE (1024 * 512)
+#else
+#define BAMBOO_GLOBAL_DEFS_SIZE (BAMBOO_SMEM_SIZE)
+#define BAMBOO_GLOBAL_DEFS_PRIM_SIZE (BAMBOO_SMEM_SIZE/2)
+#endif // GC_SMALLPAGESIZE
+#endif // MULTICORE
+
 #ifdef MGC
 // shared memory pointer for global thread queue
 // In MGC version, this block of memory is located at the very bottom of the 
@@ -38,12 +48,8 @@ bool reside;
 //     mutex + thread counter + start pointer + end pointer
 #ifdef GC_SMALLPAGESIZE
 #define BAMBOO_THREAD_QUEUE_SIZE (1024 * 1024)
-#define BAMBOO_GLOBAL_DEFS_SIZE (1024 * 1024)
-#define BAMBOO_GLOBAL_DEFS_PRIM_SIZE (1024 * 512)
 #else
 #define BAMBOO_THREAD_QUEUE_SIZE (BAMBOO_SMEM_SIZE) // (45 * 16 * 1024)
-#define BAMBOO_GLOBAL_DEFS_SIZE (BAMBOO_SMEM_SIZE)
-#define BAMBOO_GLOBAL_DEFS_PRIM_SIZE (BAMBOO_SMEM_SIZE/2)
 #endif
 // data structures for threads
 INTPTR * bamboo_thread_queue;
index b02fc1790961ad2f08d8a45fee3fdaaf2240a219..8f9e5f4b08dc66f34a51be726fe9db9aff22817e 100644 (file)
@@ -114,6 +114,18 @@ void createstartupobject();
 #define CALL24(name, rest, rest2, alt1, alt2, alt3, alt4) name(struct name ## _params * ___params___, rest, rest2)
 #define CALL34(name, rest, rest2, rest3, alt1, alt2, alt3, alt4) name(struct name ## _params * ___params___, rest, rest2, rest3)
 #define CALL35(name, rest, rest2, rest3, alt1, alt2, alt3, alt4, alt5) name(struct name ## _params * ___params___, rest, rest2, rest3)
+#elif defined MULTICORE_GC
+#define VAR(name) ___params___->name
+#define CALL00(name) name(struct name ## _params * ___params___)
+#define CALL01(name, alt) name(struct name ## _params * ___params___)
+#define CALL02(name, alt1, alt2) name(struct name ## _params * ___params___)
+#define CALL11(name,rest, alt) name(struct name ## _params * ___params___, rest)
+#define CALL12(name,rest, alt1, alt2) name(struct name ## _params * ___params___, rest)
+#define CALL22(name, rest, rest2, alt1, alt2) name(struct name ## _params * ___params___, rest, rest2)
+#define CALL23(name, rest, rest2, alt1, alt2, alt3) name(struct name ## _params * ___params___, rest, rest2)
+#define CALL24(name, rest, rest2, alt1, alt2, alt3, alt4) name(struct name ## _params * ___params___, rest, rest2)
+#define CALL34(name, rest, rest2, rest3, alt1, alt2, alt3, alt4) name(struct name ## _params * ___params___, rest, rest2, rest3)
+#define CALL35(name, rest, rest2, rest3, alt1, alt2, alt3, alt4, alt5) name(struct name ## _params * ___params___, rest, rest2, rest3)
 #else
 #define VAR(name) name
 #define CALL00(name) name()