small differences
[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 #define MAXARRAY 1024*1024
12
13 struct pointerlist {
14   int count;
15   void * prev;
16   void * array[MAXPOINTERS];
17   int maxcount;
18   int buffer[2048];
19 };
20
21 struct primitivelist {
22   int count;
23   int array[MAXVALUES+1024];
24 };
25
26 struct branchlist {
27   int count;
28   char array[MAXBRANCHES+4096];
29 };
30
31 extern __thread struct pointerlist ptrstack;
32 extern __thread struct primitivelist primstack;
33 extern __thread struct branchlist branchstack;
34 #ifdef STMARRAY
35 struct arraylist {
36   int count;
37   void * prev;
38   void *array[MAXARRAY];
39   int maxcount;
40   int index[MAXARRAY+1024];
41 };
42
43 extern __thread struct arraylist arraystack;
44 #endif
45
46 //Arrays
47
48 #define RESTOREARRAY(x,z) {x=arraystack.array[arraystack.maxcount];z=arraystack.index[arraystack.maxcount++];}
49
50 #define STOREARRAY(x,z) {void * y=COMPOID(x); arraystack.array[arraystack.count]=y; arraystack.index[arraystack.count++]=z; dc_t_chashInsertOnce(y,y,z);}
51
52 #define STOREARRAYNOLOCK(x,z) {void * y=COMPOID(x); arraystack.array[arraystack.count]=y; arraystack.index[arraystack.count++]=z;}
53
54 #define STOREARRAYNOTRANS(x,z) {void * y=x; arraystack.array[arraystack.count]=y; arraystack.index[arraystack.count++]=z; dc_t_chashInsertOnce(y,y,z);}
55
56 #define STOREARRAYNOLOCKNOTRANS(x,z) {void * y=x; arraystack.array[arraystack.count]=y; arraystack.index[arraystack.count++]=z; }
57
58 //Pointers
59
60 #define RESTOREPTR(x) x=ptrstack.array[ptrstack.maxcount++];
61
62 #define STOREPTR(x) {void * y=COMPOID(x); ptrstack.array[ptrstack.count++]=y; dc_t_chashInsertOnce(y,y);}
63
64 #define STOREPTRNOLOCK(x) {void * y=COMPOID(x); ptrstack.array[ptrstack.count++]=y; }
65
66 #define STOREPTRNOTRANS(x) {void * y=x; ptrstack.array[ptrstack.count++]=y; dc_t_chashInsertOnce(y,y);}
67
68 #define STOREPTRNOLOCKNOTRANS(x) {void * y=x; ptrstack.array[ptrstack.count++]=y; }
69
70 //Branches
71
72 #define RESTOREANDBRANCH(loc) if (branchstack.array[branchstack.count++]) goto loc
73
74 #define STOREANDBRANCH(cond, loc) if (branchstack.array[branchstack.count++]=cond) goto loc
75
76 //Integers
77
78 #define RESTOREI(x) x=primstack.array[primstack.count++]
79
80 #define STOREI(x) primstack.array[primstack.count++]=x
81
82 //Floats
83
84 #define RESTOREF(x) x=*((float *)&primstack.array[primstack.count++])
85
86 #define STOREF(x) *((float *)&primstack.array[primstack.count++])=x
87
88 //Doubles
89
90 #define RESTORED(x) x=*((double *)&primstack.array[primstack.count]); primstack.count+=2
91
92 #define STORED(x) *((double *)&primstack.array[primstack.count])=x; primstack.count+=2
93
94 //Bytes
95
96 #define RESTOREB(x) x=*((char *)&primstack.array[primstack.count++])
97
98 #define STOREB(x) *((char *)&primstack.array[primstack.count++])=x
99
100 //Characters
101
102 #define RESTOREC(x) x=*((short *)&primstack.array[primstack.count++])
103
104 #define STOREC(x) *((short *)&primstack.array[primstack.count++])=x
105
106 //Longs
107
108 #define RESTOREJ(x) x=*((long long *)&primstack.array[primstack.count]); primstack.count+=2
109
110 #define STOREJ(x) *((long long *)&primstack.array[primstack.count])=x; primstack.count+=2
111
112 //Booleans
113
114 #define RESTOREZ(x) x=primstack.array[primstack.count++]
115
116 #define STOREZ(x) primstack.array[primstack.count++]=x
117
118 #endif