changes to build script to increase java heap memory
[IRC.git] / Robust / src / Runtime / runtime.h
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 #ifndef MULTICORE
83 #include "ObjectHash.h"
84 #include "structdefs.h"
85 #endif
86 #include "task.h"
87 #ifdef OPTIONAL
88 #include "optionalstruct.h"
89 #endif
90
91 #ifdef OPTIONAL
92 struct failedtasklist {
93   struct taskdescriptor *task;
94   int index;
95   int numflags;
96   int *flags;
97   struct failedtasklist *next;
98 };
99 #endif
100
101 #ifdef MULTICORE
102 struct transObjInfo {
103         void * objptr;
104         int targetcore;
105         int * queues;
106         int length;
107 };
108 #endif
109
110 #ifdef RAW
111 //struct RuntimeHash * ptbl = NULL;
112 #endif
113
114 #ifdef MULTICORE
115 void flagorand(void * ptr, int ormask, int andmask, struct parameterwrapper ** queues, int length);
116 void flagorandinit(void * ptr, int ormask, int andmask);
117 void enqueueObject(void * ptr, struct parameterwrapper ** queues, int length);
118 #ifdef RAW
119 void enqueueObject_I(void * ptr, struct parameterwrapper ** queues, int length);
120 #endif
121 #else
122 void flagorand(void * ptr, int ormask, int andmask);
123 void flagorandinit(void * ptr, int ormask, int andmask);
124 void enqueueObject(void * ptr);
125 #endif
126 void executetasks();
127 void processtasks();
128
129 #ifdef MULTICORE
130 void transferObject(struct transObjInfo * transObj);
131 #endif
132
133 #ifndef MULTICORE
134 struct tagobjectiterator {
135   int istag; /* 0 if object iterator, 1 if tag iterator */
136   struct ObjectIterator it; /* Object iterator */
137   struct ObjectHash * objectset;
138 #ifdef OPTIONAL
139   int failedstate;
140 #endif
141   int slot;
142   int tagobjindex; /* Index for tag or object depending on use */
143   /*if tag we have an object binding */
144   int tagid;
145   int tagobjectslot;
146   /*if object, we may have one or more tag bindings */
147   int numtags;
148   int tagbindings[MAXTASKPARAMS-1]; /* list slots */
149 };
150
151 struct parameterwrapper {
152   struct parameterwrapper *next;
153   struct ObjectHash * objectset;
154   int numberofterms;
155   int * intarray;
156   int numbertags;
157   int * tagarray;
158   struct taskdescriptor * task;
159   int slot;
160   struct tagobjectiterator iterators[MAXTASKPARAMS-1];
161 };
162 #endif
163
164 struct taskparamdescriptor {
165   struct taskdescriptor * task;
166   int numParameters;
167   void ** parameterArray;
168 #ifdef OPTIONAL
169   int * failed;
170 #endif
171 };
172
173 int hashCodetpd(struct taskparamdescriptor *);
174 int comparetpd(struct taskparamdescriptor *, struct taskparamdescriptor *);
175
176 void toiReset(struct tagobjectiterator * it);
177 int toiHasNext(struct tagobjectiterator *it, void ** objectarray OPTARG(int * failed));
178 void toiNext(struct tagobjectiterator *it , void ** objectarray OPTARG(int * failed));
179 void processobject(struct parameterwrapper *parameter, int index, struct parameterdescriptor *pd, int *iteratorcount, int * statusarray, int numparams);
180 void processtags(struct parameterdescriptor *pd, int index, struct parameterwrapper *parameter, int * iteratorcount, int *statusarray, int numparams);
181 void builditerators(struct taskdescriptor * task, int index, struct parameterwrapper * parameter);
182 int enqueuetasks(struct parameterwrapper *parameter, struct parameterwrapper *prevptr, struct ___Object___ *ptr, int * enterflags, int numenterflags);
183 #ifdef RAW
184 int enqueuetasks_I(struct parameterwrapper *parameter, struct parameterwrapper *prevptr, struct ___Object___ *ptr, int * enterflags, int numenterflags);
185 #endif
186
187 #endif
188
189 #endif