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 #define TAGARRAYINTERVAL 10
12 #define OBJECTARRAYINTERVAL 10
13
14 #define ARRAYSET(array, type, index, value) \
15 ((type *)(&(& array->___length___)[1]))[index]=value
16
17 #define ARRAYGET(array, type, index) \
18 ((type *)(&(& array->___length___)[1]))[index]
19
20 #ifdef OPTIONAL
21 #define OPTARG(x) , x
22 #else
23 #define OPTARG(x)
24 #endif
25
26 #ifdef DSTM
27 void * allocate_newglobal(transrecord_t *, int type);
28 struct ArrayObject * allocate_newarrayglobal(transrecord_t *, int type, int length);
29 #endif
30
31 #ifdef PRECISE_GC
32 #include "garbage.h"
33 void * allocate_new(void *, int type);
34 struct ArrayObject * allocate_newarray(void *, int type, int length);
35 struct ___String___ * NewString(void *, const char *str,int length);
36 struct ___TagDescriptor___ * allocate_tag(void *ptr, int index);
37 #else
38 void * allocate_new(int type);
39 struct ArrayObject * allocate_newarray(int type, int length);
40 struct ___String___ * NewString(const char *str,int length);
41 struct ___TagDescriptor___ * allocate_tag(int index);
42 #endif
43
44
45
46 void initializeexithandler();
47 void failedboundschk();
48 void failednullptr();
49 void abort_task();
50 void injectinstructionfailure();
51 void createstartupobject();
52
53 #ifdef PRECISE_GC
54 #define VAR(name) ___params___->name
55 #define CALL00(name) name(struct name ## _params * ___params___)
56 #define CALL01(name, alt) name(struct name ## _params * ___params___)
57 #define CALL02(name, alt1, alt2) name(struct name ## _params * ___params___)
58 #define CALL11(name,rest, alt) name(struct name ## _params * ___params___, rest)
59 #define CALL12(name,rest, alt1, alt2) name(struct name ## _params * ___params___, rest)
60 #define CALL22(name, rest, rest2, alt1, alt2) name(struct name ## _params * ___params___, rest, rest2)
61 #define CALL23(name, rest, rest2, alt1, alt2, alt3) name(struct name ## _params * ___params___, rest, rest2)
62 #define CALL24(name, rest, rest2, alt1, alt2, alt3, alt4) name(struct name ## _params * ___params___, rest, rest2)
63 #define CALL34(name, rest, rest2, rest3, alt1, alt2, alt3, alt4) name(struct name ## _params * ___params___, rest, rest2, rest3)
64 #else
65 #define VAR(name) name
66 #define CALL00(name) name()
67 #define CALL01(name, alt) name(alt)
68 #define CALL02(name, alt1, alt2) name(alt1, alt2)
69 #define CALL11(name,rest, alt) name(alt)
70 #define CALL12(name,rest, alt1, alt2) name(alt1, alt2)
71 #define CALL22(name, rest, rest2, alt1, alt2) name(alt1, alt2)
72 #define CALL23(name, rest, rest2, alt1, alt2, alt3) name(alt1, alt2, alt3)
73 #define CALL24(name, rest, rest2, alt1, alt2, alt3, alt4) name(alt1, alt2, alt3, alt4)
74 #define CALL34(name, rest, rest2, rest3, alt1, alt2, alt3, alt4) name(alt1, alt2, alt3, alt4)
75 #endif
76
77 #ifdef TASK
78 #include "SimpleHash.h"
79 #include "ObjectHash.h"
80 #include "task.h"
81 #include "structdefs.h"
82 #ifdef OPTIONAL
83 #include "optionalstruct.h"
84 #endif
85
86 #ifdef OPTIONAL
87 struct failedtasklist {
88   struct taskdescriptor *task;
89   int index;
90   int numflags;
91   int *flags;
92   struct failedtasklist *next;
93 };
94 #endif
95
96 void flagorand(void * ptr, int ormask, int andmask);
97 void flagorandinit(void * ptr, int ormask, int andmask);
98 void executetasks();
99 void processtasks();
100
101 struct tagobjectiterator {
102   int istag; /* 0 if object iterator, 1 if tag iterator */
103   struct ObjectIterator it; /* Object iterator */
104   struct ObjectHash * objectset;
105 #ifdef OPTIONAL
106   int failedstate;
107 #endif
108   int slot;
109   int tagobjindex; /* Index for tag or object depending on use */
110   /*if tag we have an object binding */
111   int tagid;
112   int tagobjectslot;
113   /*if object, we may have one or more tag bindings */
114   int numtags;
115   int tagbindings[MAXTASKPARAMS-1]; /* list slots */
116 };
117
118 struct parameterwrapper {
119   struct parameterwrapper *next;
120   struct ObjectHash * objectset;
121   int numberofterms;
122   int * intarray;
123   int numbertags;
124   int * tagarray;
125   struct taskdescriptor * task;
126   int slot;
127   struct tagobjectiterator iterators[MAXTASKPARAMS-1];
128 };
129
130 struct taskparamdescriptor {
131   struct taskdescriptor * task;
132   int numParameters;
133   void ** parameterArray;
134 #ifdef OPTIONAL
135   int * failed;
136 #endif
137 };
138
139 int hashCodetpd(struct taskparamdescriptor *);
140 int comparetpd(struct taskparamdescriptor *, struct taskparamdescriptor *);
141
142 void toiReset(struct tagobjectiterator * it);
143 int toiHasNext(struct tagobjectiterator *it, void ** objectarray OPTARG(int * failed));
144 void toiNext(struct tagobjectiterator *it , void ** objectarray OPTARG(int * failed));
145 void processobject(struct parameterwrapper *parameter, int index, struct parameterdescriptor *pd, int *iteratorcount, int * statusarray, int numparams);
146 void processtags(struct parameterdescriptor *pd, int index, struct parameterwrapper *parameter, int * iteratorcount, int *statusarray, int numparams);
147 void builditerators(struct taskdescriptor * task, int index, struct parameterwrapper * parameter);
148 int enqueuetasks(struct parameterwrapper *parameter, struct parameterwrapper *prevptr, struct ___Object___ *ptr, int * enterflags, int numenterflags);
149
150 #endif
151
152 #endif