This commit was manufactured by cvs2svn to create tag 'buildscript'.
[IRC.git] /
1 #ifndef RUNTIME
2 #define RUNTIME
3 #include <setjmp.h>
4 extern jmp_buf error_handler;
5 extern int instructioncount;
6 extern int failurecount;
7 #ifdef DSTM
8 #include "dstm.h"
9 #endif
10
11 extern void * curr_heapbase;
12 extern void * curr_heaptop;
13
14 #define TAGARRAYINTERVAL 10
15 #define OBJECTARRAYINTERVAL 10
16
17 #define ARRAYSET(array, type, index, value) \
18   ((type *)(& (& array->___length___)[1]))[index]=value
19
20 #define ARRAYGET(array, type, index) \
21   ((type *)(& (& array->___length___)[1]))[index]
22
23 #ifdef OPTIONAL
24 #define OPTARG(x) , x
25 #else
26 #define OPTARG(x)
27 #endif
28
29 #ifdef DSTM
30 void * allocate_newglobal(transrecord_t *, int type);
31 struct ArrayObject * allocate_newarrayglobal(transrecord_t *, int type, int length);
32 #endif
33
34 #ifdef PRECISE_GC
35 #include "garbage.h"
36 void * allocate_new(void *, int type);
37 struct ArrayObject * allocate_newarray(void *, int type, int length);
38 struct ___String___ * NewString(void *, const char *str,int length);
39 struct ___TagDescriptor___ * allocate_tag(void *ptr, int index);
40 #else
41 void * allocate_new(int type);
42 struct ArrayObject * allocate_newarray(int type, int length);
43 struct ___String___ * NewString(const char *str,int length);
44 struct ___TagDescriptor___ * allocate_tag(int index);
45 #endif
46
47
48
49 void initializeexithandler();
50 void failedboundschk();
51 void failednullptr();
52 void abort_task();
53 void injectinstructionfailure();
54 void createstartupobject();
55
56 #ifdef PRECISE_GC
57 #define VAR(name) ___params___->name
58 #define CALL00(name) name(struct name ## _params * ___params___)
59 #define CALL01(name, alt) name(struct name ## _params * ___params___)
60 #define CALL02(name, alt1, alt2) name(struct name ## _params * ___params___)
61 #define CALL11(name,rest, alt) name(struct name ## _params * ___params___, rest)
62 #define CALL12(name,rest, alt1, alt2) name(struct name ## _params * ___params___, rest)
63 #define CALL22(name, rest, rest2, alt1, alt2) name(struct name ## _params * ___params___, rest, rest2)
64 #define CALL23(name, rest, rest2, alt1, alt2, alt3) name(struct name ## _params * ___params___, rest, rest2)
65 #define CALL24(name, rest, rest2, alt1, alt2, alt3, alt4) name(struct name ## _params * ___params___, rest, rest2)
66 #define CALL34(name, rest, rest2, rest3, alt1, alt2, alt3, alt4) name(struct name ## _params * ___params___, rest, rest2, rest3)
67 #else
68 #define VAR(name) name
69 #define CALL00(name) name()
70 #define CALL01(name, alt) name(alt)
71 #define CALL02(name, alt1, alt2) name(alt1, alt2)
72 #define CALL11(name,rest, alt) name(alt)
73 #define CALL12(name,rest, alt1, alt2) name(alt1, alt2)
74 #define CALL22(name, rest, rest2, alt1, alt2) name(alt1, alt2)
75 #define CALL23(name, rest, rest2, alt1, alt2, alt3) name(alt1, alt2, alt3)
76 #define CALL24(name, rest, rest2, alt1, alt2, alt3, alt4) name(alt1, alt2, alt3, alt4)
77 #define CALL34(name, rest, rest2, rest3, alt1, alt2, alt3, alt4) name(alt1, alt2, alt3, alt4)
78 #endif
79
80 #ifdef TASK
81 #include "SimpleHash.h"
82 #include "chash.h"
83 #ifndef MULTICORE
84 #include "ObjectHash.h"
85 #include "structdefs.h"
86 #endif
87 #include "task.h"
88 #ifdef OPTIONAL
89 #include "optionalstruct.h"
90 #endif
91
92 #ifdef OPTIONAL
93 struct failedtasklist {
94   struct taskdescriptor *task;
95   int index;
96   int numflags;
97   int *flags;
98   struct failedtasklist *next;
99 };
100 #endif
101
102 #ifdef MULTICORE
103 struct transObjInfo {
104   void * objptr;
105   int targetcore;
106   int * queues;
107   int length;
108 };
109 #endif
110
111 #ifdef MULTICORE
112 void flagorand(void * ptr, int ormask, int andmask, struct parameterwrapper ** queues, int length);
113 void flagorandinit(void * ptr, int ormask, int andmask);
114 void enqueueObject(void * ptr, struct parameterwrapper ** queues, int length);
115 #ifdef RAW
116 void enqueueObject_I(void * ptr, struct parameterwrapper ** queues, int length);
117 #ifdef RAWPROFILE
118 inline void setTaskExitIndex(int index);
119 inline void addNewObjInfo(void * nobj);
120 #endif
121 #endif
122 void addAliasLock(void * ptr, int lock);
123 #else
124 void flagorand(void * ptr, int ormask, int andmask);
125 void flagorandinit(void * ptr, int ormask, int andmask);
126 void enqueueObject(void * ptr);
127 #endif
128 void executetasks();
129 void processtasks();
130
131 #ifdef MULTICORE
132 void transferObject(struct transObjInfo * transObj);
133 #endif
134
135 #ifndef MULTICORE
136 struct tagobjectiterator {
137   int istag; /* 0 if object iterator, 1 if tag iterator */
138   struct ObjectIterator it; /* Object iterator */
139   struct ObjectHash * objectset;
140 #ifdef OPTIONAL
141   int failedstate;
142 #endif
143   int slot;
144   int tagobjindex; /* Index for tag or object depending on use */
145   /*if tag we have an object binding */
146   int tagid;
147   int tagobjectslot;
148   /*if object, we may have one or more tag bindings */
149   int numtags;
150   int tagbindings[MAXTASKPARAMS-1]; /* list slots */
151 };
152
153 struct parameterwrapper {
154   struct parameterwrapper *next;
155   struct ObjectHash * objectset;
156   int numberofterms;
157   int * intarray;
158   int numbertags;
159   int * tagarray;
160   struct taskdescriptor * task;
161   int slot;
162   struct tagobjectiterator iterators[MAXTASKPARAMS-1];
163 };
164 #endif
165
166 struct taskparamdescriptor {
167   struct taskdescriptor * task;
168   int numParameters;
169   void ** parameterArray;
170 #ifdef OPTIONAL
171   int * failed;
172 #endif
173 };
174
175 int hashCodetpd(struct taskparamdescriptor *);
176 int comparetpd(struct taskparamdescriptor *, struct taskparamdescriptor *);
177
178 void toiReset(struct tagobjectiterator * it);
179 int toiHasNext(struct tagobjectiterator *it, void ** objectarray OPTARG(int * failed));
180 void toiNext(struct tagobjectiterator *it, void ** objectarray OPTARG(int * failed));
181 void processobject(struct parameterwrapper *parameter, int index, struct parameterdescriptor *pd, int *iteratorcount, int * statusarray, int numparams);
182 void processtags(struct parameterdescriptor *pd, int index, struct parameterwrapper *parameter, int * iteratorcount, int *statusarray, int numparams);
183 void builditerators(struct taskdescriptor * task, int index, struct parameterwrapper * parameter);
184 int enqueuetasks(struct parameterwrapper *parameter, struct parameterwrapper *prevptr, struct ___Object___ *ptr, int * enterflags, int numenterflags);
185 #ifdef RAW
186 int enqueuetasks_I(struct parameterwrapper *parameter, struct parameterwrapper *prevptr, struct ___Object___ *ptr, int * enterflags, int numenterflags);
187 #endif
188
189 #endif
190
191 #endif