[project @ 2001-07-31 13:44:37 by simonmar]
[ghc-hetmet.git] / ghc / includes / Constants.h
1 /* ----------------------------------------------------------------------------
2  * $Id: Constants.h,v 1.15 2001/07/31 13:44:37 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
119 /* -----------------------------------------------------------------------------
120    SEQ frame size
121
122    I don't think seq frames really need sccs --SDM
123    They don't need a GranSim bitmask either, but who cares anyway -- HWL
124    -------------------------------------------------------------------------- */
125
126 #define NOSCC_SEQ_FRAME_SIZE 2
127 #define GRAN_SEQ_FRAME_SIZE  3
128 #define SCC_SEQ_FRAME_SIZE   3
129
130 /* -----------------------------------------------------------------------------
131    STG Registers.
132
133    Note that in MachRegs.h we define how many of these registers are
134    *real* machine registers, and not just offsets in the Register Table.
135    -------------------------------------------------------------------------- */
136
137 #define MAX_VANILLA_REG 8
138 #define MAX_FLOAT_REG   4
139 #define MAX_DOUBLE_REG  2
140 /* register is only used for returning (unboxed) 64-bit vals */
141 #define MAX_LONG_REG    1
142
143 /*---- The size of an StgDouble, in StgWords. */
144
145 #if SIZEOF_VOID_P == SIZEOF_DOUBLE
146 #define DOUBLE_SIZE     1
147 #else
148 #define DOUBLE_SIZE     2
149 #endif
150
151 /*---- The size of Stg{Int,Word}64e, in StgWords. */
152 #if SIZEOF_VOID_P == 8
153 #define WORD64_SIZE     1
154 #define INT64_SIZE      1
155 #else
156 #define WORD64_SIZE     2
157 #define INT64_SIZE      2
158 #endif
159
160
161 /*---- The size of StgWord, in bytes. */
162 #define WORD_SIZE       SIZEOF_VOID_P
163
164 /*---- Maximum number of constructors in a data type for direct-returns.  */
165
166 #define MAX_VECTORED_RTN 8
167
168 /*---- Range of built-in table of static small int-like and char-like closures. */
169
170 #define MAX_INTLIKE             16
171 #define MIN_INTLIKE             (-16)
172
173 #define MAX_CHARLIKE            255
174 #define MIN_CHARLIKE            0
175
176 /* You can change these constants (I hope) but be sure to modify
177    rts/StgMiscClosures.hs accordingly. */
178
179 /*---- Minimum number of words left in heap after GC to carry on */
180
181 #define HEAP_HWM_WORDS  1024
182
183 /* -----------------------------------------------------------------------------
184    Semi-Tagging constants
185
186    Old Comments about this stuff:
187
188    Tags for indirection nodes and ``other'' (probably unevaluated) nodes;
189    normal-form values of algebraic data types will have tags 0, 1, ...
190    
191    @INFO_IND_TAG@ is different from @INFO_OTHER_TAG@ just so we can count
192    how often we bang into indirection nodes; that's all.  (WDP 95/11)
193
194    ToDo: find out if we need any of this.
195    -------------------------------------------------------------------------- */
196
197 #define INFO_OTHER_TAG          (-1)
198 #define INFO_IND_TAG            (-2)
199 #define INFO_FIRST_TAG          0
200
201 /* -----------------------------------------------------------------------------
202    How much C stack to reserve for local temporaries when in the STG
203    world.  Used in StgRun.S and StgCRun.c.
204    -------------------------------------------------------------------------- */
205
206 #define RESERVED_C_STACK_BYTES (2048 * SIZEOF_LONG)
207
208 /* -----------------------------------------------------------------------------
209    How much Haskell stack space to reserve for the saving of registers
210    etc. in the case of a stack/heap overflow.
211    
212    This must be large enough to accomodate the largest stack frame
213    pushed in one of the heap check fragments in HeapStackCheck.hc
214    (ie. currently the generic heap checks - 19 words).
215    -------------------------------------------------------------------------- */
216
217 #define RESERVED_STACK_WORDS 19
218
219 /* -----------------------------------------------------------------------------
220    Storage manager constants
221    -------------------------------------------------------------------------- */
222
223 /* The size of a block */
224 #define BLOCK_SIZE   0x1000
225 #define BLOCK_SHIFT  12
226
227 /* The size of a megablock */
228 #define MBLOCK_SIZE    0x100000
229 #define MBLOCK_SHIFT   20
230
231 /* the largest size an object can be before we give it a block of its
232  * own and treat it as an immovable object during GC, expressed as a
233  * fraction of BLOCK_SIZE.
234  */
235 #define LARGE_OBJECT_THRESHOLD ((nat)(BLOCK_SIZE * 8 / 10))
236
237 #endif /* CONSTANTS_H */
238