public static void genReach();
private static Properties props;
- private static native Properties initProperties();
static {
- initProperties();
+ setProperty("line.separator", "\n");
}
public static Properties getProperties() {
}
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) {
output.println(" void * next;");
for(int i=0; i<objecttemps.numPointers(); i++) {
TempDescriptor temp=objecttemps.getPointer(i);
- if (temp.getType().isNull())
+ if (!temp.getType().isArray() && temp.getType().isNull())
output.println(" void * "+temp.getSafeSymbol()+";");
else
output.println(" struct "+temp.getType().getSafeSymbol()+" * "+temp.getSafeSymbol()+";");
output.println(" void * next;");
for(int i=0; i<objecttemps.numPointers(); i++) {
TempDescriptor temp=objecttemps.getPointer(i);
- if (temp.getType().isNull())
+ if (!temp.getType().isArray() && temp.getType().isNull())
output.println(" void * "+temp.getSafeSymbol()+";");
else
output.println(" struct "+temp.getType().getSafeSymbol()+" * "+temp.getSafeSymbol()+";");
output.println(" void * next;");
for(int i=0; i<objecttemps.numPointers(); i++) {
TempDescriptor temp=objecttemps.getPointer(i);
- if (temp.getType().isNull())
+ if (!temp.getType().isArray() && temp.getType().isNull())
output.println(" void * "+temp.getSafeSymbol()+";");
else if(temp.getType().isTag())
output.println(" struct "+
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;");
}
}
}
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;
}
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;");
}
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;");
}
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);
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)));");
#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;
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);
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);
}
}
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; i<staticptr->size; 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<NUMCLASSES; i++) {
markObj((void *)(runtime_locks[i].value));
}
}
-
GC_BAMBOO_DEBUGPRINT(0xe509);
+#endif
+
#ifdef MGC
// enqueue global thread queue
lockthreadqueue();
int host = hostcore(ptr);
bool islocal = (host == BAMBOO_NUM_OF_CORE);
if(islocal) {
- bool isnotmarked = ((((int *)ptr)[6] & DISCOVERED) != 0);
+ bool isnotmarked = ((((int *)ptr)[BAMBOOMARKBIT] & DISCOVERED) != 0);
if(isLarge(ptr, &type, &size) && isnotmarked) {
// ptr is a large object and not marked or enqueued
GC_BAMBOO_DEBUGPRINT(0xecec);
gcnumlobjs++;
BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
// mark this obj
- ((int *)ptr)[6] = ((int *)ptr)[6] & (~DISCOVERED) | MARKED;
+ ((int *)ptr)[BAMBOOMARKBIT] =
+ ((int *)ptr)[BAMBOOMARKBIT] & (~DISCOVERED) | MARKED;
BAMBOO_CACHE_FLUSH_LINE(ptr);
} else if(isnotmarked) {
// ptr is an unmarked active object on this core
GC_BAMBOO_DEBUGPRINT_REG(isize);
GC_BAMBOO_DEBUGPRINT(((int *)(ptr))[0]);
// mark this obj
- ((int *)ptr)[6] = ((int *)ptr)[6] & (~DISCOVERED) | MARKED;
+ ((int *)ptr)[BAMBOOMARKBIT] =
+ ((int *)ptr)[BAMBOOMARKBIT] & (~DISCOVERED) | MARKED;
BAMBOO_CACHE_FLUSH_LINE(ptr);
if(ptr + size > gcmarkedptrbound) {
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);
} // 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) {
stackptr=stackptr->next;
}
+ // flush static pointers global_defs_p
+ struct garbagelist * staticptr=(struct garbagelist *)global_defs_p;
+ for(i=0; i<staticptr->size; 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<NUMCLASSES; i++) {
}
}
}
+#endif
#ifdef MGC
// flush global thread queue
BAMBOO_EXIT(0xb004);
}
} // if(ISSHAREDOBJ(ptr))
- if((!ISSHAREDOBJ(ptr)) || (((int *)(ptr))[6] == COMPACTED)) {
+ if((!ISSHAREDOBJ(ptr)) || (((int *)(ptr))[BAMBOOMARKBIT] == COMPACTED)) {
int type = ((int *)(ptr))[0];
// scan all pointers in ptr
unsigned INTPTR * pointer;
} // if (pointer==0) else if (((INTPTR)pointer)==1) else ()
// restore the mark field, indicating that this obj has been flushed
if(ISSHAREDOBJ(ptr)) {
- ((int *)(ptr))[6] = INIT;
+ ((int *)(ptr))[BAMBOOMARKBIT] = INIT;
}
- } // if((!ISSHAREDOBJ(ptr)) || (((int *)(ptr))[6] == COMPACTED))
+ } // if((!ISSHAREDOBJ(ptr)) || (((int *)(ptr))[BAMBOOMARKBIT] == COMPACTED))
} // while(gc_moreItems())
GC_BAMBOO_DEBUGPRINT(0xe308);
if(ptr == NULL) {
BAMBOO_EXIT(0xb005);
}
- if(((int *)(ptr))[6] == COMPACTED) {
+ if(((int *)(ptr))[BAMBOOMARKBIT] == COMPACTED) {
int type = ((int *)(ptr))[0];
// scan all pointers in ptr
unsigned INTPTR * pointer;
} // for(i=1; i<=size; i++)
} // if (pointer==0) else if (((INTPTR)pointer)==1) else ()
// restore the mark field, indicating that this obj has been flushed
- ((int *)(ptr))[6] = INIT;
- } // if(((int *)(ptr))[6] == COMPACTED)
+ ((int *)(ptr))[BAMBOOMARKBIT] = INIT;
+ } // if(((int *)(ptr))[BAMBOOMARKBIT] == COMPACTED)
} // while(gc_lobjmoreItems())
GC_BAMBOO_DEBUGPRINT(0xe310);
return false;
}
+ if(BAMBOO_NUM_OF_CORE==0) tprintf("GC starts!\n"); // TODO
+
#ifdef GC_CACHE_ADAPT
#ifdef GC_CACHE_SAMPLING
// disable the timer interrupt
#else
#define BAMBOO_RMSP_SIZE (BAMBOO_SMEM_SIZE) // (45 * 16 * 1024)
#endif
-mspace bamboo_rmsp;
+//extern mspace bamboo_rmsp;
// shared pointer mapping tbl
mgcsharedhashtbl_t * gcsharedptbl;
// remote shared pointer tbls
} jvalue;
#ifdef D___Double______doubleToRawLongBits____D
-long long CALL11(___Double______doubleToRawLongBits____D, double dval, double dval) {
+long long CALL11(___Double______doubleToRawLongBits____D, double ___value___, double ___value___) {
jvalue val;
- val.d = dval;
+ val.d = ___value___;
#if defined(__IEEE_BYTES_LITTLE_ENDIAN)
/* On little endian ARM processors when using FPA, word order of
#endif
#ifdef D___Double______longBitsToDouble____J
-double CALL11(___Double______longBitsToDouble____J, long long lval, long long lval) {
+double CALL11(___Double______longBitsToDouble____J, long long ___bits___, long long ___bits___) {
jvalue val;
- val.j = lval;
+ val.j = ___bits___;
#if defined(__IEEE_BYTES_LITTLE_ENDIAN)
#ifndef SWAP_DOUBLE
#endif // MGC
}
-#ifdef D___System______initProperties____
-struct ___Properties___ * CALL00(___System______initProperties____) {
-#ifdef MGC
- struct ___Properties___ * ___srctmp31736___;
- struct ___String___ * ___arg42781___;
- struct ___String___ * ___arg42782___;
- struct ___String___ * ___s42780___;
- ___srctmp31736___=allocate_new(76);
- {
- ___Properties______Properties____((struct ___Properties___ *) ___srctmp31736___);
- }
- global_defs_p->___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