[project @ 2000-01-13 14:33:57 by hwloidl]
[ghc-hetmet.git] / ghc / includes / Constants.h
1 /* ----------------------------------------------------------------------------
2  * $Id: Constants.h,v 1.8 2000/01/13 14:34:00 hwloidl 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_HDR_SIZE   1
31
32 /* -----------------------------------------------------------------------------
33    Info Table sizes
34
35    The native code generator needs to know these things, and can't use
36    the C sizeof() function.
37   
38    NOTE: keep these in line with the real definitions in InfoTables.h
39
40    NOTE: the PROF, and GRAN values are *wrong*  (ToDo)
41    HWL: checked GRAN_ITBL_SIZE; ok
42    -------------------------------------------------------------------------- */
43
44 #define STD_ITBL_SIZE   3
45 #define PROF_ITBL_SIZE  1
46 #define GRAN_ITBL_SIZE  1
47 #define PAR_ITBL_SIZE   0
48 #define TICKY_ITBL_SIZE 0
49
50 /* -----------------------------------------------------------------------------
51    Minimum closure sizes
52
53    Here We define the minimum size for updatable closures. This must be at
54    least 2, to allow for cons cells and linked indirections. All updates
55    will be performed on closures of this size. For non-updatable closures
56    the minimum size is 1 to allow for a forwarding pointer.
57
58    Linked indirections are UPD_OLDGEN things: see Closures.h
59
60    o MIN_UPD_SIZE doesn't apply to stack closures, static closures
61      or non-updateable objects like PAPs or CONSTRs
62    o MIN_UPD_SIZE is big enough to contain any of the following:
63      o EVACUATED
64      o BLACKHOLE
65      o BLOCKING QUEUE
66      o IND, IND_PERM, IND_OLDGEN and IND_OLDGEN_PERM
67        (it need not be big enough for IND_STATIC - but it is)
68    o MIN_NONUPD_SIZE doesn't apply to stack closures, static closures
69      or updateable objects like APs, THUNKS or THUNK_SELECTORs
70    o MIN_NONUPD_SIZE is big enough to contain any of the following:
71      o EVACUATED
72    -------------------------------------------------------------------------- */
73
74 #define MIN_UPD_SIZE    2
75 #define MIN_NONUPD_SIZE 1
76
77 /* -----------------------------------------------------------------------------
78    Constants to do with specialised closure types.
79    -------------------------------------------------------------------------- */
80
81 /* We have some pre-compiled selector thunks defined in
82  * StgSelectors.hc in the runtime system.  This constant defines the
83  * highest selectee index that we can replace with a reference to the
84  * pre-compiled code.
85  */
86
87 #define MAX_SPEC_SELECTEE_SIZE 15
88
89 /* Vector-apply thunks.  These thunks just push their free variables
90  * on the stack and enter the first one.  They're a bit like PAPs, but
91  * don't have a dynamic size.  We've pre-compiled a few to save
92  * space. 
93  */
94
95 #define MAX_SPEC_AP_SIZE       8
96
97 /* Specialised FUN/THUNK/CONSTR closure types */
98
99 #define MAX_SPEC_THUNK_SIZE    2
100 #define MAX_SPEC_FUN_SIZE      2
101 #define MAX_SPEC_CONSTR_SIZE   2
102
103 /* -----------------------------------------------------------------------------
104    Update Frame Layout
105    GranSim uses an additional word as bitmask in the update frame; actually,
106    not really necessary, but uses standard closure layout that way
107    NB: UF_RET etc are *wrong* in a GranSim setup; should be increased by 1 
108        if compiling for GranSim (currently not used in compiler) -- HWL
109    -------------------------------------------------------------------------- */
110 #define NOSCC_UF_SIZE   3
111 #define GRAN_UF_SIZE    4
112 #define SCC_UF_SIZE     4
113
114 #define UF_RET          0
115 #define UF_SU           1
116 #define UF_UPDATEE      2
117 #define UF_CCS          3
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 /*---- Maximum number of constructors in a data type for direct-returns.  */
161
162 #define MAX_VECTORED_RTN 8
163
164 /*---- Range of built-in table of static small int-like closures. */
165
166 #define MAX_INTLIKE             (16)
167 #define MIN_INTLIKE             (-16)
168
169 /*---- Minimum number of words left in heap after GC to carry on */
170
171 #define HEAP_HWM_WORDS  1024
172
173 /* -----------------------------------------------------------------------------
174    Semi-Tagging constants
175
176    Old Comments about this stuff:
177
178    Tags for indirection nodes and ``other'' (probably unevaluated) nodes;
179    normal-form values of algebraic data types will have tags 0, 1, ...
180    
181    @INFO_IND_TAG@ is different from @INFO_OTHER_TAG@ just so we can count
182    how often we bang into indirection nodes; that's all.  (WDP 95/11)
183
184    ToDo: find out if we need any of this.
185    -------------------------------------------------------------------------- */
186
187 #define INFO_OTHER_TAG          (-1)
188 #define INFO_IND_TAG            (-2)
189 #define INFO_FIRST_TAG          0
190
191 /* -----------------------------------------------------------------------------
192    Context switch timing constants.
193    -------------------------------------------------------------------------- */
194
195 #define CS_MAX_FREQUENCY 100              /* context switches per second */
196 #define CS_MIN_MILLISECS (1000/CS_MAX_FREQUENCY)/* milliseconds per slice */
197  
198 /* -----------------------------------------------------------------------------
199    How much C stack to reserve for local temporaries when in the STG
200    world.  Used in StgRun.S and StgCRun.c.
201    -------------------------------------------------------------------------- */
202
203 #define RESERVED_C_STACK_BYTES (512 * SIZEOF_LONG)
204
205 /* -----------------------------------------------------------------------------
206    How much Haskell stack space to reserve for the saving of registers
207    etc. in the case of a stack/heap overflow.
208    
209    This must be large enough to accomodate the largest stack frame
210    pushed in one of the heap check fragments in HeapStackCheck.hc
211    (ie. currently the generic heap checks - 19 words).
212    -------------------------------------------------------------------------- */
213
214 #define RESERVED_STACK_WORDS 19
215
216 /* -----------------------------------------------------------------------------
217    Storage manager constants
218    -------------------------------------------------------------------------- */
219
220 /* The size of a block */
221 #define BLOCK_SIZE   0x1000
222 #define BLOCK_SHIFT  12
223
224 /* The size of a megablock */
225 #define MBLOCK_SIZE    0x100000
226 #define MBLOCK_SHIFT   20
227
228 /* the largest size an object can be before we give it a block of its
229  * own and treat it as an immovable object during GC, expressed as a
230  * fraction of BLOCK_SIZE.
231  */
232 #define LARGE_OBJECT_THRESHOLD ((nat)(BLOCK_SIZE * 8 / 10))
233
234 #endif /* CONSTANTS_H */
235