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();
104 void createstartupobject(int argc, char ** argv);
106 void createstartupobject();
110 #define VAR(name) ___params___->name
111 #define CALL00(name) name(struct name ## _params * ___params___)
112 #define CALL01(name, alt) name(struct name ## _params * ___params___)
113 #define CALL02(name, alt1, alt2) name(struct name ## _params * ___params___)
114 #define CALL11(name,rest, alt) name(struct name ## _params * ___params___, rest)
115 #define CALL12(name,rest, alt1, alt2) name(struct name ## _params * ___params___, rest)
116 #define CALL22(name, rest, rest2, alt1, alt2) name(struct name ## _params * ___params___, rest, rest2)
117 #define CALL23(name, rest, rest2, alt1, alt2, alt3) name(struct name ## _params * ___params___, rest, rest2)
118 #define CALL24(name, rest, rest2, alt1, alt2, alt3, alt4) name(struct name ## _params * ___params___, rest, rest2)
119 #define CALL34(name, rest, rest2, rest3, alt1, alt2, alt3, alt4) name(struct name ## _params * ___params___, rest, rest2, rest3)
120 #define CALL35(name, rest, rest2, rest3, alt1, alt2, alt3, alt4, alt5) name(struct name ## _params * ___params___, rest, rest2, rest3)
121 #elif defined MULTICORE_GC
122 #define VAR(name) ___params___->name
123 #define CALL00(name) name(struct name ## _params * ___params___)
124 #define CALL01(name, alt) name(struct name ## _params * ___params___)
125 #define CALL02(name, alt1, alt2) name(struct name ## _params * ___params___)
126 #define CALL11(name,rest, alt) name(struct name ## _params * ___params___, rest)
127 #define CALL12(name,rest, alt1, alt2) name(struct name ## _params * ___params___, rest)
128 #define CALL22(name, rest, rest2, alt1, alt2) name(struct name ## _params * ___params___, rest, rest2)
129 #define CALL23(name, rest, rest2, alt1, alt2, alt3) name(struct name ## _params * ___params___, rest, rest2)
130 #define CALL24(name, rest, rest2, alt1, alt2, alt3, alt4) name(struct name ## _params * ___params___, rest, rest2)
131 #define CALL34(name, rest, rest2, rest3, alt1, alt2, alt3, alt4) name(struct name ## _params * ___params___, rest, rest2, rest3)
132 #define CALL35(name, rest, rest2, rest3, alt1, alt2, alt3, alt4, alt5) name(struct name ## _params * ___params___, rest, rest2, rest3)
134 #define VAR(name) name
135 #define CALL00(name) name()
136 #define CALL01(name, alt) name(alt)
137 #define CALL02(name, alt1, alt2) name(alt1, alt2)
138 #define CALL11(name,rest, alt) name(alt)
139 #define CALL12(name,rest, alt1, alt2) name(alt1, alt2)
140 #define CALL22(name, rest, rest2, alt1, alt2) name(alt1, alt2)
141 #define CALL23(name, rest, rest2, alt1, alt2, alt3) name(alt1, alt2, alt3)
142 #define CALL24(name, rest, rest2, alt1, alt2, alt3, alt4) name(alt1, alt2, alt3, alt4)
143 #define CALL34(name, rest, rest2, rest3, alt1, alt2, alt3, alt4) name(alt1, alt2, alt3, alt4)
144 #define CALL35(name, rest, rest2, rest3, alt1, alt2, alt3, alt4, alt5) name(alt1, alt2, alt3, alt4, alt5)
148 #include "SimpleHash.h"
149 inline void run(int argc, char** argv);
150 int receiveObject(int send_port_pending);
151 void * smemalloc_I(int coren, int size, int * allocsize);
153 inline void setupsmemmode(void);
160 #include "ObjectHash.h"
161 #include "structdefs.h"
165 #include "optionalstruct.h"
169 struct failedtasklist {
170 struct taskdescriptor *task;
174 struct failedtasklist *next;
179 struct transObjInfo {
188 extern struct ___Object___ * ___fcrevert___;
192 void flagorand(void * ptr, int ormask, int andmask, struct parameterwrapper ** queues, int length);
193 void flagorandinit(void * ptr, int ormask, int andmask);
194 void enqueueObject(void * ptr, struct parameterwrapper ** queues,int length);
196 inline void setTaskExitIndex(int index);
197 inline void addNewObjInfo(void * nobj);
199 int * getAliasLock(void ** ptrs, int length, struct RuntimeHash * tbl);
200 void addAliasLock(void * ptr, int lock);
202 void flagorand(void * ptr, int ormask, int andmask);
203 void flagorandinit(void * ptr, int ormask, int andmask);
204 void enqueueObject(void * ptr);
210 struct tagobjectiterator {
211 int istag; /* 0 if object iterator, 1 if tag iterator */
212 struct ObjectIterator it; /* Object iterator */
213 struct ObjectHash * objectset;
218 int tagobjindex; /* Index for tag or object depending on use */
219 /*if tag we have an object binding */
222 /*if object, we may have one or more tag bindings */
224 int tagbindings[MAXTASKPARAMS-1]; /* list slots */
227 struct parameterwrapper {
228 struct parameterwrapper *next;
229 struct ObjectHash * objectset;
234 struct taskdescriptor * task;
236 struct tagobjectiterator iterators[MAXTASKPARAMS-1];
240 struct taskparamdescriptor {
241 struct taskdescriptor * task;
243 void ** parameterArray;
249 int hashCodetpd(struct taskparamdescriptor *);
250 int comparetpd(struct taskparamdescriptor *, struct taskparamdescriptor *);
252 void toiReset(struct tagobjectiterator * it);
253 int toiHasNext(struct tagobjectiterator *it, void ** objectarray OPTARG(int * failed));
254 void toiNext(struct tagobjectiterator *it, void ** objectarray OPTARG(int * failed));
255 void processobject(struct parameterwrapper *parameter, int index, struct parameterdescriptor *pd, int *iteratorcount, int * statusarray, int numparams);
256 void processtags(struct parameterdescriptor *pd, int index, struct parameterwrapper *parameter, int * iteratorcount, int *statusarray, int numparams);
257 void builditerators(struct taskdescriptor * task, int index, struct parameterwrapper * parameter);
258 int enqueuetasks(struct parameterwrapper *parameter, struct parameterwrapper *prevptr, struct ___Object___ *ptr, int * enterflags, int numenterflags);
262 #if defined(__i386__)
264 static __inline__ unsigned long long rdtsc(void)
266 unsigned long long int x;
267 __asm__ volatile (".byte 0x0f, 0x31" : "=A" (x));
270 #elif defined(__x86_64__)
272 static __inline__ unsigned long long rdtsc(void)
275 __asm__ __volatile__ ("rdtsc" : "=a"(lo), "=d"(hi));
276 return ( (unsigned long long)lo)|( ((unsigned long long)hi)<<32 );
279 #elif defined(__powerpc__)
281 typedef unsigned long long int unsigned long long;
283 static __inline__ unsigned long long rdtsc(void)
285 unsigned long long int result=0;
286 unsigned long int upper, lower,tmp;
294 : "=r"(upper),"=r"(lower),"=r"(tmp)
298 result = result|lower;