6 extern jmp_buf error_handler;
7 extern int instructioncount;
8 extern int failurecount;
12 #include "DSTM/interface_recovery/dstm.h"
14 #include "DSTM/interface/dstm.h"
33 // The L1 and L2 cache line size for the
34 // AMD Opteron 6168 (dc-10) is 64 bytes. Source:
35 // http://www.cs.virginia.edu/~skadron/cs451/opteron/opteron.ppt
36 #define CACHELINESIZE 64
39 extern void * curr_heapbase;
40 extern void * curr_heaptop;
42 #define likely(x) __builtin_expect((x),1)
43 #define unlikely(x) __builtin_expect((x),0)
46 #define TAGARRAYINTERVAL 10
47 #define OBJECTARRAYINTERVAL 10
49 #define ARRAYSET(array, type, index, value) \
50 ((type *)(& (& array->___length___)[1]))[index]=value
52 #define ARRAYGET(array, type, index) \
53 ((type *)(& (& array->___length___)[1]))[index]
62 __attribute__((malloc)) void * allocate_newglobal(int type);
63 __attribute__((malloc)) struct ArrayObject * allocate_newarrayglobal(int type, int length);
67 __attribute__((malloc)) void * allocate_newtrans(void * ptr, int type);
68 __attribute__((malloc)) struct ArrayObject * allocate_newarraytrans(void * ptr, int type, int length);
74 __attribute__((malloc)) void * allocate_new_mlp(void *, int type, int oid, int allocsite);
75 __attribute__((malloc)) void * allocate_new(void *, int type);
76 __attribute__((malloc)) struct ArrayObject * allocate_newarray_mlp(void *, int type, int length, int oid, int allocsite);
77 __attribute__((malloc)) struct ArrayObject * allocate_newarray(void * ptr, int type, int length);
79 __attribute__((malloc)) void * allocate_new(void *, int type);
80 __attribute__((malloc)) struct ArrayObject * allocate_newarray(void *, int type, int length);
82 __attribute__((malloc)) struct ___String___ * NewString(void *, const char *str,int length);
83 __attribute__((malloc)) struct ___TagDescriptor___ * allocate_tag(void *ptr, int index);
84 #elif defined MULTICORE_GC
85 __attribute__((malloc)) void * allocate_new(void *, int type);
86 __attribute__((malloc)) struct ArrayObject * allocate_newarray(void *, int type, int length);
87 __attribute__((malloc)) struct ___String___ * NewString(void *, const char *str,int length);
88 __attribute__((malloc)) struct ___TagDescriptor___ * allocate_tag(void *ptr, int index);
90 __attribute__((malloc)) void * allocate_new(int type);
91 __attribute__((malloc)) struct ArrayObject * allocate_newarray(int type, int length);
92 __attribute__((malloc)) struct ___String___ * NewString(const char *str,int length);
93 __attribute__((malloc)) struct ___TagDescriptor___ * allocate_tag(int index);
98 void initializeexithandler();
99 void failedboundschk();
100 void failednullptr();
102 void injectinstructionfailure();
103 void createstartupobject();
106 #define VAR(name) ___params___->name
107 #define CALL00(name) name(struct name ## _params * ___params___)
108 #define CALL01(name, alt) name(struct name ## _params * ___params___)
109 #define CALL02(name, alt1, alt2) name(struct name ## _params * ___params___)
110 #define CALL11(name,rest, alt) name(struct name ## _params * ___params___, rest)
111 #define CALL12(name,rest, alt1, alt2) name(struct name ## _params * ___params___, rest)
112 #define CALL22(name, rest, rest2, alt1, alt2) name(struct name ## _params * ___params___, rest, rest2)
113 #define CALL23(name, rest, rest2, alt1, alt2, alt3) name(struct name ## _params * ___params___, rest, rest2)
114 #define CALL24(name, rest, rest2, alt1, alt2, alt3, alt4) name(struct name ## _params * ___params___, rest, rest2)
115 #define CALL34(name, rest, rest2, rest3, alt1, alt2, alt3, alt4) name(struct name ## _params * ___params___, rest, rest2, rest3)
116 #define CALL35(name, rest, rest2, rest3, alt1, alt2, alt3, alt4, alt5) name(struct name ## _params * ___params___, rest, rest2, rest3)
117 #elif defined MULTICORE_GC
118 #define VAR(name) ___params___->name
119 #define CALL00(name) name(struct name ## _params * ___params___)
120 #define CALL01(name, alt) name(struct name ## _params * ___params___)
121 #define CALL02(name, alt1, alt2) name(struct name ## _params * ___params___)
122 #define CALL11(name,rest, alt) name(struct name ## _params * ___params___, rest)
123 #define CALL12(name,rest, alt1, alt2) name(struct name ## _params * ___params___, rest)
124 #define CALL22(name, rest, rest2, alt1, alt2) name(struct name ## _params * ___params___, rest, rest2)
125 #define CALL23(name, rest, rest2, alt1, alt2, alt3) name(struct name ## _params * ___params___, rest, rest2)
126 #define CALL24(name, rest, rest2, alt1, alt2, alt3, alt4) name(struct name ## _params * ___params___, rest, rest2)
127 #define CALL34(name, rest, rest2, rest3, alt1, alt2, alt3, alt4) name(struct name ## _params * ___params___, rest, rest2, rest3)
128 #define CALL35(name, rest, rest2, rest3, alt1, alt2, alt3, alt4, alt5) name(struct name ## _params * ___params___, rest, rest2, rest3)
130 #define VAR(name) name
131 #define CALL00(name) name()
132 #define CALL01(name, alt) name(alt)
133 #define CALL02(name, alt1, alt2) name(alt1, alt2)
134 #define CALL11(name,rest, alt) name(alt)
135 #define CALL12(name,rest, alt1, alt2) name(alt1, alt2)
136 #define CALL22(name, rest, rest2, alt1, alt2) name(alt1, alt2)
137 #define CALL23(name, rest, rest2, alt1, alt2, alt3) name(alt1, alt2, alt3)
138 #define CALL24(name, rest, rest2, alt1, alt2, alt3, alt4) name(alt1, alt2, alt3, alt4)
139 #define CALL34(name, rest, rest2, rest3, alt1, alt2, alt3, alt4) name(alt1, alt2, alt3, alt4)
140 #define CALL35(name, rest, rest2, rest3, alt1, alt2, alt3, alt4, alt5) name(alt1, alt2, alt3, alt4, alt5)
144 #include "SimpleHash.h"
145 inline void run(int argc, char** argv);
146 int receiveObject(int send_port_pending);
147 void * smemalloc_I(int coren, int size, int * allocsize);
149 inline void setupsmemmode(void);
156 #include "ObjectHash.h"
157 #include "structdefs.h"
161 #include "optionalstruct.h"
165 struct failedtasklist {
166 struct taskdescriptor *task;
170 struct failedtasklist *next;
175 struct transObjInfo {
184 extern struct ___Object___ * ___fcrevert___;
188 void flagorand(void * ptr, int ormask, int andmask, struct parameterwrapper ** queues, int length);
189 void flagorandinit(void * ptr, int ormask, int andmask);
190 void enqueueObject(void * ptr, struct parameterwrapper ** queues,int length);
192 inline void setTaskExitIndex(int index);
193 inline void addNewObjInfo(void * nobj);
195 int * getAliasLock(void ** ptrs, int length, struct RuntimeHash * tbl);
196 void addAliasLock(void * ptr, int lock);
198 void flagorand(void * ptr, int ormask, int andmask);
199 void flagorandinit(void * ptr, int ormask, int andmask);
200 void enqueueObject(void * ptr);
206 struct tagobjectiterator {
207 int istag; /* 0 if object iterator, 1 if tag iterator */
208 struct ObjectIterator it; /* Object iterator */
209 struct ObjectHash * objectset;
214 int tagobjindex; /* Index for tag or object depending on use */
215 /*if tag we have an object binding */
218 /*if object, we may have one or more tag bindings */
220 int tagbindings[MAXTASKPARAMS-1]; /* list slots */
223 struct parameterwrapper {
224 struct parameterwrapper *next;
225 struct ObjectHash * objectset;
230 struct taskdescriptor * task;
232 struct tagobjectiterator iterators[MAXTASKPARAMS-1];
236 struct taskparamdescriptor {
237 struct taskdescriptor * task;
239 void ** parameterArray;
245 int hashCodetpd(struct taskparamdescriptor *);
246 int comparetpd(struct taskparamdescriptor *, struct taskparamdescriptor *);
248 void toiReset(struct tagobjectiterator * it);
249 int toiHasNext(struct tagobjectiterator *it, void ** objectarray OPTARG(int * failed));
250 void toiNext(struct tagobjectiterator *it, void ** objectarray OPTARG(int * failed));
251 void processobject(struct parameterwrapper *parameter, int index, struct parameterdescriptor *pd, int *iteratorcount, int * statusarray, int numparams);
252 void processtags(struct parameterdescriptor *pd, int index, struct parameterwrapper *parameter, int * iteratorcount, int *statusarray, int numparams);
253 void builditerators(struct taskdescriptor * task, int index, struct parameterwrapper * parameter);
254 int enqueuetasks(struct parameterwrapper *parameter, struct parameterwrapper *prevptr, struct ___Object___ *ptr, int * enterflags, int numenterflags);
258 #if defined(__i386__)
260 static __inline__ unsigned long long rdtsc(void)
262 unsigned long long int x;
263 __asm__ volatile (".byte 0x0f, 0x31" : "=A" (x));
266 #elif defined(__x86_64__)
268 static __inline__ unsigned long long rdtsc(void)
271 __asm__ __volatile__ ("rdtsc" : "=a"(lo), "=d"(hi));
272 return ( (unsigned long long)lo)|( ((unsigned long long)hi)<<32 );
275 #elif defined(__powerpc__)
277 typedef unsigned long long int unsigned long long;
279 static __inline__ unsigned long long rdtsc(void)
281 unsigned long long int result=0;
282 unsigned long int upper, lower,tmp;
290 : "=r"(upper),"=r"(lower),"=r"(tmp)
294 result = result|lower;