Bug fixes for gc
authorjzhou <jzhou>
Wed, 23 Mar 2011 19:15:59 +0000 (19:15 +0000)
committerjzhou <jzhou>
Wed, 23 Mar 2011 19:15:59 +0000 (19:15 +0000)
Robust/src/IR/Flat/BuildCode.java
Robust/src/IR/Flat/BuildCodeMGC.java
Robust/src/IR/Flat/BuildCodeMultiCore.java
Robust/src/Runtime/bamboo/multicoreruntime.c

index fdf15bc246652fc9876ecec3858638ce8c695b11..e1c36297c8f4ad6c2474cf3b8aa7742fc71b2dce 100644 (file)
@@ -1581,7 +1581,6 @@ public class BuildCode {
          } else {
            globaldefprimout.println("  "+fd.getType().getSafeSymbol()+ " "+fd.getSafeSymbol()+";");
          }
-         globaldefscount++;
        }
       } else if (fd.isVolatile()) {
        //volatile field
index d7b2accdf98500b46a16084bf7e6ef9f0ef5633b..e01fe00825636b11150b3b59df23054c5bc3b7ae 100644 (file)
@@ -154,6 +154,7 @@ public class BuildCodeMGC extends BuildCode {
     
     if (state.MULTICOREGC) {
       outmethod.println("  global_defs_p->size="+globaldefscount+";");
+      outmethod.println("  global_defs_p->next=NULL;");
       outmethod.println("  for(i=0;i<"+globaldefscount+";i++) {");
       outmethod.println("    ((struct garbagelist *)global_defs_p)->array[i]=NULL;");
       outmethod.println("  }");
@@ -192,26 +193,4 @@ public class BuildCodeMGC extends BuildCode {
 
     outmethod.println("}");
   }
-  
-  protected void outputClassObjects(PrintWriter outmethod) {
-    // for each class, initialize its Class object
-    if(state.MGC) {
-      SymbolTable ctbl = this.state.getClassSymbolTable();
-      Iterator it_classes = ctbl.getDescriptorsIterator();
-
-      while(it_classes.hasNext()) {
-        ClassDescriptor t_cd = (ClassDescriptor)it_classes.next();
-        // TODO initialize the Class object for this class  ++
-        outmethod.println(" {");
-        if ((GENERATEPRECISEGC) || (this.state.MULTICOREGC)) {
-          outmethod.println("    struct garbagelist dummy={0,NULL};");
-          outmethod.println("    global_defs_p->"+t_cd.getSafeSymbol()+"classobj = allocate_new(&dummy, " + typeutil.getClass(TypeUtil.ObjectClass).getId() + ");");
-        } else {
-          outmethod.println("    global_defs_p->"+t_cd.getSafeSymbol()+"classobj = allocate_new(" + typeutil.getClass(TypeUtil.ObjectClass).getId() + ");");
-        }
-        outmethod.println(" }");
-        
-      }
-    } // else TODO normal java version 
-  }
 }
index 05010567130012bf89c7b2448fd4a7d1da13835b..454432b4a413d3bd234a9e7d3dfb41dc72f9a14c 100644 (file)
@@ -362,6 +362,8 @@ public class BuildCodeMultiCore extends BuildCode {
         outrepairstructs.close();
        }*/
 
+    outputInitStaticAndGlobalMethod(outmethod);
+    
     /* Close files */
     outmethodheader.println("#endif");
     outmethodheader.close();
@@ -369,6 +371,24 @@ public class BuildCodeMultiCore extends BuildCode {
     outstructs.println("#endif");
     outstructs.close();
   }
+  
+  private void outputInitStaticAndGlobalMethod(PrintWriter outmethod) {
+    outmethod.println("void initStaticAndGlobal() {");
+    outmethod.println("  int i;");
+    
+    if (state.MULTICOREGC) {
+      outmethod.println("  global_defs_p->size="+globaldefscount+";");
+      outmethod.println("  global_defs_p->next=NULL;");
+      outmethod.println("  for(i=0;i<"+globaldefscount+";i++) {");
+      outmethod.println("    ((struct garbagelist *)global_defs_p)->array[i]=NULL;");
+      outmethod.println("  }");
+    }
+    
+    outputStaticBlocks(outmethod);
+    outputClassObjects(outmethod);
+
+    outmethod.println("}");
+  }
 
   /** This function outputs (1) structures that parameters are
    * passed in (when PRECISE GC is enabled) and (2) function
index 496fc086bc14d43c33df6bbfb534ec17276438b9..89a2dbe21f1adef0963552351ab31ea120447061 100644 (file)
@@ -777,12 +777,16 @@ inline void run(int argc, char** argv) {
     BAMBOO_DEBUGPRINT(0xee00);
 #endif
 
-#ifdef MGC
        if(STARTUPCORE == BAMBOO_NUM_OF_CORE) {
+#ifdef TASK
+         // run the initStaticAndGlobal method to initialize the static blocks and
+         // global fields
+         initStaticAndGlobal();
+#elif defined MGC
          // run the main method in the specified mainclass
          mgc_main(argc, argv);
+#endif // TASK
        }
-#endif
 
     while(true) {