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)
118 #define VAR(name) name
119 #define CALL00(name) name()
120 #define CALL01(name, alt) name(alt)
121 #define CALL02(name, alt1, alt2) name(alt1, alt2)
122 #define CALL11(name,rest, alt) name(alt)
123 #define CALL12(name,rest, alt1, alt2) name(alt1, alt2)
124 #define CALL22(name, rest, rest2, alt1, alt2) name(alt1, alt2)
125 #define CALL23(name, rest, rest2, alt1, alt2, alt3) name(alt1, alt2, alt3)
126 #define CALL24(name, rest, rest2, alt1, alt2, alt3, alt4) name(alt1, alt2, alt3, alt4)
127 #define CALL34(name, rest, rest2, rest3, alt1, alt2, alt3, alt4) name(alt1, alt2, alt3, alt4)
128 #define CALL35(name, rest, rest2, rest3, alt1, alt2, alt3, alt4, alt5) name(alt1, alt2, alt3, alt4, alt5)
132 #include "SimpleHash.h"
133 inline void run(int argc, char** argv);
134 int receiveObject(int send_port_pending);
135 void * smemalloc_I(int coren, int size, int * allocsize);
137 inline void setupsmemmode(void);
144 #include "ObjectHash.h"
145 #include "structdefs.h"
149 #include "optionalstruct.h"
153 struct failedtasklist {
154 struct taskdescriptor *task;
158 struct failedtasklist *next;
163 struct transObjInfo {
172 extern struct ___Object___ * ___fcrevert___;
176 void flagorand(void * ptr, int ormask, int andmask, struct parameterwrapper ** queues, int length);
177 void flagorandinit(void * ptr, int ormask, int andmask);
178 void enqueueObject(void * ptr, struct parameterwrapper ** queues,int length);
180 inline void setTaskExitIndex(int index);
181 inline void addNewObjInfo(void * nobj);
183 int * getAliasLock(void ** ptrs, int length, struct RuntimeHash * tbl);
184 void addAliasLock(void * ptr, int lock);
186 void flagorand(void * ptr, int ormask, int andmask);
187 void flagorandinit(void * ptr, int ormask, int andmask);
188 void enqueueObject(void * ptr);
194 struct tagobjectiterator {
195 int istag; /* 0 if object iterator, 1 if tag iterator */
196 struct ObjectIterator it; /* Object iterator */
197 struct ObjectHash * objectset;
202 int tagobjindex; /* Index for tag or object depending on use */
203 /*if tag we have an object binding */
206 /*if object, we may have one or more tag bindings */
208 int tagbindings[MAXTASKPARAMS-1]; /* list slots */
211 struct parameterwrapper {
212 struct parameterwrapper *next;
213 struct ObjectHash * objectset;
218 struct taskdescriptor * task;
220 struct tagobjectiterator iterators[MAXTASKPARAMS-1];
224 struct taskparamdescriptor {
225 struct taskdescriptor * task;
227 void ** parameterArray;
233 int hashCodetpd(struct taskparamdescriptor *);
234 int comparetpd(struct taskparamdescriptor *, struct taskparamdescriptor *);
236 void toiReset(struct tagobjectiterator * it);
237 int toiHasNext(struct tagobjectiterator *it, void ** objectarray OPTARG(int * failed));
238 void toiNext(struct tagobjectiterator *it, void ** objectarray OPTARG(int * failed));
239 void processobject(struct parameterwrapper *parameter, int index, struct parameterdescriptor *pd, int *iteratorcount, int * statusarray, int numparams);
240 void processtags(struct parameterdescriptor *pd, int index, struct parameterwrapper *parameter, int * iteratorcount, int *statusarray, int numparams);
241 void builditerators(struct taskdescriptor * task, int index, struct parameterwrapper * parameter);
242 int enqueuetasks(struct parameterwrapper *parameter, struct parameterwrapper *prevptr, struct ___Object___ *ptr, int * enterflags, int numenterflags);
246 #if defined(__i386__)
248 static __inline__ unsigned long long rdtsc(void)
250 unsigned long long int x;
251 __asm__ volatile (".byte 0x0f, 0x31" : "=A" (x));
254 #elif defined(__x86_64__)
256 static __inline__ unsigned long long rdtsc(void)
259 __asm__ __volatile__ ("rdtsc" : "=a"(lo), "=d"(hi));
260 return ( (unsigned long long)lo)|( ((unsigned long long)hi)<<32 );
263 #elif defined(__powerpc__)
265 typedef unsigned long long int unsigned long long;
267 static __inline__ unsigned long long rdtsc(void)
269 unsigned long long int result=0;
270 unsigned long int upper, lower,tmp;
278 : "=r"(upper),"=r"(lower),"=r"(tmp)
282 result = result|lower;