1 /* ----------------------------------------------------------------------------
2 * $Id: Constants.h,v 1.20 2001/11/28 14:31:27 simonmar Exp $
4 * (c) The GHC Team, 1998-1999
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
53 * StgSelectors.hc in the runtime system. This constant defines the
54 * highest selectee index that we can replace with a reference to the
58 #define MAX_SPEC_SELECTEE_SIZE 15
60 /* Vector-apply thunks. These thunks just push their free variables
61 * on the stack and enter the first one. They're a bit like PAPs, but
62 * don't have a dynamic size. We've pre-compiled a few to save
66 #define MAX_SPEC_AP_SIZE 8
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 /*---- Minimum number of words left in heap after GC to carry on */
104 #define HEAP_HWM_WORDS 1024
106 /* -----------------------------------------------------------------------------
107 Semi-Tagging constants
109 Old Comments about this stuff:
111 Tags for indirection nodes and ``other'' (probably unevaluated) nodes;
112 normal-form values of algebraic data types will have tags 0, 1, ...
114 @INFO_IND_TAG@ is different from @INFO_OTHER_TAG@ just so we can count
115 how often we bang into indirection nodes; that's all. (WDP 95/11)
117 ToDo: find out if we need any of this.
118 -------------------------------------------------------------------------- */
120 #define INFO_OTHER_TAG (-1)
121 #define INFO_IND_TAG (-2)
122 #define INFO_FIRST_TAG 0
124 /* -----------------------------------------------------------------------------
125 How much C stack to reserve for local temporaries when in the STG
126 world. Used in StgRun.S and StgCRun.c.
127 -------------------------------------------------------------------------- */
129 #define RESERVED_C_STACK_BYTES (2048 * SIZEOF_LONG)
131 /* -----------------------------------------------------------------------------
132 How much Haskell stack space to reserve for the saving of registers
133 etc. in the case of a stack/heap overflow.
135 This must be large enough to accomodate the largest stack frame
136 pushed in one of the heap check fragments in HeapStackCheck.hc
137 (ie. currently the generic heap checks - 19 words).
138 -------------------------------------------------------------------------- */
140 #define RESERVED_STACK_WORDS 19
142 /* -----------------------------------------------------------------------------
143 Storage manager constants
144 -------------------------------------------------------------------------- */
146 /* The size of a block (2^BLOCK_SHIFT bytes) */
147 #define BLOCK_SHIFT 12
149 /* The size of a megablock (2^MBLOCK_SHIFT bytes) */
150 #define MBLOCK_SHIFT 20
152 /* the largest size an object can be before we give it a block of its
153 * own and treat it as an immovable object during GC, expressed as a
154 * fraction of BLOCK_SIZE.
156 #define LARGE_OBJECT_THRESHOLD ((nat)(BLOCK_SIZE * 8 / 10))
158 #endif /* CONSTANTS_H */