[project @ 1998-12-02 13:17:09 by simonm]
[ghc-hetmet.git] / ghc / includes / Constants.h
1 /* ----------------------------------------------------------------------------
2  * $Id: Constants.h,v 1.2 1998/12/02 13:21:03 simonm Exp $
3  *
4  * Constants
5  *
6  * NOTE: this information is used by both the compiler and the RTS,
7  * and *must* be kept up-to-date with respect to the rest of the
8  * world.
9  *
10  * -------------------------------------------------------------------------- */
11
12 #ifndef CONSTANTS_H
13 #define CONSTANTS_H
14
15 /* -----------------------------------------------------------------------------
16    Header Sizes
17
18    NOTE: keep these in line with the real definitions in Closures.h
19    -------------------------------------------------------------------------- */
20
21 #define STD_HDR_SIZE   1
22 #define PROF_HDR_SIZE  1
23 #define GRAN_HDR_SIZE  1
24 #define TICKY_HDR_SIZE 1
25
26 #define ARR_HDR_SIZE   1
27
28 /* -----------------------------------------------------------------------------
29    Info Table sizes
30
31    The native code generator needs to know these things, and can't use
32    the C sizeof() function.
33   
34    NOTE: keep these in line with the real definitions in InfoTables.h
35
36    NOTE: the PROF, GRAN and TICKY values are *wrong*  (ToDo)
37    -------------------------------------------------------------------------- */
38
39 #define STD_ITBL_SIZE   3
40 #define PROF_ITBL_SIZE  1
41 #define GRAN_ITBL_SIZE  1
42 #define TICKY_ITBL_SIZE 1
43
44 /* -----------------------------------------------------------------------------
45    Minimum closure sizes
46
47    Here We define the minimum size for updatable closures. This must be at
48    least 2, to allow for cons cells and linked indirections. All updates
49    will be performed on closures of this size. For non-updatable closures
50    the minimum size is 1 to allow for a forwarding pointer.
51
52    Linked indirections are UPD_OLDGEN things: see Closures.h
53
54    o MIN_UPD_SIZE doesn't apply to stack closures, static closures
55      or non-updateable objects like PAPs or CONSTRs
56    o MIN_UPD_SIZE is big enough to contain any of the following:
57      o EVACUATED
58      o BLACKHOLE
59      o BLOCKING QUEUE
60      o IND, IND_PERM, IND_OLDGEN and IND_OLDGEN_PERM
61        (it need not be big enough for IND_STATIC - but it is)
62    o MIN_NONUPD_SIZE doesn't apply to stack closures, static closures
63      or updateable objects like APs, THUNKS or THUNK_SELECTORs
64    o MIN_NONUPD_SIZE is big enough to contain any of the following:
65      o EVACUATED
66    -------------------------------------------------------------------------- */
67
68 #define MIN_UPD_SIZE    2
69 #define MIN_NONUPD_SIZE 1
70
71 /* -----------------------------------------------------------------------------
72    Constants to do with specialised closure types.
73    -------------------------------------------------------------------------- */
74
75 /* We have some pre-compiled selector thunks defined in
76  * StgSelectors.hc in the runtime system.  This constant defines the
77  * highest selectee index that we can replace with a reference to the
78  * pre-compiled code.
79  */
80
81 #define MAX_SPEC_SELECTEE_SIZE 15
82
83 /* Vector-apply thunks.  These thunks just push their free variables
84  * on the stack and enter the first one.  They're a bit like PAPs, but
85  * don't have a dynamic size.  We've pre-compiled a few to save
86  * space. 
87  */
88
89 #define MAX_SPEC_AP_SIZE       8
90
91 /* -----------------------------------------------------------------------------
92    Update Frame Layout
93    -------------------------------------------------------------------------- */
94
95 #define NOSCC_UF_SIZE   3
96 #define SCC_UF_SIZE     4
97
98 #if defined(PROFILING)
99 #define UF_SIZE SCC_UF_SIZE
100 #else
101 #define UF_SIZE NOSCC_UF_SIZE
102 #endif
103
104 #define UF_RET          0
105 #define UF_SU           1
106 #define UF_UPDATEE      2
107 #define UF_CCS          3
108
109 /* -----------------------------------------------------------------------------
110    SEQ frame size
111    -------------------------------------------------------------------------- */
112
113 #if defined(PROFILING)
114 #define SEQ_FRAME_SIZE 3
115 #else
116 #define SEQ_FRAME_SIZE 2
117 #endif
118
119 /* -----------------------------------------------------------------------------
120    STG Registers.
121
122    Note that in MachRegs.h we define how many of these registers are
123    *real* machine registers, and not just offsets in the Register Table.
124    -------------------------------------------------------------------------- */
125
126 #define MAX_VANILLA_REG 8
127 #define MAX_FLOAT_REG   4
128 #define MAX_DOUBLE_REG  2
129 /* register is only used for returning (unboxed) 64-bit vals */
130 #define MAX_LONG_REG    1
131
132 /*---- The size of an StgDouble, in StgWords. */
133
134 #if SIZEOF_VOID_P == SIZEOF_DOUBLE
135 #define DOUBLE_SIZE     1
136 #else
137 #define DOUBLE_SIZE     2
138 #endif
139
140 /*---- The size of Stg{Int,Word}64e, in StgWords. */
141 #if SIZEOF_VOID_P == 8
142 #define WORD64_SIZE     1
143 #define INT64_SIZE      1
144 #else
145 #define WORD64_SIZE     2
146 #define INT64_SIZE      2
147 #endif
148
149 /*---- Maximum number of constructors in a data type for direct-returns.  */
150
151 #define MAX_VECTORED_RTN 8
152
153 /*---- Range of built-in table of static small int-like closures. */
154
155 #define MAX_INTLIKE             (16)
156 #define MIN_INTLIKE             (-16)
157
158 /*---- Minimum number of words left in heap after GC to carry on */
159
160 #define HEAP_HWM_WORDS  1024
161
162 /* -----------------------------------------------------------------------------
163    Semi-Tagging constants
164
165    Old Comments about this stuff:
166
167    Tags for indirection nodes and ``other'' (probably unevaluated) nodes;
168    normal-form values of algebraic data types will have tags 0, 1, ...
169    
170    @INFO_IND_TAG@ is different from @INFO_OTHER_TAG@ just so we can count
171    how often we bang into indirection nodes; that's all.  (WDP 95/11)
172
173    ToDo: find out if we need any of this.
174    -------------------------------------------------------------------------- */
175
176 #define INFO_OTHER_TAG          (-1)
177 #define INFO_IND_TAG            (-2)
178 #define INFO_FIRST_TAG          0
179
180 /* -----------------------------------------------------------------------------
181    Context switch timing constants.
182    -------------------------------------------------------------------------- */
183
184 #define CS_MAX_FREQUENCY 100              /* context switches per second */
185 #define CS_MIN_MILLISECS (1000/CS_MAX_FREQUENCY)/* milliseconds per slice */
186  
187 /* -----------------------------------------------------------------------------
188    How much C stack to reserve for local temporaries when in the STG
189    world.  Used in StgRun.S and StgCRun.c.
190    -------------------------------------------------------------------------- */
191
192 #define RESERVED_C_STACK_BYTES (512 * SIZEOF_LONG)
193
194 /* -----------------------------------------------------------------------------
195    How much Haskell stack space to reserve for the saving of registers
196    etc. in the case of a stack/heap overflow.
197    
198    This must be large enough to accomodate the largest stack frame
199    pushed in one of the heap check fragments in HeapStackCheck.hc
200    (ie. currently the generic heap checks - 19 words).
201    -------------------------------------------------------------------------- */
202
203 #define RESERVED_STACK_WORDS 19
204
205 /* -----------------------------------------------------------------------------
206    Storage manager constants
207    -------------------------------------------------------------------------- */
208
209 /* The size of a block */
210 #define BLOCK_SIZE   0x2000
211 #define BLOCK_SHIFT  13
212
213 /* The size of a megablock */
214 #define MBLOCK_SIZE    0x100000
215 #define MBLOCK_SHIFT   20
216
217 /* the largest size an object can be before we give it a block of its
218  * own and treat it as an immovable object during GC, expressed as a
219  * fraction of BLOCK_SIZE.
220  */
221 #define LARGE_OBJECT_THRESHOLD ((nat)(BLOCK_SIZE * 8 / 10))
222
223 #endif /* CONSTANTS_H */
224