add likely/unlikely branch hints
[IRC.git] / Robust / src / Runtime / runtime.h
index fcc62a61ec452b463afb1b556f0fa5ccfc480421..d3dcc04a1fd3d1680d1e926d3516a3f4e4219574 100644 (file)
@@ -1,16 +1,34 @@
 #ifndef RUNTIME
 #define RUNTIME
+#ifndef MULTICORE
 #include <setjmp.h>
 extern jmp_buf error_handler;
 extern int instructioncount;
 extern int failurecount;
+#endif
 #ifdef DSTM
-#include "dstm.h"
+#ifdef RECOVERY
+#include "DSTM/interface_recovery/dstm.h"
+#else
+#include "DSTM/interface/dstm.h"
+#endif
+#endif
+
+#ifndef INTPTR
+#ifdef BIT64
+#define INTPTR long
+#else
+#define INTPTR int
+#endif
 #endif
 
 extern void * curr_heapbase;
 extern void * curr_heaptop;
 
+#define likely(x) __builtin_expect((x),1)
+#define unlikely(x) __builtin_expect((x),0)
+
+
 #define TAGARRAYINTERVAL 10
 #define OBJECTARRAYINTERVAL 10
 
@@ -27,21 +45,31 @@ extern void * curr_heaptop;
 #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);
+#elif defined MULTICORE_GC
+__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
 
 
@@ -80,6 +108,7 @@ void createstartupobject();
 #ifdef TASK
 #include "SimpleHash.h"
 #ifndef MULTICORE
+#include "chash.h"
 #include "ObjectHash.h"
 #include "structdefs.h"
 #endif
@@ -107,17 +136,26 @@ struct transObjInfo {
 };
 #endif
 
-#ifdef RAW
-//struct RuntimeHash * ptbl = NULL;
+#ifdef FASTCHECK
+extern struct ___Object___ * ___fcrevert___;
 #endif
 
 #ifdef MULTICORE
+inline void run(void * arg);
+#ifdef MULTICORE_GC
+inline void setupsmemmode(void);
+#endif
+int receiveObject(void);
 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);
-#endif
+void enqueueObject(void * ptr, struct parameterwrapper ** queues,int length);
+#ifdef PROFILE
+inline void setTaskExitIndex(int index);
+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);
 #else
 void flagorand(void * ptr, int ormask, int andmask);
 void flagorandinit(void * ptr, int ormask, int andmask);
@@ -126,10 +164,6 @@ void enqueueObject(void * ptr);
 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 */
@@ -180,9 +214,6 @@ void processobject(struct parameterwrapper *parameter, int index, struct paramet
 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