1 /* ----------------------------------------------------------------------------
2 * $Id: Constants.h,v 1.8 2000/01/13 14:34:00 hwloidl 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_HDR_SIZE 1
32 /* -----------------------------------------------------------------------------
35 The native code generator needs to know these things, and can't use
36 the C sizeof() function.
38 NOTE: keep these in line with the real definitions in InfoTables.h
40 NOTE: the PROF, and GRAN values are *wrong* (ToDo)
41 HWL: checked GRAN_ITBL_SIZE; ok
42 -------------------------------------------------------------------------- */
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
50 /* -----------------------------------------------------------------------------
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.
58 Linked indirections are UPD_OLDGEN things: see Closures.h
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:
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:
72 -------------------------------------------------------------------------- */
74 #define MIN_UPD_SIZE 2
75 #define MIN_NONUPD_SIZE 1
77 /* -----------------------------------------------------------------------------
78 Constants to do with specialised closure types.
79 -------------------------------------------------------------------------- */
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
87 #define MAX_SPEC_SELECTEE_SIZE 15
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
95 #define MAX_SPEC_AP_SIZE 8
97 /* Specialised FUN/THUNK/CONSTR closure types */
99 #define MAX_SPEC_THUNK_SIZE 2
100 #define MAX_SPEC_FUN_SIZE 2
101 #define MAX_SPEC_CONSTR_SIZE 2
103 /* -----------------------------------------------------------------------------
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
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
160 /*---- Maximum number of constructors in a data type for direct-returns. */
162 #define MAX_VECTORED_RTN 8
164 /*---- Range of built-in table of static small int-like closures. */
166 #define MAX_INTLIKE (16)
167 #define MIN_INTLIKE (-16)
169 /*---- Minimum number of words left in heap after GC to carry on */
171 #define HEAP_HWM_WORDS 1024
173 /* -----------------------------------------------------------------------------
174 Semi-Tagging constants
176 Old Comments about this stuff:
178 Tags for indirection nodes and ``other'' (probably unevaluated) nodes;
179 normal-form values of algebraic data types will have tags 0, 1, ...
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)
184 ToDo: find out if we need any of this.
185 -------------------------------------------------------------------------- */
187 #define INFO_OTHER_TAG (-1)
188 #define INFO_IND_TAG (-2)
189 #define INFO_FIRST_TAG 0
191 /* -----------------------------------------------------------------------------
192 Context switch timing constants.
193 -------------------------------------------------------------------------- */
195 #define CS_MAX_FREQUENCY 100 /* context switches per second */
196 #define CS_MIN_MILLISECS (1000/CS_MAX_FREQUENCY)/* milliseconds per slice */
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 -------------------------------------------------------------------------- */
203 #define RESERVED_C_STACK_BYTES (512 * SIZEOF_LONG)
205 /* -----------------------------------------------------------------------------
206 How much Haskell stack space to reserve for the saving of registers
207 etc. in the case of a stack/heap overflow.
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 -------------------------------------------------------------------------- */
214 #define RESERVED_STACK_WORDS 19
216 /* -----------------------------------------------------------------------------
217 Storage manager constants
218 -------------------------------------------------------------------------- */
220 /* The size of a block */
221 #define BLOCK_SIZE 0x1000
222 #define BLOCK_SHIFT 12
224 /* The size of a megablock */
225 #define MBLOCK_SIZE 0x100000
226 #define MBLOCK_SHIFT 20
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.
232 #define LARGE_OBJECT_THRESHOLD ((nat)(BLOCK_SIZE * 8 / 10))
234 #endif /* CONSTANTS_H */