changes
[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*16
9 #define MAXVALUES 1024*1024*16
10
11 struct pointerlist {
12   int count;
13   void * prev;
14   void * array[MAXPOINTERS];
15 };
16
17 struct primitivelist {
18   int count;
19   int array[MAXVALUES];
20 };
21
22 extern __thread pointerlist ptrstack;
23 extern __thread primitivelist primstack;
24
25 //Pointers
26
27 #define RESTOREPTR(x) x=ptrstack.array[--ptrstack.count]
28
29 #define STOREPTR(x) ptrstack.array[ptrstack.count++]=x
30
31 //Branches
32
33 #define RESTOREANDBRANCH(loc) if (primstack.array[--primstack.count]) goto loc
34
35 #define STOREANDBRANCH(cond, loc) if (primatack.array[primstack.count++]=cond) goto loc
36
37 //Integers
38
39 #define RESTOREI(x) x=primstack.array[--primstack.count]
40
41 #define STOREI(x) primstack.array[primstack.count++]=x
42
43 //Floats
44
45 #define RESTOREF(x) x=*((float *)&primstack.array[--primstack.count])
46
47 #define STOREF(x) *((float *)&primstack.array[primstack.count++])=x
48
49 //Doubles
50
51 #define RESTORED(x) x=*((double *)&primstack.array[primstack.count-=2])
52
53 #define STORED(x) *((double *)&primstack.array[primstack.count])=x; primstack.count+=2
54
55 //Bytes
56
57 #define RESTOREB(x) x=*((char *)&primstack.array[--primstack.count])
58
59 #define STOREB(x) *((char *)&primstack.array[primstack.count++])=x
60
61 //Characters
62
63 #define RESTOREC(x) x=*((short *)&primstack.array[--primstack.count])
64
65 #define STOREC(x) *((short *)&primstack.array[primstack.count++])=x
66
67 //Doubles
68
69 #define RESTOREJ(x) x=*((long long *)&primstack.array[primstack.count-=2])
70
71 #define STOREJ(x) *((long long *)&primstack.array[primstack.count])=x; primstack.count+=2
72
73 //Booleans
74
75 #define RESTOREZ(x) x=primstack.array[--primstack.count]
76
77 #define STOREZ(x) primstack.array[primstack.count++]=x
78
79 #endif