changes to support inlined fission transactions
[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 #if defined(STMARRAY)&&!defined(DUALVIEW)
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,t) {void * y=COMPOID(x); int ii=z;arraystack.array[arraystack.count]=y; arraystack.index[arraystack.count++]=ii; dc_t_chashInsertOnceArray(y,(ii*sizeof(t))>>INDEXSHIFT);}
51
52 //Pointers
53
54 #define RESTOREPTR(x) x=ptrstack.array[ptrstack.maxcount++];
55
56 #define STOREPTR(x) {void * y=COMPOID(x); ptrstack.array[ptrstack.count++]=y; dc_t_chashInsertOnce(y);}
57
58 #define STOREPTRNOLOCK(x) {void * y=COMPOID(x); ptrstack.array[ptrstack.count++]=y; }
59
60 //Branches
61
62 #define RESTOREBRANCH(loc) (branchstack.array[branchstack.count++])
63
64 #define STOREBRANCH(cond) branchstack.array[branchstack.count++]=cond
65
66 //Integers
67
68 #define RESTOREI(x) x=primstack.array[primstack.count++]
69
70 #define STOREI(x) primstack.array[primstack.count++]=x
71
72 //Floats
73
74 #define RESTOREF(x) x=*((float *)&primstack.array[primstack.count++])
75
76 #define STOREF(x) *((float *)&primstack.array[primstack.count++])=x
77
78 //Doubles
79
80 #define RESTORED(x) x=*((double *)&primstack.array[primstack.count]); primstack.count+=2
81
82 #define STORED(x) *((double *)&primstack.array[primstack.count])=x; primstack.count+=2
83
84 //Bytes
85
86 #define RESTOREB(x) x=*((char *)&primstack.array[primstack.count++])
87
88 #define STOREB(x) *((char *)&primstack.array[primstack.count++])=x
89
90 //Characters
91
92 #define RESTOREC(x) x=*((short *)&primstack.array[primstack.count++])
93
94 #define STOREC(x) *((short *)&primstack.array[primstack.count++])=x
95
96 //Longs
97
98 #define RESTOREJ(x) x=*((long long *)&primstack.array[primstack.count]); primstack.count+=2
99
100 #define STOREJ(x) *((long long *)&primstack.array[primstack.count])=x; primstack.count+=2
101
102 //Booleans
103
104 #define RESTOREZ(x) x=primstack.array[primstack.count++]
105
106 #define STOREZ(x) primstack.array[primstack.count++]=x
107
108 #endif