1671999652d0f412020f30bc9e562557b8969e73
[IRC.git] / Robust / src / Runtime / STM / delaycomp.h
1 #ifndef DELAYCOMP_H
2 #define DELAYCOMP_H
3
4 //There is probably a better way for these...but we'll just hardcode
5 //them for now..probably a real implementation would page protect the
6 //page after...then default to something simpler
7
8 #define MAXPOINTERS 1024*1024*1
9 #define MAXVALUES 1024*1024*2
10 #define MAXBRANCHES 1024*1024*4
11
12 struct pointerlist {
13   int count;
14   void * prev;
15   void * array[MAXPOINTERS+1024];
16 };
17
18 struct primitivelist {
19   int count;
20   int array[MAXVALUES+1024];
21 };
22
23 struct branchlist {
24   int count;
25   char array[MAXBRANCHES+4096];
26 };
27
28 extern __thread struct pointerlist ptrstack;
29 extern __thread struct primitivelist primstack;
30 extern __thread struct branchlist branchstack;
31
32 //Pointers
33
34 #define RESTOREPTR(x) x=ptrstack.array[ptrstack.count++];
35
36 #define STOREPTR(x) {void * y=COMPOID(x); ptrstack.array[ptrstack.count++]=y; dc_t_chashInsertOnce(y,y);}
37
38 #define STOREPTRNOLOCK(x) {void * y=COMPOID(x); ptrstack.array[ptrstack.count++]=y; }
39
40 #define STOREPTRNOTRANS(x) {void * y=x; ptrstack.array[ptrstack.count++]=y; dc_t_chashInsertOnce(y,y);}
41
42 #define STOREPTRNOLOCKNOTRANS(x) {void * y=x; ptrstack.array[ptrstack.count++]=y; }
43
44 //Branches
45
46 #define RESTOREANDBRANCH(loc) if (branchstack.array[branchstack.count++]) goto loc
47
48 #define STOREANDBRANCH(cond, loc) if (branchstack.array[branchstack.count++]=cond) goto loc
49
50 //Integers
51
52 #define RESTOREI(x) x=primstack.array[primstack.count++]
53
54 #define STOREI(x) primstack.array[primstack.count++]=x
55
56 //Floats
57
58 #define RESTOREF(x) x=*((float *)&primstack.array[primstack.count++])
59
60 #define STOREF(x) *((float *)&primstack.array[primstack.count++])=x
61
62 //Doubles
63
64 #define RESTORED(x) x=*((double *)&primstack.array[primstack.count]); primstack.count+=2
65
66 #define STORED(x) *((double *)&primstack.array[primstack.count])=x; primstack.count+=2
67
68 //Bytes
69
70 #define RESTOREB(x) x=*((char *)&primstack.array[primstack.count++])
71
72 #define STOREB(x) *((char *)&primstack.array[primstack.count++])=x
73
74 //Characters
75
76 #define RESTOREC(x) x=*((short *)&primstack.array[primstack.count++])
77
78 #define STOREC(x) *((short *)&primstack.array[primstack.count++])=x
79
80 //Longs
81
82 #define RESTOREJ(x) x=*((long long *)&primstack.array[primstack.count]); primstack.count+=2
83
84 #define STOREJ(x) *((long long *)&primstack.array[primstack.count])=x; primstack.count+=2
85
86 //Booleans
87
88 #define RESTOREZ(x) x=primstack.array[primstack.count++]
89
90 #define STOREZ(x) primstack.array[primstack.count++]=x
91
92 #endif