From: jzhou Date: Fri, 18 Mar 2011 00:13:10 +0000 (+0000) Subject: Remove compilation errors for MGC code with gc X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=b73f2f37aaededdc9494503c88e8f94f192f3194;p=IRC.git Remove compilation errors for MGC code with gc --- diff --git a/Robust/src/ClassLibrary/MGC/System.java b/Robust/src/ClassLibrary/MGC/System.java index 45da9df3..c3a54860 100644 --- a/Robust/src/ClassLibrary/MGC/System.java +++ b/Robust/src/ClassLibrary/MGC/System.java @@ -95,10 +95,9 @@ public class System { public static void genReach(); private static Properties props; - private static native Properties initProperties(); static { - initProperties(); + setProperty("line.separator", "\n"); } public static Properties getProperties() { @@ -113,10 +112,10 @@ public class System { } public static String setProperty(String key, String value) { - if(props != null) { - return (String)props.setProperty(key, value); + if(props == null) { + props = new Properties(); } - return ""; + return (String)props.setProperty(key, value); } public static void setOut(PrintStream out) { diff --git a/Robust/src/IR/Flat/BuildCode.java b/Robust/src/IR/Flat/BuildCode.java index dfeef8d1..eb1fa51f 100644 --- a/Robust/src/IR/Flat/BuildCode.java +++ b/Robust/src/IR/Flat/BuildCode.java @@ -1759,7 +1759,7 @@ public class BuildCode { output.println(" void * next;"); for(int i=0; i" + cn.getSafeSymbol()+"static_block_exe_flag == 0) {"); if(cn.getNumStaticBlocks() != 0) { MethodDescriptor t_md = (MethodDescriptor)cn.getMethodTable().get("staticblocks"); - output.println(" "+cn.getSafeSymbol()+t_md.getSafeSymbol()+"_"+t_md.getSafeMethodDescriptor()+"();"); + if ((GENERATEPRECISEGC) || (this.state.MULTICOREGC)) { + output.print(" struct "+cn.getSafeSymbol()+t_md.getSafeSymbol()+"_"+t_md.getSafeMethodDescriptor()+"_params __parameterlist__={"); + output.println("0, NULL};"); + output.println(" "+cn.getSafeSymbol()+t_md.getSafeSymbol()+"_"+t_md.getSafeMethodDescriptor()+"(& __parameterlist__);"); + } else { + output.println(" "+cn.getSafeSymbol()+t_md.getSafeSymbol()+"_"+t_md.getSafeMethodDescriptor()+"();"); + } } else { output.println(" global_defsprim_p->" + cn.getSafeSymbol()+"static_block_exe_flag = 1;"); } @@ -2458,10 +2464,18 @@ public class BuildCode { } } if((md.getSymbol().equals("MonitorEnter") || md.getSymbol().equals("MonitorExit")) && fc.getThis().getSymbol().equals("classobj")) { + output.println("{"); // call MonitorEnter/MonitorExit on a class obj + if ((GENERATEPRECISEGC) || (this.state.MULTICOREGC)) { + output.print(" struct "+cn.getSafeSymbol()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_params __parameterlist__={"); + output.println("1," + localsprefixaddr + ", global_defs_p->"+ fc.getThis().getType().getClassDesc().getSafeSymbol() +"classobj};"); + output.println(" "+cn.getSafeSymbol()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"(& __parameterlist__);"); + } else { output.println(" " + cn.getSafeSymbol()+md.getSafeSymbol()+"_" + md.getSafeMethodDescriptor() + "((struct ___Object___*)(global_defs_p->" + fc.getThis().getType().getClassDesc().getSafeSymbol() +"classobj));"); + } + output.println("}"); return; } @@ -2624,7 +2638,13 @@ public class BuildCode { output.println("if(global_defsprim_p->" + cn.getSafeSymbol()+"static_block_exe_flag == 0) {"); if(cn.getNumStaticBlocks() != 0) { MethodDescriptor t_md = (MethodDescriptor)cn.getMethodTable().get("staticblocks"); - output.println(" "+cn.getSafeSymbol()+t_md.getSafeSymbol()+"_"+t_md.getSafeMethodDescriptor()+"();"); + if ((GENERATEPRECISEGC) || (this.state.MULTICOREGC)) { + output.print(" struct "+cn.getSafeSymbol()+t_md.getSafeSymbol()+"_"+t_md.getSafeMethodDescriptor()+"_params __parameterlist__={"); + output.println("0, NULL};"); + output.println(" "+cn.getSafeSymbol()+t_md.getSafeSymbol()+"_"+t_md.getSafeMethodDescriptor()+"(& __parameterlist__);"); + } else { + output.println(" "+cn.getSafeSymbol()+t_md.getSafeSymbol()+"_"+t_md.getSafeMethodDescriptor()+"();"); + } } else { output.println(" global_defsprim_p->" + cn.getSafeSymbol()+"static_block_exe_flag = 1;"); } @@ -2683,7 +2703,13 @@ public class BuildCode { output.println("if(global_defsprim_p->" + cn.getSafeSymbol()+"static_block_exe_flag == 0) {"); if(cn.getNumStaticBlocks() != 0) { MethodDescriptor t_md = (MethodDescriptor)cn.getMethodTable().get("staticblocks"); - output.println(" "+cn.getSafeSymbol()+t_md.getSafeSymbol()+"_"+t_md.getSafeMethodDescriptor()+"();"); + if ((GENERATEPRECISEGC) || (this.state.MULTICOREGC)) { + output.print(" struct "+cn.getSafeSymbol()+t_md.getSafeSymbol()+"_"+t_md.getSafeMethodDescriptor()+"_params __parameterlist__={"); + output.println("0, NULL};"); + output.println(" "+cn.getSafeSymbol()+t_md.getSafeSymbol()+"_"+t_md.getSafeMethodDescriptor()+"(& __parameterlist__);"); + } else { + output.println(" "+cn.getSafeSymbol()+t_md.getSafeSymbol()+"_"+t_md.getSafeMethodDescriptor()+"();"); + } } else { output.println(" global_defsprim_p->" + cn.getSafeSymbol()+"static_block_exe_flag = 1;"); } diff --git a/Robust/src/IR/Flat/BuildCodeMGC.java b/Robust/src/IR/Flat/BuildCodeMGC.java index 79ce5fcd..adbb3225 100644 --- a/Robust/src/IR/Flat/BuildCodeMGC.java +++ b/Robust/src/IR/Flat/BuildCodeMGC.java @@ -154,6 +154,9 @@ public class BuildCodeMGC extends BuildCode { if (state.MULTICOREGC) { outmethod.println(" global_defs_p->size="+globaldefscount+";"); + outmethod.println(" for(i=0;i<"+globaldefscount+";i++) {"); + outmethod.println(" ((struct garbagelist *)global_defs_p)->array[i]=NULL;"); + outmethod.println(" }"); } outputStaticBlocks(outmethod); @@ -196,119 +199,16 @@ public class BuildCodeMGC extends BuildCode { SymbolTable ctbl = this.state.getClassSymbolTable(); Iterator it_classes = ctbl.getDescriptorsIterator(); - /*TypeDescriptor[] tdarray=new TypeDescriptor[1]; - tdarray[0] = new TypeDescriptor(((ClassDescriptor)this.state.getClassSymbolTable().get("Object"))); - - TypeDescriptor typetolookin=new TypeDescriptor(((ClassDescriptor)this.state.getClassSymbolTable().get("Class")));; - - //find the constructor for 'Class' class - ClassDescriptor classtolookin=typetolookin.getClassDesc(); - - 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 - if (1!=currmd.numParameters()) - continue; - for(int i=0; i<1; i++) { - if (!typeutil.isSuperorType(currmd.getParamType(i),tdarray[i])) - continue NextMethod; - } - // Local allocations can't call global allocator - if (currmd.isGlobal()) - continue; - - // Method okay so far - if (bestmd==null) - bestmd=currmd; - else { - if (typeutil.isMoreSpecific(currmd,bestmd)) { - bestmd=currmd; - } else if (!typeutil.isMoreSpecific(bestmd, currmd)) { - throw new Error("No method is most specific"); - } - - // Is this more specific than bestmd - } - } - if (bestmd==null) - throw new Error("No constructor found for Class in "); - */ while(it_classes.hasNext()) { ClassDescriptor t_cd = (ClassDescriptor)it_classes.next(); - /*if(t_cd.getSymbol().equals("Class") || t_cd.getSymbol().equals("VMClass")) { - continue; - }*/ // TODO initialize the Class object for this class ++ outmethod.println(" {"); - /* - // create the vmdata object that record the class's type - if(this.state.MULTICOREGC) { - outmethod.println(" void * " + t_cd.getSafeSymbol() + "vmdata=allocate_new("+localsprefixaddr+", "+t_cd.getId()+");"); - } else { - outmethod.println(" void * " + t_cd.getSafeSymbol() + "vmdata=allocate_new("+t_cd.getId()+");"); - } - // invoke the Class.constructor - ParamsObject objectparams=(ParamsObject)paramstable.get(bestmd); - if ((GENERATEPRECISEGC) || (this.state.MULTICOREGC)) { - outmethod.print(" struct "+classtolookin.getSafeSymbol()+bestmd.getSafeSymbol()+"_"+bestmd.getSafeMethodDescriptor()+"_params __parameterlist__={"); - outmethod.print(objectparams.numPointers()); - outmethod.print(", "+localsprefixaddr); - if (bestmd.getThis()!=null) { - outmethod.print(", "); - outmethod.print("(struct "+bestmd.getThis().getType().getSafeSymbol() +" *)&(global_defs_p->"+t_cd.getSafeSymbol()+"classobj)"); - } - - Descriptor var=bestmd.getParameter(0); - TempDescriptor paramtemp=(TempDescriptor)temptovar.get(var); - if (objectparams.isParamPtr(paramtemp)) { - outmethod.print(", "); - TypeDescriptor td=bestmd.getParamType(0); - outmethod.print("(struct "+bestmd.getParamType(0).getSafeSymbol() +" *)" + t_cd.getSafeSymbol() + "vmdata"); - } - outmethod.println("};"); - } - outmethod.print(" "); - - outmethod.print(classtolookin.getSafeSymbol()+bestmd.getSafeSymbol()+"_"+bestmd.getSafeMethodDescriptor()); - - outmethod.print("("); - boolean needcomma=false; if ((GENERATEPRECISEGC) || (this.state.MULTICOREGC)) { - outmethod.print("&__parameterlist__"); - needcomma=true; - } - - if (!GENERATEPRECISEGC && !this.state.MULTICOREGC) { - TypeDescriptor ptd=null; - if(bestmd.getThis() != null) { - ptd = bestmd.getThis().getType(); - } - if (needcomma) - outmethod.print(","); - if (ptd.isClass()&&!ptd.isArray()) - outmethod.print("(struct "+ptd.getSafeSymbol()+" *) "); - outmethod.print("&(global_defs_p->"+t_cd.getSafeSymbol()+"classobj)"); - needcomma=true; - } - - Descriptor var=bestmd.getParameter(0); - TempDescriptor paramtemp=(TempDescriptor)temptovar.get(var); - if (objectparams.isParamPrim(paramtemp)) { - if (needcomma) - outmethod.print(", "); - - TypeDescriptor ptd=bestmd.getParamType(0); - if (ptd.isClass()&&!ptd.isArray()) - outmethod.print("(struct "+ptd.getSafeSymbol()+" *) "); - outmethod.print(t_cd.getSafeSymbol() + "vmdata"); - needcomma=true; + 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(");"); - */ - outmethod.println(" global_defs_p->"+t_cd.getSafeSymbol()+"classobj = allocate_new(" + typeutil.getClass(TypeUtil.ObjectClass).getId() + ");"); outmethod.println(" global_defs_p->"+t_cd.getSafeSymbol()+"classobj->type = " + t_cd.getId() + ";"); outmethod.println(" initlock((struct ___Object___ *)((global_defs_p->"+t_cd.getSafeSymbol()+"classobj)));"); diff --git a/Robust/src/Runtime/bamboo/multicoregarbage.c b/Robust/src/Runtime/bamboo/multicoregarbage.c index 76dc4333..7ca5f39c 100644 --- a/Robust/src/Runtime/bamboo/multicoregarbage.c +++ b/Robust/src/Runtime/bamboo/multicoregarbage.c @@ -8,16 +8,24 @@ #include "ObjectHash.h" #include "GCSharedHash.h" +#ifdef TASK +#define BAMBOOMARKBIT 6 +#elif defined MGC +#define BAMBOOMARKBIT 4 +#endif // TASK + extern int corenum; +#ifdef TASK extern struct parameterwrapper ** objectqueues[][NUMCLASSES]; extern int numqueues[][NUMCLASSES]; - extern struct genhashtable * activetasks; extern struct parameterwrapper ** objectqueues[][NUMCLASSES]; extern struct taskparamdescriptor *currtpd; - extern struct LockValue runtime_locks[MAXTASKPARAMS]; extern int runtime_locklen; +#endif + +extern struct global_defs_t * global_defs_p; #ifdef SMEMM extern unsigned int gcmem_mixed_threshold; @@ -695,7 +703,7 @@ inline bool cacheLObjs() { size = gclobjtail2->lengths[gclobjtailindex2]; // set the mark field to , indicating that this obj has been moved // and need to be flushed - ((int *)(gclobjtail2->lobjs[gclobjtailindex2]))[6] = COMPACTED; + ((int *)(gclobjtail2->lobjs[gclobjtailindex2]))[BAMBOOMARKBIT] = COMPACTED; dst -= size; if((int)dst < (int)(gclobjtail2->lobjs[gclobjtailindex2])+size) { memmove(dst, gclobjtail2->lobjs[gclobjtailindex2], size); @@ -1035,10 +1043,10 @@ inline void markObj(void * objptr) { if(BAMBOO_NUM_OF_CORE == host) { // on this core BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT(); - if(((int *)objptr)[6] == INIT) { + if(((int *)objptr)[BAMBOOMARKBIT] == INIT) { // this is the first time that this object is discovered, // set the flag as DISCOVERED - ((int *)objptr)[6] |= DISCOVERED; + ((int *)objptr)[BAMBOOMARKBIT] |= DISCOVERED; BAMBOO_CACHE_FLUSH_LINE(objptr); gc_enqueue_I(objptr); } @@ -1088,8 +1096,21 @@ inline void tomark(struct garbagelist * stackptr) { } stackptr=stackptr->next; } + GC_BAMBOO_DEBUGPRINT(0xe502); + // enqueue static pointers global_defs_p + struct garbagelist * staticptr=(struct garbagelist *)global_defs_p; + while(staticptr != NULL) { + for(i=0; isize; i++) { + if(staticptr->array[i] != NULL) { + markObj(staticptr->array[i]); + } + } + staticptr = staticptr->next; + } GC_BAMBOO_DEBUGPRINT(0xe503); + +#ifdef TASK // enqueue objectsets if(BAMBOO_NUM_OF_CORE < NUMCORESACTIVE) { for(i=0; i gcmarkedptrbound) { @@ -1774,8 +1798,8 @@ innermoveobj: int length=ao->___length___; size=sizeof(struct ArrayObject)+length*elementsize; } - mark = ((int *)(origptr))[6]; - bool isremote = ((((int *)(origptr))[6] & REMOTEM) != 0); + mark = ((int *)(origptr))[BAMBOOMARKBIT]; + bool isremote = ((((int *)(origptr))[BAMBOOMARKBIT] & REMOTEM) != 0); GC_BAMBOO_DEBUGPRINT(0xe203); GC_BAMBOO_DEBUGPRINT_REG(origptr); GC_BAMBOO_DEBUGPRINT_REG(size); @@ -1811,7 +1835,7 @@ innermoveobj: } // if(to->top + isize > to->bound) // set the mark field to 2, indicating that this obj has been moved // and need to be flushed - ((int *)(origptr))[6] = COMPACTED; + ((int *)(origptr))[BAMBOOMARKBIT] = COMPACTED; INTPTR toptr = to->ptr; if(toptr != origptr) { if((int)(origptr) < (int)(toptr)+size) { @@ -2192,6 +2216,18 @@ inline void flushRuntimeObj(struct garbagelist * stackptr) { stackptr=stackptr->next; } + // flush static pointers global_defs_p + struct garbagelist * staticptr=(struct garbagelist *)global_defs_p; + for(i=0; isize; i++) { + if(staticptr->array[i] != NULL) { + void * dst = flushObj(staticptr->array[i]); + if(dst != NULL) { + staticptr->array[i] = dst; + } + } + } + +#ifdef TASK // flush objectsets if(BAMBOO_NUM_OF_CORE < NUMCORESACTIVE) { for(i=0; i___System______props___ = ___srctmp31736___; - ___arg42781___=NewString("line.separator",14); - ___arg42782___=NewString("\n",1); - { - ___s42780___=___System______setProperty____L___String____L___String___((struct ___String___ *) ___arg42781___, (struct ___String___ *) ___arg42782___); - } -#endif // MGC -} -#endif - /* Object allocation function */ #ifdef MULTICORE_GC