1 /* ----------------------------------------------------------------------------
2 * $Id: Constants.h,v 1.25 2003/04/28 09:55:20 simonmar Exp $
4 * (c) The GHC Team, 1998-2002
8 * NOTE: this information is used by both the compiler and the RTS.
9 * Some of it is tweakable, and some of it must be kept up to date
10 * with various other parts of the system.
12 * Constants which are derived automatically from other definitions in
13 * the system (eg. structure sizes) are generated into the file
14 * DerivedConstants.h by a C program (mkDerivedConstantsHdr).
16 * -------------------------------------------------------------------------- */
21 /* -----------------------------------------------------------------------------
24 Here we define the minimum size for updatable closures. This must be at
25 least 2, to allow for cons cells and linked indirections. All updates
26 will be performed on closures of this size. For non-updatable closures
27 the minimum size is 1 to allow for a forwarding pointer.
29 Linked indirections are UPD_OLDGEN things: see Closures.h
31 o MIN_UPD_SIZE doesn't apply to stack closures, static closures
32 or non-updateable objects like PAPs or CONSTRs
33 o MIN_UPD_SIZE is big enough to contain any of the following:
37 o IND, IND_PERM, IND_OLDGEN and IND_OLDGEN_PERM
38 (it need not be big enough for IND_STATIC - but it is)
39 o MIN_NONUPD_SIZE doesn't apply to stack closures, static closures
40 or updateable objects like APs, THUNKS or THUNK_SELECTORs
41 o MIN_NONUPD_SIZE is big enough to contain any of the following:
43 -------------------------------------------------------------------------- */
45 #define MIN_UPD_SIZE 2
46 #define MIN_NONUPD_SIZE 1
48 /* -----------------------------------------------------------------------------
49 Constants to do with specialised closure types.
50 -------------------------------------------------------------------------- */
52 /* We have some pre-compiled selector thunks defined in rts/StgStdThunks.hc.
53 * This constant defines the highest selectee index that we can replace with a
54 * reference to the pre-compiled code.
57 #define MAX_SPEC_SELECTEE_SIZE 15
59 /* Vector-apply thunks. These thunks just push their free variables
60 * on the stack and enter the first one. They're a bit like PAPs, but
61 * don't have a dynamic size. We've pre-compiled a few to save
65 #define MAX_SPEC_AP_SIZE 8
66 /* ToDo: make it 8 again */
68 /* Specialised FUN/THUNK/CONSTR closure types */
70 #define MAX_SPEC_THUNK_SIZE 2
71 #define MAX_SPEC_FUN_SIZE 2
72 #define MAX_SPEC_CONSTR_SIZE 2
74 /* -----------------------------------------------------------------------------
77 Note that in MachRegs.h we define how many of these registers are
78 *real* machine registers, and not just offsets in the Register Table.
79 -------------------------------------------------------------------------- */
81 #define MAX_VANILLA_REG 8
82 #define MAX_FLOAT_REG 4
83 #define MAX_DOUBLE_REG 2
84 /* register is only used for returning (unboxed) 64-bit vals */
85 #define MAX_LONG_REG 1
87 /*---- Maximum number of constructors in a data type for direct-returns. */
89 #define MAX_VECTORED_RTN 8
91 /*---- Range of built-in table of static small int-like and char-like closures. */
93 #define MAX_INTLIKE 16
94 #define MIN_INTLIKE (-16)
96 #define MAX_CHARLIKE 255
97 #define MIN_CHARLIKE 0
99 /* You can change these constants (I hope) but be sure to modify
100 rts/StgMiscClosures.hs accordingly. */
102 /* -----------------------------------------------------------------------------
103 Semi-Tagging constants
105 Old Comments about this stuff:
107 Tags for indirection nodes and ``other'' (probably unevaluated) nodes;
108 normal-form values of algebraic data types will have tags 0, 1, ...
110 @INFO_IND_TAG@ is different from @INFO_OTHER_TAG@ just so we can count
111 how often we bang into indirection nodes; that's all. (WDP 95/11)
113 ToDo: find out if we need any of this.
114 -------------------------------------------------------------------------- */
116 #define INFO_OTHER_TAG (-1)
117 #define INFO_IND_TAG (-2)
118 #define INFO_FIRST_TAG 0
120 /* -----------------------------------------------------------------------------
121 How much C stack to reserve for local temporaries when in the STG
122 world. Used in StgCRun.c.
123 -------------------------------------------------------------------------- */
125 #define RESERVED_C_STACK_BYTES (2048 * SIZEOF_LONG)
127 /* -----------------------------------------------------------------------------
128 How much Haskell stack space to reserve for the saving of registers
129 etc. in the case of a stack/heap overflow.
131 This must be large enough to accomodate the largest stack frame
132 pushed in one of the heap check fragments in HeapStackCheck.hc
133 (ie. currently the generic heap checks - 3 words for StgRetDyn,
134 18 words for the saved registers, see StgMacros.h).
136 In the event of an unboxed tuple or let-no-escape stack/heap check
137 failure, there will be other words on the stack which are covered
138 by the RET_DYN frame. These will have been accounted for by stack
139 checks however, so we don't need to allow for them here.
140 -------------------------------------------------------------------------- */
142 #define RESERVED_STACK_WORDS 21
144 /* -----------------------------------------------------------------------------
145 Storage manager constants
146 -------------------------------------------------------------------------- */
148 /* The size of a block (2^BLOCK_SHIFT bytes) */
149 #define BLOCK_SHIFT 12
151 /* The size of a megablock (2^MBLOCK_SHIFT bytes) */
152 #define MBLOCK_SHIFT 20
154 /* -----------------------------------------------------------------------------
155 Bitmap/size fields (used in info tables)
156 -------------------------------------------------------------------------- */
158 /* In a 32-bit bitmap field, we use 5 bits for the size, and 27 bits
159 * for the bitmap. If the bitmap requires more than 27 bits, then we
160 * store it in a separate array, and leave a pointer in the bitmap
161 * field. On a 64-bit machine, the sizes are extended accordingly.
163 #if SIZEOF_VOID_P == 4
164 #define BITMAP_SIZE_MASK 0x1f
165 #define BITMAP_BITS_SHIFT 5
166 #elif SIZEOF_VOID_P == 8
167 #define BITMAP_SIZE_MASK 0x3f
168 #define BITMAP_BITS_SHIFT 6
170 #error unknown SIZEOF_VOID_P
173 #endif /* CONSTANTS_H */