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 ___String___ * NewStringShort(void *, const short *str,int length);
84 __attribute__((malloc)) struct ___TagDescriptor___ * allocate_tag(void *ptr, int index);
85 #elif defined MULTICORE_GC
86 __attribute__((malloc)) void * allocate_new(void *, int type);
87 __attribute__((malloc)) struct ArrayObject * allocate_newarray(void *, int type, int length);
88 __attribute__((malloc)) struct ___String___ * NewString(void *, const char *str,int length);
89 __attribute__((malloc)) struct ___String___ * NewStringShort(void *, const short *str,int length);
90 __attribute__((malloc)) struct ___TagDescriptor___ * allocate_tag(void *ptr, int index);
92 __attribute__((malloc)) void * allocate_new(int type);
93 __attribute__((malloc)) struct ArrayObject * allocate_newarray(int type, int length);
94 __attribute__((malloc)) struct ___String___ * NewString(const char *str,int length);
95 __attribute__((malloc)) struct ___String___ * NewStringShort(const short *str,int length);
96 __attribute__((malloc)) struct ___TagDescriptor___ * allocate_tag(int index);
101 void initializeexithandler();
102 void failedboundschk(int num);
103 void failednullptr(void * stackptr);
105 void injectinstructionfailure();
107 void createstartupobject(int argc, char ** argv);
109 void createstartupobject();
113 #define VAR(name) ___params___->name
114 #define CALL00(name) name(struct name ## _params * ___params___)
115 #define CALL01(name, alt) name(struct name ## _params * ___params___)
116 #define CALL02(name, alt1, alt2) name(struct name ## _params * ___params___)
117 #define CALL11(name,rest, alt) name(struct name ## _params * ___params___, rest)
118 #define CALL12(name,rest, alt1, alt2) name(struct name ## _params * ___params___, rest)
119 #define CALL22(name, rest, rest2, alt1, alt2) name(struct name ## _params * ___params___, rest, rest2)
120 #define CALL23(name, rest, rest2, alt1, alt2, alt3) name(struct name ## _params * ___params___, rest, rest2)
121 #define CALL24(name, rest, rest2, alt1, alt2, alt3, alt4) name(struct name ## _params * ___params___, rest, rest2)
122 #define CALL34(name, rest, rest2, rest3, alt1, alt2, alt3, alt4) name(struct name ## _params * ___params___, rest, rest2, rest3)
123 #define CALL35(name, rest, rest2, rest3, alt1, alt2, alt3, alt4, alt5) name(struct name ## _params * ___params___, rest, rest2, rest3)
124 #elif defined MULTICORE_GC
125 #define VAR(name) ___params___->name
126 #define CALL00(name) name(struct name ## _params * ___params___)
127 #define CALL01(name, alt) name(struct name ## _params * ___params___)
128 #define CALL02(name, alt1, alt2) name(struct name ## _params * ___params___)
129 #define CALL11(name,rest, alt) name(struct name ## _params * ___params___, rest)
130 #define CALL12(name,rest, alt1, alt2) name(struct name ## _params * ___params___, rest)
131 #define CALL22(name, rest, rest2, alt1, alt2) name(struct name ## _params * ___params___, rest, rest2)
132 #define CALL23(name, rest, rest2, alt1, alt2, alt3) name(struct name ## _params * ___params___, rest, rest2)
133 #define CALL24(name, rest, rest2, alt1, alt2, alt3, alt4) name(struct name ## _params * ___params___, rest, rest2)
134 #define CALL34(name, rest, rest2, rest3, alt1, alt2, alt3, alt4) name(struct name ## _params * ___params___, rest, rest2, rest3)
135 #define CALL35(name, rest, rest2, rest3, alt1, alt2, alt3, alt4, alt5) name(struct name ## _params * ___params___, rest, rest2, rest3)
137 #define VAR(name) name
138 #define CALL00(name) name()
139 #define CALL01(name, alt) name(alt)
140 #define CALL02(name, alt1, alt2) name(alt1, alt2)
141 #define CALL11(name,rest, alt) name(alt)
142 #define CALL12(name,rest, alt1, alt2) name(alt1, alt2)
143 #define CALL22(name, rest, rest2, alt1, alt2) name(alt1, alt2)
144 #define CALL23(name, rest, rest2, alt1, alt2, alt3) name(alt1, alt2, alt3)
145 #define CALL24(name, rest, rest2, alt1, alt2, alt3, alt4) name(alt1, alt2, alt3, alt4)
146 #define CALL34(name, rest, rest2, rest3, alt1, alt2, alt3, alt4) name(alt1, alt2, alt3, alt4)
147 #define CALL35(name, rest, rest2, rest3, alt1, alt2, alt3, alt4, alt5) name(alt1, alt2, alt3, alt4, alt5)
151 #include "SimpleHash.h"
152 inline void run(int argc, char** argv);
153 int receiveObject(int send_port_pending);
154 void * smemalloc_I(int coren, int size, int * allocsize);
156 inline void setupsmemmode(void);
163 #include "ObjectHash.h"
164 #include "structdefs.h"
168 #include "optionalstruct.h"
172 struct failedtasklist {
173 struct taskdescriptor *task;
177 struct failedtasklist *next;
182 struct transObjInfo {
191 extern struct ___Object___ * ___fcrevert___;
195 void flagorand(void * ptr, int ormask, int andmask, struct parameterwrapper ** queues, int length);
196 void flagorandinit(void * ptr, int ormask, int andmask);
197 void enqueueObject(void * ptr, struct parameterwrapper ** queues,int length);
199 inline void setTaskExitIndex(int index);
200 inline void addNewObjInfo(void * nobj);
202 int * getAliasLock(void ** ptrs, int length, struct RuntimeHash * tbl);
203 void addAliasLock(void * ptr, int lock);
205 void flagorand(void * ptr, int ormask, int andmask);
206 void flagorandinit(void * ptr, int ormask, int andmask);
207 void enqueueObject(void * ptr);
213 struct tagobjectiterator {
214 int istag; /* 0 if object iterator, 1 if tag iterator */
215 struct ObjectIterator it; /* Object iterator */
216 struct ObjectHash * objectset;
221 int tagobjindex; /* Index for tag or object depending on use */
222 /*if tag we have an object binding */
225 /*if object, we may have one or more tag bindings */
227 int tagbindings[MAXTASKPARAMS-1]; /* list slots */
230 struct parameterwrapper {
231 struct parameterwrapper *next;
232 struct ObjectHash * objectset;
237 struct taskdescriptor * task;
239 struct tagobjectiterator iterators[MAXTASKPARAMS-1];
243 struct taskparamdescriptor {
244 struct taskdescriptor * task;
246 void ** parameterArray;
252 int hashCodetpd(struct taskparamdescriptor *);
253 int comparetpd(struct taskparamdescriptor *, struct taskparamdescriptor *);
255 void toiReset(struct tagobjectiterator * it);
256 int toiHasNext(struct tagobjectiterator *it, void ** objectarray OPTARG(int * failed));
257 void toiNext(struct tagobjectiterator *it, void ** objectarray OPTARG(int * failed));
258 void processobject(struct parameterwrapper *parameter, int index, struct parameterdescriptor *pd, int *iteratorcount, int * statusarray, int numparams);
259 void processtags(struct parameterdescriptor *pd, int index, struct parameterwrapper *parameter, int * iteratorcount, int *statusarray, int numparams);
260 void builditerators(struct taskdescriptor * task, int index, struct parameterwrapper * parameter);
261 int enqueuetasks(struct parameterwrapper *parameter, struct parameterwrapper *prevptr, struct ___Object___ *ptr, int * enterflags, int numenterflags);
265 #if defined(__i386__)
267 static __inline__ unsigned long long rdtsc(void)
269 unsigned long long int x;
270 __asm__ volatile (".byte 0x0f, 0x31" : "=A" (x));
273 #elif defined(__x86_64__)
275 static __inline__ unsigned long long rdtsc(void)
278 __asm__ __volatile__ ("rdtsc" : "=a"(lo), "=d"(hi));
279 return ( (unsigned long long)lo)|( ((unsigned long long)hi)<<32 );
282 #elif defined(__powerpc__)
284 typedef unsigned long long int unsigned long long;
286 static __inline__ unsigned long long rdtsc(void)
288 unsigned long long int result=0;
289 unsigned long int upper, lower,tmp;
297 : "=r"(upper),"=r"(lower),"=r"(tmp)
301 result = result|lower;