} else {
globaldefprimout.println(" "+fd.getType().getSafeSymbol()+ " "+fd.getSafeSymbol()+";");
}
- globaldefscount++;
}
} else if (fd.isVolatile()) {
//volatile field
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(" }");
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
- }
}
outrepairstructs.close();
}*/
+ outputInitStaticAndGlobalMethod(outmethod);
+
/* Close files */
outmethodheader.println("#endif");
outmethodheader.close();
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
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) {