1 /* ----------------------------------------------------------------------------
2 * $Id: Constants.h,v 1.17 2001/08/01 08:20:33 simonmar Exp $
4 * (c) The GHC Team, 1998-1999
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
12 * -------------------------------------------------------------------------- */
17 /* -----------------------------------------------------------------------------
20 NOTE: keep these in line with the real definitions in Closures.h
21 HWL: checked GRAN_HDR_SIZE; ok
22 -------------------------------------------------------------------------- */
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
30 #define ARR_WORDS_HDR_SIZE 1
31 #define ARR_PTRS_HDR_SIZE 2
33 /* -----------------------------------------------------------------------------
36 The native code generator needs to know these things, and can't use
37 the C sizeof() function.
39 NOTE: keep these in line with the real definitions in InfoTables.h
41 NOTE: the PROF, and GRAN values are *wrong* (ToDo)
42 HWL: checked GRAN_ITBL_SIZE; ok
43 -------------------------------------------------------------------------- */
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
51 /* -----------------------------------------------------------------------------
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.
59 Linked indirections are UPD_OLDGEN things: see Closures.h
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:
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:
73 -------------------------------------------------------------------------- */
75 #define MIN_UPD_SIZE 2
76 #define MIN_NONUPD_SIZE 1
78 /* -----------------------------------------------------------------------------
79 Constants to do with specialised closure types.
80 -------------------------------------------------------------------------- */
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
88 #define MAX_SPEC_SELECTEE_SIZE 15
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
96 #define MAX_SPEC_AP_SIZE 8
98 /* Specialised FUN/THUNK/CONSTR closure types */
100 #define MAX_SPEC_THUNK_SIZE 2
101 #define MAX_SPEC_FUN_SIZE 2
102 #define MAX_SPEC_CONSTR_SIZE 2
104 /* -----------------------------------------------------------------------------
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
119 /* -----------------------------------------------------------------------------
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 -------------------------------------------------------------------------- */
126 #define NOSCC_SEQ_FRAME_SIZE 2
127 #define GRAN_SEQ_FRAME_SIZE 3
128 #define SCC_SEQ_FRAME_SIZE 3
130 /* -----------------------------------------------------------------------------
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 -------------------------------------------------------------------------- */
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
143 /*---- The size of an StgDouble, in StgWords. */
145 #if SIZEOF_VOID_P == SIZEOF_DOUBLE
146 #define DOUBLE_SIZE 1
148 #define DOUBLE_SIZE 2
151 /*---- The size of Stg{Int,Word}64e, in StgWords. */
152 #if SIZEOF_VOID_P == 8
153 #define WORD64_SIZE 1
156 #define WORD64_SIZE 2
161 /*---- The size of StgWord, in bytes. */
162 #define WORD_SIZE SIZEOF_VOID_P
164 /*---- Maximum number of constructors in a data type for direct-returns. */
166 #define MAX_VECTORED_RTN 8
168 /*---- Range of built-in table of static small int-like and char-like closures. */
170 #define MAX_INTLIKE 16
171 #define MIN_INTLIKE (-16)
173 #define MAX_CHARLIKE 255
174 #define MIN_CHARLIKE 0
176 /* You can change these constants (I hope) but be sure to modify
177 rts/StgMiscClosures.hs accordingly. */
179 /*---- Minimum number of words left in heap after GC to carry on */
181 #define HEAP_HWM_WORDS 1024
183 /* -----------------------------------------------------------------------------
184 Semi-Tagging constants
186 Old Comments about this stuff:
188 Tags for indirection nodes and ``other'' (probably unevaluated) nodes;
189 normal-form values of algebraic data types will have tags 0, 1, ...
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)
194 ToDo: find out if we need any of this.
195 -------------------------------------------------------------------------- */
197 #define INFO_OTHER_TAG (-1)
198 #define INFO_IND_TAG (-2)
199 #define INFO_FIRST_TAG 0
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 -------------------------------------------------------------------------- */
206 #define RESERVED_C_STACK_BYTES (2048 * SIZEOF_LONG)
208 /* -----------------------------------------------------------------------------
209 How much Haskell stack space to reserve for the saving of registers
210 etc. in the case of a stack/heap overflow.
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 -------------------------------------------------------------------------- */
217 #define RESERVED_STACK_WORDS 19
219 /* -----------------------------------------------------------------------------
220 Storage manager constants
221 -------------------------------------------------------------------------- */
223 /* The size of a block */
224 #define BLOCK_SIZE 0x1000
225 #define BLOCK_SHIFT 12
227 /* The size of a megablock */
228 #define MBLOCK_SIZE 0x100000
229 #define MBLOCK_SHIFT 20
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.
235 #define LARGE_OBJECT_THRESHOLD ((nat)(BLOCK_SIZE * 8 / 10))
237 #endif /* CONSTANTS_H */