From e350f6037d94ab79ca3c8c256cc0e2b3eae344c9 Mon Sep 17 00:00:00 2001 From: jzhou Date: Wed, 23 Mar 2011 19:15:59 +0000 Subject: [PATCH] Bug fixes for gc --- Robust/src/IR/Flat/BuildCode.java | 1 - Robust/src/IR/Flat/BuildCodeMGC.java | 23 +------------------- Robust/src/IR/Flat/BuildCodeMultiCore.java | 20 +++++++++++++++++ Robust/src/Runtime/bamboo/multicoreruntime.c | 8 +++++-- 4 files changed, 27 insertions(+), 25 deletions(-) diff --git a/Robust/src/IR/Flat/BuildCode.java b/Robust/src/IR/Flat/BuildCode.java index fdf15bc2..e1c36297 100644 --- a/Robust/src/IR/Flat/BuildCode.java +++ b/Robust/src/IR/Flat/BuildCode.java @@ -1581,7 +1581,6 @@ public class BuildCode { } else { globaldefprimout.println(" "+fd.getType().getSafeSymbol()+ " "+fd.getSafeSymbol()+";"); } - globaldefscount++; } } else if (fd.isVolatile()) { //volatile field diff --git a/Robust/src/IR/Flat/BuildCodeMGC.java b/Robust/src/IR/Flat/BuildCodeMGC.java index d7b2accd..e01fe008 100644 --- a/Robust/src/IR/Flat/BuildCodeMGC.java +++ b/Robust/src/IR/Flat/BuildCodeMGC.java @@ -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 - } } diff --git a/Robust/src/IR/Flat/BuildCodeMultiCore.java b/Robust/src/IR/Flat/BuildCodeMultiCore.java index 05010567..454432b4 100644 --- a/Robust/src/IR/Flat/BuildCodeMultiCore.java +++ b/Robust/src/IR/Flat/BuildCodeMultiCore.java @@ -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 diff --git a/Robust/src/Runtime/bamboo/multicoreruntime.c b/Robust/src/Runtime/bamboo/multicoreruntime.c index 496fc086..89a2dbe2 100644 --- a/Robust/src/Runtime/bamboo/multicoreruntime.c +++ b/Robust/src/Runtime/bamboo/multicoreruntime.c @@ -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) { -- 2.34.1