[project @ 2001-10-03 13:57:42 by simonmar]
[ghc-hetmet.git] / ghc / includes / Constants.h
1 /* ----------------------------------------------------------------------------
2  * $Id: Constants.h,v 1.18 2001/10/03 13:57:42 simonmar Exp $
3  *
4  * (c) The GHC Team, 1998-1999
5  *
6  * Constants
7  *
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.
11  *
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).
15  *
16  * -------------------------------------------------------------------------- */
17
18 #ifndef CONSTANTS_H
19 #define CONSTANTS_H
20
21 /* -----------------------------------------------------------------------------
22    Minimum closure sizes
23
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.
28
29    Linked indirections are UPD_OLDGEN things: see Closures.h
30
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:
34      o EVACUATED
35      o BLACKHOLE
36      o BLOCKING QUEUE
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:
42      o EVACUATED
43    -------------------------------------------------------------------------- */
44
45 #define MIN_UPD_SIZE    2
46 #define MIN_NONUPD_SIZE 1
47
48 /* -----------------------------------------------------------------------------
49    Constants to do with specialised closure types.
50    -------------------------------------------------------------------------- */
51
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
55  * pre-compiled code.
56  */
57
58 #define MAX_SPEC_SELECTEE_SIZE 15
59
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
63  * space. 
64  */
65
66 #define MAX_SPEC_AP_SIZE       8
67
68 /* Specialised FUN/THUNK/CONSTR closure types */
69
70 #define MAX_SPEC_THUNK_SIZE    2
71 #define MAX_SPEC_FUN_SIZE      2
72 #define MAX_SPEC_CONSTR_SIZE   2
73
74 /* -----------------------------------------------------------------------------
75    STG Registers.
76
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    -------------------------------------------------------------------------- */
80
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
86
87 /*---- Maximum number of constructors in a data type for direct-returns.  */
88
89 #define MAX_VECTORED_RTN 8
90
91 /*---- Range of built-in table of static small int-like and char-like closures. */
92
93 #define MAX_INTLIKE             16
94 #define MIN_INTLIKE             (-16)
95
96 #define MAX_CHARLIKE            255
97 #define MIN_CHARLIKE            0
98
99 /* You can change these constants (I hope) but be sure to modify
100    rts/StgMiscClosures.hs accordingly. */
101
102 /*---- Minimum number of words left in heap after GC to carry on */
103
104 #define HEAP_HWM_WORDS  1024
105
106 /* -----------------------------------------------------------------------------
107    Semi-Tagging constants
108
109    Old Comments about this stuff:
110
111    Tags for indirection nodes and ``other'' (probably unevaluated) nodes;
112    normal-form values of algebraic data types will have tags 0, 1, ...
113    
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)
116
117    ToDo: find out if we need any of this.
118    -------------------------------------------------------------------------- */
119
120 #define INFO_OTHER_TAG          (-1)
121 #define INFO_IND_TAG            (-2)
122 #define INFO_FIRST_TAG          0
123
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    -------------------------------------------------------------------------- */
128
129 #define RESERVED_C_STACK_BYTES (2048 * SIZEOF_LONG)
130
131 /* -----------------------------------------------------------------------------
132    How much Haskell stack space to reserve for the saving of registers
133    etc. in the case of a stack/heap overflow.
134    
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    -------------------------------------------------------------------------- */
139
140 #define RESERVED_STACK_WORDS 19
141
142 /* -----------------------------------------------------------------------------
143    Storage manager constants
144    -------------------------------------------------------------------------- */
145
146 /* The size of a block (2^BLOCK_SHIFT bytes) */
147 #define BLOCK_SHIFT  12
148
149 /* The size of a megablock (2^MBLOCK_SHIFT bytes) */
150 #define MBLOCK_SHIFT   20
151
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.
155  */
156 #define LARGE_OBJECT_THRESHOLD ((nat)(BLOCK_SIZE * 8 / 10))
157
158 #endif /* CONSTANTS_H */
159