#ifdef GC_TBL_DEBUG
unsigned int gcsbstarttbl_len;
#endif
-unsigned int gcreservedsb; // number of reserved sblock for sbstarttbl
unsigned int gcnumblock; // number of total blocks in the shared mem
unsigned int gcbaseva; // base va for shared memory without reserved sblocks
#ifdef GC_CACHE_ADAPT
#define ISSHAREDOBJ(p) \
((((unsigned int)p)>=gcbaseva)&&(((unsigned int)p)<(gcbaseva+(BAMBOO_SHARED_MEM_SIZE))))
-#define ALIGNSIZE(s, as) \
- (*((unsigned int*)as))=((((unsigned int)(s-1))&(~(BAMBOO_CACHE_LINE_MASK)))+(BAMBOO_CACHE_LINE_SIZE))
+
+#define ALIGNMENTBYTES 32
+#define ALIGNMENTSHIFT 5
+#define ALIGNSIZE(x) (x>>ALIGNMENTSHIFT)
// mapping of pointer to block # (start from 0), here the block # is
// the global index
INLINE void gettype_size(void * ptr, int * ttype, unsigned int * tsize) {
int type = ((int *)ptr)[0];
- unsigned int size;
if(type < NUMCLASSES) {
// a normal object
*tsize = classsize[type];
}
}
+/* THIS FUNCTION IS BAD!!!!!!!!!!!!!! */
INLINE bool isLarge(void * ptr, int * ttype, unsigned int * tsize) {
- // check if a pointer is referring to a large object
+ // check if a pointer refers to a large object
gettype_size(ptr, ttype, tsize);
- unsigned int bound = (BAMBOO_SMEM_SIZE);
- if(((unsigned int)ptr-gcbaseva) < (BAMBOO_LARGE_SMEM_BOUND)) {
- bound = (BAMBOO_SMEM_SIZE_L);
- }
- // ptr is a start of a block OR it acrosses the boundary of current block
- return (((((unsigned int)ptr-gcbaseva)%(bound))==0)||
- ((bound-(((unsigned int)ptr-gcbaseva)%bound)) < (*tsize)));
+ unsigned int blocksize = (((unsigned int)ptr-gcbaseva) < (BAMBOO_LARGE_SMEM_BOUND))? BAMBOO_SMEM_SIZE_L:BAMBOO_SMEM_SIZE;
+
+ // ptr is a start of a block OR it crosses the boundary of current block
+ return (((((unsigned int)ptr-gcbaseva)%blocksize)==0)||
+ ((blocksize-(((unsigned int)ptr-gcbaseva)%blocksize)) < (*tsize)));
}
INLINE unsigned int hostcore(void * ptr) {
if(1 == (NUMCORES4GC)) {
host = 0;
} else {
- unsigned int b;
unsigned int t = (unsigned int)ptr - (unsigned int)gcbaseva;
- if(t < (BAMBOO_LARGE_SMEM_BOUND)) {
- b = t / (BAMBOO_SMEM_SIZE_L);
- } else {
- b = NUMCORES4GC+((t-(BAMBOO_LARGE_SMEM_BOUND))/(BAMBOO_SMEM_SIZE));
- }
+ unsigned int b = (t < BAMBOO_LARGE_SMEM_BOUND) ? t / (BAMBOO_SMEM_SIZE_L) : NUMCORES4GC+((t-(BAMBOO_LARGE_SMEM_BOUND))/(BAMBOO_SMEM_SIZE));
host = gc_block2core[(b%(NUMCORES4GC*2))];
}
return host;
}
+
//push the null check into the mark macro
//#define MARKOBJ(objptr, ii) {void * marktmpptr=objptr; if (marktmpptr!=NULL) markObj(marktmpptr, __LINE__, ii);}
gc_enqueue(objptr);
}
} else {
- // check if this obj has been forwarded
+ // check if this obj has been forwarded already
if(!MGCHashcontains(gcforwardobjtbl, (int)objptr)) {
- // send a msg to host informing that objptr is active
+ // if not, send msg to host informing that objptr is active
send_msg_2(host,GCMARKEDOBJ,objptr);
GCPROFILE_RECORD_FORWARD_OBJ();
gcself_numsendobjs++;