Add runtime support for STM Barrier class
[IRC.git] / Robust / src / Runtime / runtime.h
index 7158c14ff1c9ad960104b00d7a4202541668decf..032eb29f3d94d248051289a85f3d2d6f96c6ccf5 100644 (file)
@@ -8,14 +8,25 @@ extern int failurecount;
 #include "dstm.h"
 #endif
 
+#ifndef INTPTR
+#ifdef BIT64
+#define INTPTR long
+#else
+#define INTPTR int
+#endif
+#endif
+
+extern void * curr_heapbase;
+extern void * curr_heaptop;
+
 #define TAGARRAYINTERVAL 10
 #define OBJECTARRAYINTERVAL 10
 
 #define ARRAYSET(array, type, index, value) \
-((type *)(&(& array->___length___)[1]))[index]=value
+  ((type *)(& (& array->___length___)[1]))[index]=value
 
 #define ARRAYGET(array, type, index) \
-((type *)(&(& array->___length___)[1]))[index]
+  ((type *)(& (& array->___length___)[1]))[index]
 
 #ifdef OPTIONAL
 #define OPTARG(x) , x
@@ -24,21 +35,26 @@ extern int failurecount;
 #endif
 
 #ifdef DSTM
-void * allocate_newglobal(transrecord_t *, int type);
-struct ArrayObject * allocate_newarrayglobal(transrecord_t *, int type, int length);
+__attribute__((malloc)) void * allocate_newglobal(int type);
+__attribute__((malloc)) struct ArrayObject * allocate_newarrayglobal(int type, int length);
+#endif
+
+#ifdef STM
+__attribute__((malloc)) void * allocate_newtrans(void * ptr, int type);
+__attribute__((malloc)) struct ArrayObject * allocate_newarraytrans(void * ptr, int type, int length);
 #endif
 
 #ifdef PRECISE_GC
 #include "garbage.h"
-void * allocate_new(void *, int type);
-struct ArrayObject * allocate_newarray(void *, int type, int length);
-struct ___String___ * NewString(void *, const char *str,int length);
-struct ___TagDescriptor___ * allocate_tag(void *ptr, int index);
+__attribute__((malloc)) void * allocate_new(void *, int type);
+__attribute__((malloc)) struct ArrayObject * allocate_newarray(void *, int type, int length);
+__attribute__((malloc)) struct ___String___ * NewString(void *, const char *str,int length);
+__attribute__((malloc)) struct ___TagDescriptor___ * allocate_tag(void *ptr, int index);
 #else
-void * allocate_new(int type);
-struct ArrayObject * allocate_newarray(int type, int length);
-struct ___String___ * NewString(const char *str,int length);
-struct ___TagDescriptor___ * allocate_tag(int index);
+__attribute__((malloc)) void * allocate_new(int type);
+__attribute__((malloc)) struct ArrayObject * allocate_newarray(int type, int length);
+__attribute__((malloc)) struct ___String___ * NewString(const char *str,int length);
+__attribute__((malloc)) struct ___TagDescriptor___ * allocate_tag(int index);
 #endif
 
 
@@ -76,9 +92,12 @@ void createstartupobject();
 
 #ifdef TASK
 #include "SimpleHash.h"
+#include "chash.h"
+#ifndef MULTICORE
 #include "ObjectHash.h"
-#include "task.h"
 #include "structdefs.h"
+#endif
+#include "task.h"
 #ifdef OPTIONAL
 #include "optionalstruct.h"
 #endif
@@ -93,11 +112,48 @@ struct failedtasklist {
 };
 #endif
 
+#ifdef MULTICORE
+struct transObjInfo {
+  void * objptr;
+  int targetcore;
+  int * queues;
+  int length;
+};
+#ifdef RAW
+struct RuntimeHash * lockRedirectTbl;
+#endif
+#endif
+
+#ifdef FASTCHECK
+extern struct ___Object___ * ___fcrevert___;
+#endif
+
+#ifdef MULTICORE
+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);
+#ifdef RAW
+void enqueueObject_I(void * ptr, struct parameterwrapper ** queues, int length);
+#ifdef RAWPROFILE
+inline void setTaskExitIndex(int index);
+inline void addNewObjInfo(void * nobj);
+#endif
+#endif
+int * getAliasLock(void ** ptrs, int length, struct RuntimeHash * tbl);
+void addAliasLock(void * ptr, int lock);
+#else
 void flagorand(void * ptr, int ormask, int andmask);
 void flagorandinit(void * ptr, int ormask, int andmask);
+void enqueueObject(void * ptr);
+#endif
 void executetasks();
 void processtasks();
 
+#ifdef MULTICORE
+void transferObject(struct transObjInfo * transObj);
+#endif
+
+#ifndef MULTICORE
 struct tagobjectiterator {
   int istag; /* 0 if object iterator, 1 if tag iterator */
   struct ObjectIterator it; /* Object iterator */
@@ -126,6 +182,7 @@ struct parameterwrapper {
   int slot;
   struct tagobjectiterator iterators[MAXTASKPARAMS-1];
 };
+#endif
 
 struct taskparamdescriptor {
   struct taskdescriptor * task;
@@ -141,11 +198,14 @@ int comparetpd(struct taskparamdescriptor *, struct taskparamdescriptor *);
 
 void toiReset(struct tagobjectiterator * it);
 int toiHasNext(struct tagobjectiterator *it, void ** objectarray OPTARG(int * failed));
-void toiNext(struct tagobjectiterator *it , void ** objectarray OPTARG(int * failed));
+void toiNext(struct tagobjectiterator *it, void ** objectarray OPTARG(int * failed));
 void processobject(struct parameterwrapper *parameter, int index, struct parameterdescriptor *pd, int *iteratorcount, int * statusarray, int numparams);
 void processtags(struct parameterdescriptor *pd, int index, struct parameterwrapper *parameter, int * iteratorcount, int *statusarray, int numparams);
 void builditerators(struct taskdescriptor * task, int index, struct parameterwrapper * parameter);
 int enqueuetasks(struct parameterwrapper *parameter, struct parameterwrapper *prevptr, struct ___Object___ *ptr, int * enterflags, int numenterflags);
+#ifdef RAW
+int enqueuetasks_I(struct parameterwrapper *parameter, struct parameterwrapper *prevptr, struct ___Object___ *ptr, int * enterflags, int numenterflags);
+#endif
 
 #endif