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