5 extern jmp_buf error_handler;
6 extern int instructioncount;
7 extern int failurecount;
11 #include "DSTM/interface_recovery/dstm.h"
13 #include "DSTM/interface/dstm.h"
27 extern void * curr_heapbase;
28 extern void * curr_heaptop;
30 #define likely(x) __builtin_expect((x),1)
31 #define unlikely(x) __builtin_expect((x),0)
34 #define TAGARRAYINTERVAL 10
35 #define OBJECTARRAYINTERVAL 10
37 #define ARRAYSET(array, type, index, value) \
38 ((type *)(& (& array->___length___)[1]))[index]=value
40 #define ARRAYGET(array, type, index) \
41 ((type *)(& (& array->___length___)[1]))[index]
50 __attribute__((malloc)) void * allocate_newglobal(int type);
51 __attribute__((malloc)) struct ArrayObject * allocate_newarrayglobal(int type, int length);
55 __attribute__((malloc)) void * allocate_newtrans(void * ptr, int type);
56 __attribute__((malloc)) struct ArrayObject * allocate_newarraytrans(void * ptr, int type, int length);
61 __attribute__((malloc)) void * allocate_new(void *, int type);
62 __attribute__((malloc)) struct ArrayObject * allocate_newarray(void *, int type, int length);
63 __attribute__((malloc)) struct ___String___ * NewString(void *, const char *str,int length);
64 __attribute__((malloc)) struct ___TagDescriptor___ * allocate_tag(void *ptr, int index);
65 #elif defined MULTICORE_GC
66 __attribute__((malloc)) void * allocate_new(void *, int type);
67 __attribute__((malloc)) struct ArrayObject * allocate_newarray(void *, int type, int length);
68 __attribute__((malloc)) struct ___String___ * NewString(void *, const char *str,int length);
69 __attribute__((malloc)) struct ___TagDescriptor___ * allocate_tag(void *ptr, int index);
71 __attribute__((malloc)) void * allocate_new(int type);
72 __attribute__((malloc)) struct ArrayObject * allocate_newarray(int type, int length);
73 __attribute__((malloc)) struct ___String___ * NewString(const char *str,int length);
74 __attribute__((malloc)) struct ___TagDescriptor___ * allocate_tag(int index);
79 void initializeexithandler();
80 void failedboundschk();
83 void injectinstructionfailure();
84 void createstartupobject();
87 #define VAR(name) ___params___->name
88 #define CALL00(name) name(struct name ## _params * ___params___)
89 #define CALL01(name, alt) name(struct name ## _params * ___params___)
90 #define CALL02(name, alt1, alt2) name(struct name ## _params * ___params___)
91 #define CALL11(name,rest, alt) name(struct name ## _params * ___params___, rest)
92 #define CALL12(name,rest, alt1, alt2) name(struct name ## _params * ___params___, rest)
93 #define CALL22(name, rest, rest2, alt1, alt2) name(struct name ## _params * ___params___, rest, rest2)
94 #define CALL23(name, rest, rest2, alt1, alt2, alt3) name(struct name ## _params * ___params___, rest, rest2)
95 #define CALL24(name, rest, rest2, alt1, alt2, alt3, alt4) name(struct name ## _params * ___params___, rest, rest2)
96 #define CALL34(name, rest, rest2, rest3, alt1, alt2, alt3, alt4) name(struct name ## _params * ___params___, rest, rest2, rest3)
98 #define VAR(name) name
99 #define CALL00(name) name()
100 #define CALL01(name, alt) name(alt)
101 #define CALL02(name, alt1, alt2) name(alt1, alt2)
102 #define CALL11(name,rest, alt) name(alt)
103 #define CALL12(name,rest, alt1, alt2) name(alt1, alt2)
104 #define CALL22(name, rest, rest2, alt1, alt2) name(alt1, alt2)
105 #define CALL23(name, rest, rest2, alt1, alt2, alt3) name(alt1, alt2, alt3)
106 #define CALL24(name, rest, rest2, alt1, alt2, alt3, alt4) name(alt1, alt2, alt3, alt4)
107 #define CALL34(name, rest, rest2, rest3, alt1, alt2, alt3, alt4) name(alt1, alt2, alt3, alt4)
111 #include "SimpleHash.h"
114 #include "ObjectHash.h"
115 #include "structdefs.h"
119 #include "optionalstruct.h"
123 struct failedtasklist {
124 struct taskdescriptor *task;
128 struct failedtasklist *next;
133 struct transObjInfo {
142 extern struct ___Object___ * ___fcrevert___;
146 inline void run(void * arg);
148 inline void setupsmemmode(void);
150 int receiveObject(void);
151 void flagorand(void * ptr, int ormask, int andmask, struct parameterwrapper ** queues, int length);
152 void flagorandinit(void * ptr, int ormask, int andmask);
153 void enqueueObject(void * ptr, struct parameterwrapper ** queues,int length);
155 inline void setTaskExitIndex(int index);
156 inline void addNewObjInfo(void * nobj);
158 int * getAliasLock(void ** ptrs, int length, struct RuntimeHash * tbl);
159 void addAliasLock(void * ptr, int lock);
160 void * smemalloc(int coren, int size, int * allocsize);
162 void flagorand(void * ptr, int ormask, int andmask);
163 void flagorandinit(void * ptr, int ormask, int andmask);
164 void enqueueObject(void * ptr);
170 struct tagobjectiterator {
171 int istag; /* 0 if object iterator, 1 if tag iterator */
172 struct ObjectIterator it; /* Object iterator */
173 struct ObjectHash * objectset;
178 int tagobjindex; /* Index for tag or object depending on use */
179 /*if tag we have an object binding */
182 /*if object, we may have one or more tag bindings */
184 int tagbindings[MAXTASKPARAMS-1]; /* list slots */
187 struct parameterwrapper {
188 struct parameterwrapper *next;
189 struct ObjectHash * objectset;
194 struct taskdescriptor * task;
196 struct tagobjectiterator iterators[MAXTASKPARAMS-1];
200 struct taskparamdescriptor {
201 struct taskdescriptor * task;
203 void ** parameterArray;
209 int hashCodetpd(struct taskparamdescriptor *);
210 int comparetpd(struct taskparamdescriptor *, struct taskparamdescriptor *);
212 void toiReset(struct tagobjectiterator * it);
213 int toiHasNext(struct tagobjectiterator *it, void ** objectarray OPTARG(int * failed));
214 void toiNext(struct tagobjectiterator *it, void ** objectarray OPTARG(int * failed));
215 void processobject(struct parameterwrapper *parameter, int index, struct parameterdescriptor *pd, int *iteratorcount, int * statusarray, int numparams);
216 void processtags(struct parameterdescriptor *pd, int index, struct parameterwrapper *parameter, int * iteratorcount, int *statusarray, int numparams);
217 void builditerators(struct taskdescriptor * task, int index, struct parameterwrapper * parameter);
218 int enqueuetasks(struct parameterwrapper *parameter, struct parameterwrapper *prevptr, struct ___Object___ *ptr, int * enterflags, int numenterflags);