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"
31 extern void * curr_heapbase;
32 extern void * curr_heaptop;
34 #define likely(x) __builtin_expect((x),1)
35 #define unlikely(x) __builtin_expect((x),0)
38 #define TAGARRAYINTERVAL 10
39 #define OBJECTARRAYINTERVAL 10
41 #define ARRAYSET(array, type, index, value) \
42 ((type *)(& (& array->___length___)[1]))[index]=value
44 #define ARRAYGET(array, type, index) \
45 ((type *)(& (& array->___length___)[1]))[index]
54 __attribute__((malloc)) void * allocate_newglobal(int type);
55 __attribute__((malloc)) struct ArrayObject * allocate_newarrayglobal(int type, int length);
59 __attribute__((malloc)) void * allocate_newtrans(void * ptr, int type);
60 __attribute__((malloc)) struct ArrayObject * allocate_newarraytrans(void * ptr, int type, int length);
65 __attribute__((malloc)) void * allocate_new(void *, int type);
66 __attribute__((malloc)) struct ArrayObject * allocate_newarray(void *, int type, int length);
67 __attribute__((malloc)) struct ___String___ * NewString(void *, const char *str,int length);
68 __attribute__((malloc)) struct ___TagDescriptor___ * allocate_tag(void *ptr, int index);
69 #elif defined MULTICORE_GC
70 __attribute__((malloc)) void * allocate_new(void *, int type);
71 __attribute__((malloc)) struct ArrayObject * allocate_newarray(void *, int type, int length);
72 __attribute__((malloc)) struct ___String___ * NewString(void *, const char *str,int length);
73 __attribute__((malloc)) struct ___TagDescriptor___ * allocate_tag(void *ptr, int index);
75 __attribute__((malloc)) void * allocate_new(int type);
76 __attribute__((malloc)) struct ArrayObject * allocate_newarray(int type, int length);
77 __attribute__((malloc)) struct ___String___ * NewString(const char *str,int length);
78 __attribute__((malloc)) struct ___TagDescriptor___ * allocate_tag(int index);
83 void initializeexithandler();
84 void failedboundschk();
87 void injectinstructionfailure();
88 void createstartupobject();
91 #define VAR(name) ___params___->name
92 #define CALL00(name) name(struct name ## _params * ___params___)
93 #define CALL01(name, alt) name(struct name ## _params * ___params___)
94 #define CALL02(name, alt1, alt2) name(struct name ## _params * ___params___)
95 #define CALL11(name,rest, alt) name(struct name ## _params * ___params___, rest)
96 #define CALL12(name,rest, alt1, alt2) name(struct name ## _params * ___params___, rest)
97 #define CALL22(name, rest, rest2, alt1, alt2) name(struct name ## _params * ___params___, rest, rest2)
98 #define CALL23(name, rest, rest2, alt1, alt2, alt3) name(struct name ## _params * ___params___, rest, rest2)
99 #define CALL24(name, rest, rest2, alt1, alt2, alt3, alt4) name(struct name ## _params * ___params___, rest, rest2)
100 #define CALL34(name, rest, rest2, rest3, alt1, alt2, alt3, alt4) name(struct name ## _params * ___params___, rest, rest2, rest3)
102 #define VAR(name) name
103 #define CALL00(name) name()
104 #define CALL01(name, alt) name(alt)
105 #define CALL02(name, alt1, alt2) name(alt1, alt2)
106 #define CALL11(name,rest, alt) name(alt)
107 #define CALL12(name,rest, alt1, alt2) name(alt1, alt2)
108 #define CALL22(name, rest, rest2, alt1, alt2) name(alt1, alt2)
109 #define CALL23(name, rest, rest2, alt1, alt2, alt3) name(alt1, alt2, alt3)
110 #define CALL24(name, rest, rest2, alt1, alt2, alt3, alt4) name(alt1, alt2, alt3, alt4)
111 #define CALL34(name, rest, rest2, rest3, alt1, alt2, alt3, alt4) name(alt1, alt2, alt3, alt4)
115 #include "SimpleHash.h"
118 #include "ObjectHash.h"
119 #include "structdefs.h"
123 #include "optionalstruct.h"
127 struct failedtasklist {
128 struct taskdescriptor *task;
132 struct failedtasklist *next;
137 struct transObjInfo {
146 extern struct ___Object___ * ___fcrevert___;
150 inline void run(void * arg);
152 inline void setupsmemmode(void);
154 int receiveObject(void);
155 void flagorand(void * ptr, int ormask, int andmask, struct parameterwrapper ** queues, int length);
156 void flagorandinit(void * ptr, int ormask, int andmask);
157 void enqueueObject(void * ptr, struct parameterwrapper ** queues,int length);
159 inline void setTaskExitIndex(int index);
160 inline void addNewObjInfo(void * nobj);
162 int * getAliasLock(void ** ptrs, int length, struct RuntimeHash * tbl);
163 void addAliasLock(void * ptr, int lock);
164 void * smemalloc_I(int coren, int size, int * allocsize);
166 void flagorand(void * ptr, int ormask, int andmask);
167 void flagorandinit(void * ptr, int ormask, int andmask);
168 void enqueueObject(void * ptr);
174 struct tagobjectiterator {
175 int istag; /* 0 if object iterator, 1 if tag iterator */
176 struct ObjectIterator it; /* Object iterator */
177 struct ObjectHash * objectset;
182 int tagobjindex; /* Index for tag or object depending on use */
183 /*if tag we have an object binding */
186 /*if object, we may have one or more tag bindings */
188 int tagbindings[MAXTASKPARAMS-1]; /* list slots */
191 struct parameterwrapper {
192 struct parameterwrapper *next;
193 struct ObjectHash * objectset;
198 struct taskdescriptor * task;
200 struct tagobjectiterator iterators[MAXTASKPARAMS-1];
204 struct taskparamdescriptor {
205 struct taskdescriptor * task;
207 void ** parameterArray;
213 int hashCodetpd(struct taskparamdescriptor *);
214 int comparetpd(struct taskparamdescriptor *, struct taskparamdescriptor *);
216 void toiReset(struct tagobjectiterator * it);
217 int toiHasNext(struct tagobjectiterator *it, void ** objectarray OPTARG(int * failed));
218 void toiNext(struct tagobjectiterator *it, void ** objectarray OPTARG(int * failed));
219 void processobject(struct parameterwrapper *parameter, int index, struct parameterdescriptor *pd, int *iteratorcount, int * statusarray, int numparams);
220 void processtags(struct parameterdescriptor *pd, int index, struct parameterwrapper *parameter, int * iteratorcount, int *statusarray, int numparams);
221 void builditerators(struct taskdescriptor * task, int index, struct parameterwrapper * parameter);
222 int enqueuetasks(struct parameterwrapper *parameter, struct parameterwrapper *prevptr, struct ___Object___ *ptr, int * enterflags, int numenterflags);