Changes to accommodate the runtime for multicore gc w/o tasks
[IRC.git] / Robust / src / Runtime / runtime.h
index 50cd81738383e850d2166b98af677a65d5ac1a09..47b912833fc13679d10d5dd585c7054962697305 100644 (file)
@@ -62,8 +62,15 @@ __attribute__((malloc)) struct ArrayObject * allocate_newarraytrans(void * ptr,
 
 #ifdef PRECISE_GC
 #include "garbage.h"
+#ifdef MLP
+__attribute__((malloc)) void * allocate_new_mlp(void *, int type, int oid, int allocsite);
+__attribute__((malloc)) void * allocate_new(void *, int type);
+__attribute__((malloc)) struct ArrayObject * allocate_newarray_mlp(void *, int type, int length, int oid, int allocsite);
+__attribute__((malloc)) struct ArrayObject * allocate_newarray(void * ptr, int type, int length);
+#else
 __attribute__((malloc)) void * allocate_new(void *, int type);
 __attribute__((malloc)) struct ArrayObject * allocate_newarray(void *, int type, int length);
+#endif
 __attribute__((malloc)) struct ___String___ * NewString(void *, const char *str,int length);
 __attribute__((malloc)) struct ___TagDescriptor___ * allocate_tag(void *ptr, int index);
 #elif defined MULTICORE_GC
@@ -98,6 +105,7 @@ void createstartupobject();
 #define CALL23(name, rest, rest2, alt1, alt2, alt3) name(struct name ## _params * ___params___, rest, rest2)
 #define CALL24(name, rest, rest2, alt1, alt2, alt3, alt4) name(struct name ## _params * ___params___, rest, rest2)
 #define CALL34(name, rest, rest2, rest3, alt1, alt2, alt3, alt4) name(struct name ## _params * ___params___, rest, rest2, rest3)
+#define CALL35(name, rest, rest2, rest3, alt1, alt2, alt3, alt4, alt5) name(struct name ## _params * ___params___, rest, rest2, rest3)
 #else
 #define VAR(name) name
 #define CALL00(name) name()
@@ -109,6 +117,7 @@ void createstartupobject();
 #define CALL23(name, rest, rest2, alt1, alt2, alt3) name(alt1, alt2, alt3)
 #define CALL24(name, rest, rest2, alt1, alt2, alt3, alt4) name(alt1, alt2, alt3, alt4)
 #define CALL34(name, rest, rest2, rest3, alt1, alt2, alt3, alt4) name(alt1, alt2, alt3, alt4)
+#define CALL35(name, rest, rest2, rest3, alt1, alt2, alt3, alt4, alt5) name(alt1, alt2, alt3, alt4, alt5)
 #endif
 
 #ifdef TASK
@@ -151,7 +160,7 @@ inline void run(void * arg);
 #ifdef MULTICORE_GC
 inline void setupsmemmode(void);
 #endif
-int receiveObject(void);
+int receiveObject(int send_port_pending);
 void flagorand(void * ptr, int ormask, int andmask, struct parameterwrapper ** queues, int length);
 void flagorandinit(void * ptr, int ormask, int andmask);
 void enqueueObject(void * ptr, struct parameterwrapper ** queues,int length);
@@ -161,7 +170,7 @@ inline void addNewObjInfo(void * nobj);
 #endif
 int * getAliasLock(void ** ptrs, int length, struct RuntimeHash * tbl);
 void addAliasLock(void * ptr, int lock);
-void * smemalloc(int coren, int size, int * allocsize);
+void * smemalloc_I(int coren, int size, int * allocsize);
 #else
 void flagorand(void * ptr, int ormask, int andmask);
 void flagorandinit(void * ptr, int ormask, int andmask);
@@ -223,4 +232,47 @@ int enqueuetasks(struct parameterwrapper *parameter, struct parameterwrapper *pr
 
 #endif
 
+#if defined(__i386__)
+
+static __inline__ unsigned long long rdtsc(void)
+{
+  unsigned long long int x;
+  __asm__ volatile (".byte 0x0f, 0x31" : "=A" (x));
+  return x;
+}
+#elif defined(__x86_64__)
+
+static __inline__ unsigned long long rdtsc(void)
+{
+  unsigned hi, lo;
+  __asm__ __volatile__ ("rdtsc" : "=a"(lo), "=d"(hi));
+  return ( (unsigned long long)lo)|( ((unsigned long long)hi)<<32 );
+}
+
+#elif defined(__powerpc__)
+
+typedef unsigned long long int unsigned long long;
+
+static __inline__ unsigned long long rdtsc(void)
+{
+  unsigned long long int result=0;
+  unsigned long int upper, lower,tmp;
+  __asm__ volatile(
+      "0:                  \n"
+      "\tmftbu   %0           \n"
+      "\tmftb    %1           \n"
+      "\tmftbu   %2           \n"
+      "\tcmpw    %2,%0        \n"
+      "\tbne     0b         \n"
+      : "=r"(upper),"=r"(lower),"=r"(tmp)
+                  );
+  result = upper;
+  result = result<<32;
+  result = result|lower;
+
+  return(result);
+}
+#endif
+
+
 #endif