add batch-mode script
[IRC.git] / Robust / src / Runtime / mem.c
index bc5216fa9f7056e9ff3dfdd81cd10e6f5fef902d..80caa39228eeeab4645cdfd751faae86188eadcd 100644 (file)
@@ -2,41 +2,59 @@
 
 #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);