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