1 /* ----------------------------------------------------------------------------
2 * $Id: Constants.h,v 1.6 1999/03/26 10:29:02 simonm 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 -------------------------------------------------------------------------- */
23 #define STD_HDR_SIZE 1
24 #define PROF_HDR_SIZE 1
25 #define GRAN_HDR_SIZE 1
26 #define TICKY_HDR_SIZE 0
28 #define ARR_HDR_SIZE 1
30 /* -----------------------------------------------------------------------------
33 The native code generator needs to know these things, and can't use
34 the C sizeof() function.
36 NOTE: keep these in line with the real definitions in InfoTables.h
38 NOTE: the PROF, and GRAN values are *wrong* (ToDo)
39 -------------------------------------------------------------------------- */
41 #define STD_ITBL_SIZE 3
42 #define PROF_ITBL_SIZE 1
43 #define GRAN_ITBL_SIZE 1
44 #define TICKY_ITBL_SIZE 0
46 /* -----------------------------------------------------------------------------
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.
54 Linked indirections are UPD_OLDGEN things: see Closures.h
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:
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:
68 -------------------------------------------------------------------------- */
70 #define MIN_UPD_SIZE 2
71 #define MIN_NONUPD_SIZE 1
73 /* -----------------------------------------------------------------------------
74 Constants to do with specialised closure types.
75 -------------------------------------------------------------------------- */
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
83 #define MAX_SPEC_SELECTEE_SIZE 15
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
91 #define MAX_SPEC_AP_SIZE 8
93 /* Specialised FUN/THUNK/CONSTR closure types */
95 #define MAX_SPEC_THUNK_SIZE 2
96 #define MAX_SPEC_FUN_SIZE 2
97 #define MAX_SPEC_CONSTR_SIZE 2
99 /* -----------------------------------------------------------------------------
101 -------------------------------------------------------------------------- */
103 #define NOSCC_UF_SIZE 3
104 #define SCC_UF_SIZE 4
111 /* -----------------------------------------------------------------------------
114 I don't think seq frames really need sccs --SDM
115 -------------------------------------------------------------------------- */
117 #define NOSCC_SEQ_FRAME_SIZE 2
118 #define SCC_SEQ_FRAME_SIZE 3
120 /* -----------------------------------------------------------------------------
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 -------------------------------------------------------------------------- */
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
133 /*---- The size of an StgDouble, in StgWords. */
135 #if SIZEOF_VOID_P == SIZEOF_DOUBLE
136 #define DOUBLE_SIZE 1
138 #define DOUBLE_SIZE 2
141 /*---- The size of Stg{Int,Word}64e, in StgWords. */
142 #if SIZEOF_VOID_P == 8
143 #define WORD64_SIZE 1
146 #define WORD64_SIZE 2
150 /*---- Maximum number of constructors in a data type for direct-returns. */
152 #define MAX_VECTORED_RTN 8
154 /*---- Range of built-in table of static small int-like closures. */
156 #define MAX_INTLIKE (16)
157 #define MIN_INTLIKE (-16)
159 /*---- Minimum number of words left in heap after GC to carry on */
161 #define HEAP_HWM_WORDS 1024
163 /* -----------------------------------------------------------------------------
164 Semi-Tagging constants
166 Old Comments about this stuff:
168 Tags for indirection nodes and ``other'' (probably unevaluated) nodes;
169 normal-form values of algebraic data types will have tags 0, 1, ...
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)
174 ToDo: find out if we need any of this.
175 -------------------------------------------------------------------------- */
177 #define INFO_OTHER_TAG (-1)
178 #define INFO_IND_TAG (-2)
179 #define INFO_FIRST_TAG 0
181 /* -----------------------------------------------------------------------------
182 Context switch timing constants.
183 -------------------------------------------------------------------------- */
185 #define CS_MAX_FREQUENCY 100 /* context switches per second */
186 #define CS_MIN_MILLISECS (1000/CS_MAX_FREQUENCY)/* milliseconds per slice */
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 -------------------------------------------------------------------------- */
193 #define RESERVED_C_STACK_BYTES (512 * SIZEOF_LONG)
195 /* -----------------------------------------------------------------------------
196 How much Haskell stack space to reserve for the saving of registers
197 etc. in the case of a stack/heap overflow.
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 -------------------------------------------------------------------------- */
204 #define RESERVED_STACK_WORDS 19
206 /* -----------------------------------------------------------------------------
207 Storage manager constants
208 -------------------------------------------------------------------------- */
210 /* The size of a block */
211 #define BLOCK_SIZE 0x2000
212 #define BLOCK_SHIFT 13
214 /* The size of a megablock */
215 #define MBLOCK_SIZE 0x100000
216 #define MBLOCK_SHIFT 20
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.
222 #define LARGE_OBJECT_THRESHOLD ((nat)(BLOCK_SIZE * 8 / 10))
224 #endif /* CONSTANTS_H */