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