#ifdef MULTICORE
#include "runtime.h"
+#include <stdio.h>
+
+#if defined(MULTICORE_GC)||defined(PMC_GC)
+#include "multicoreruntime.h"
+#include "bambooalign.h"
#include "runtime_arch.h"
+#include "methodheaders.h"
+#endif
#ifdef MULTICORE_GC
-#include "bambooalign.h"
+#include "multicoremem.h"
+#include "multicoregarbage.h"
+#endif
+#ifdef PMC_GC
+#include "multicoregc.h"
+#include "pmc_garbage.h"
+#endif
+#if defined(MULTICORE_GC)||defined(PMC_GC)
extern volatile bool gcflag;
void * mycalloc_share(struct garbagelist * stackptr, int size) {
void * p = NULL;
int isize = ((size-1)&(~(ALIGNMENTSIZE-1)))+ALIGNMENTSIZE;
int hasgc = 0;
+ int loopcount = 0;
while(true) {
- if(gcflag) {
- gc(stackptr);
- }
p = BAMBOO_SHARE_MEM_CALLOC(isize); // calloc(m, isize);
- if(p == NULL) {
- // no more global shared memory
- if(hasgc < 5) {
- // start gc
- if(gcflag) {
- gc(stackptr);
- }
+ if(p != NULL)
+ return p;
+
+ // no more global shared memory
+ if(hasgc < 30) {
+ // start gc
+ if(gcflag) {
+ gc(stackptr);
hasgc++;
- } else {
- // no more global shared memory
- BAMBOO_EXIT();
}
- } else
- break;
+ } else {
+ // no more global shared memory
+ printf("Did %u collections without getting memory\n", hasgc);
+ BAMBOO_EXIT();
+ }
+ loopcount++;
+ if (loopcount>10000000)
+ tprintf("Loopcount in mycalloc_share hit %u\n",loopcount);
}
-
- return p;
+
+ BAMBOO_EXIT();
+ return NULL;
}
+
#else
void * mycalloc_share(int size) {
int isize = ((size-1)&(~(BAMBOO_CACHE_LINE_MASK)))+(BAMBOO_CACHE_LINE_SIZE);