#include "multicoreruntime.h"
#include "multicoregarbage.h"
#include "markbit.h"
+#include "multicoremem_helper.h"
int gc_countRunningCores() {
int count=0;
void compacthelper(struct moveHelper * orig,struct moveHelper * to) {
bool senttopmessage=false;
while(true) {
- if ((gcheaptop < ((unsigned INTPTR)(to->bound-to->ptr)))&&!senttopmessage) {
+ if ((gccurr_heaptop < ((unsigned INTPTR)(to->bound-to->ptr)))&&!senttopmessage) {
//This block is the last for this core...let the startup know
- send_msg_3(STARTUPCORE, GCRETURNMEM, BAMBOO_NUM_OF_CORE, to->ptr+gcheaptop);
+ send_msg_3(STARTUPCORE, GCRETURNMEM, BAMBOO_NUM_OF_CORE, to->ptr+gccurr_heaptop);
//Only send the message once
senttopmessage=true;
}
}
void * checkNeighbors(int corenum, unsigned INTPTR requiredmem) {
- int minblockindex=allocation.lowestfreeblock/NUMCORES4GC;
- block_t toplocalblock=topblock/NUMCORES4GC;
+ int minblockindex=allocationinfo.lowestfreeblock/NUMCORES4GC;
for(int i=0;i<NUM_CORES2TEST;i++) {
int neighborcore=core2test[corenum][i];
if (neighborcore!=-1) {
return NULL;
}
-void * globalSearch(unsigned int topblock) {
+void * globalSearch(unsigned int topblock, unsigned INTPTR requiredmem) {
unsigned int firstfree=NOFREEBLOCK;
for(block_t i=allocationinfo.lowestfreeblock;i<topblock;i++) {
struct blockrecord * block=&allocationinfo.blocktable[i];
//we have a block
//mark block as used
block->status=BS_USED;
- void *blockptr=OFFSET2BASEVA(globalblockindex)+gcbaseva;
+ void *blockptr=OFFSET2BASEVA(i)+gcbaseva;
unsigned INTPTR usedspace=((block->usedspace-1)&~BAMBOO_CACHE_LINE_MASK)+BAMBOO_CACHE_LINE_SIZE;
allocationinfo.lowestfreeblock=firstfree;
return blockptr+usedspace;
/* should be invoked with interrupt turned off */
-void * gcfindSpareMem_I(unsigned int requiredmem,unsigned int requiredcore) {
+void * gcfindSpareMem_I(unsigned INTPTR requiredmem,unsigned int requiredcore) {
if (allocationinfo.lowestfreeblock!=NOFREEBLOCK) {
//There are spare blocks
unsigned int topblock=numblockspercore*NUMCORES4GC;
origptr=origbound;
to->ptr=toptr;
orig->ptr=origptr;
- gcheaptop-=(unsigned INTPTR)(toptr-toptrinit)
+ gccurr_heaptop-=(unsigned INTPTR)(toptr-toptrinit);
return 0;
}
} while(!gcmarktbl[arrayoffset]);
unsigned int length=ALIGNSIZETOBYTES(objlength);
void *endtoptr=toptr+length;
if (endtoptr>tobound) {
- gcheaptop-=(unsigned INTPTR)(toptr-toptrinit)
+ gccurr_heaptop-=(unsigned INTPTR)(toptr-toptrinit);
to->ptr=tobound;
orig->ptr=origptr;
return length;
gc_resetCoreStatus();
//initialize local data structures first....we don't want remote requests messing data up
unsigned int initblocks=numblockspercore*NUMCORES4GC;
- allocationinfo.lowestfreeblock=NOFREEBLOCKS;
+ allocationinfo.lowestfreeblock=NOFREEBLOCK;
//assigned blocks
for(int i=0;i<initblocks;i++) {
MSG_INDEXINC_I();
unsigned int blockindex;
BLOCKINDEX(blockindex, heaptop);
- unsigned INTPTR localblocknum=GLOBALBLOCK2LOCK(blockindex);
+ unsigned INTPTR localblocknum=GLOBALBLOCK2LOCAL(blockindex);
struct blockrecord * blockrecord=&allocationinfo.blocktable[blockindex];
MSG_INDEXINC_I();
}
-INLINE void processmsg_gclobjinfo_I(unsigned int data1) {
+INLINE void processmsg_gclobjinfo_I(unsigned int msglength) {
numconfirm--;
- int data2 = msgdata[msgdataindex];
+ int cnum = msgdata[msgdataindex];
MSG_INDEXINC_I();
BAMBOO_ASSERT(BAMBOO_NUM_OF_CORE <= NUMCORES4GC - 1);
// store the mark result info
- int cnum = data2;
gcloads[cnum] = msgdata[msgdataindex];
MSG_INDEXINC_I();
- int data4 = msgdata[msgdataindex];
- MSG_INDEXINC_I();
- if(gcheaptop < data4) {
- gcheaptop = data4;
- }
+
// large obj info here
- for(int k = 4; k < data1; k+=2) {
+ for(int k = 3; k < msglength; k+=2) {
int lobj = msgdata[msgdataindex];
MSG_INDEXINC_I();
int length = msgdata[msgdataindex];