[project @ 2004-02-12 02:04:59 by mthomas]
[ghc-hetmet.git] / ghc / includes / Constants.h
index 819d378..8974052 100644 (file)
@@ -1,13 +1,17 @@
 /* ----------------------------------------------------------------------------
- * $Id: Constants.h,v 1.16 2001/07/31 18:30:22 qrczak Exp $
+ * $Id: Constants.h,v 1.25 2003/04/28 09:55:20 simonmar Exp $
  *
- * (c) The GHC Team, 1998-1999
+ * (c) The GHC Team, 1998-2002
  *
  * Constants
  *
- * NOTE: this information is used by both the compiler and the RTS,
- * and *must* be kept up-to-date with respect to the rest of the
- * world.
+ * NOTE: this information is used by both the compiler and the RTS.
+ * Some of it is tweakable, and some of it must be kept up to date
+ * with various other parts of the system.
+ *
+ * Constants which are derived automatically from other definitions in
+ * the system (eg. structure sizes) are generated into the file
+ * DerivedConstants.h by a C program (mkDerivedConstantsHdr).
  *
  * -------------------------------------------------------------------------- */
 
 #define CONSTANTS_H
 
 /* -----------------------------------------------------------------------------
-   Header Sizes
-
-   NOTE: keep these in line with the real definitions in Closures.h
-   HWL: checked GRAN_HDR_SIZE; ok
-   -------------------------------------------------------------------------- */
-
-#define STD_HDR_SIZE   1
-#define PROF_HDR_SIZE  1
-#define GRAN_HDR_SIZE  1
-#define PAR_HDR_SIZE   0
-#define TICKY_HDR_SIZE 0
-
-#define ARR_WORDS_HDR_SIZE  1
-#define ARR_PTRS_HDR_SIZE   2
-
-/* -----------------------------------------------------------------------------
-   Info Table sizes
-
-   The native code generator needs to know these things, and can't use
-   the C sizeof() function.
-  
-   NOTE: keep these in line with the real definitions in InfoTables.h
-
-   NOTE: the PROF, and GRAN values are *wrong*  (ToDo)
-   HWL: checked GRAN_ITBL_SIZE; ok
-   -------------------------------------------------------------------------- */
-
-#define STD_ITBL_SIZE   3
-#define PROF_ITBL_SIZE  1
-#define GRAN_ITBL_SIZE  1
-#define PAR_ITBL_SIZE   0
-#define TICKY_ITBL_SIZE 0
-
-/* -----------------------------------------------------------------------------
    Minimum closure sizes
 
-   Here We define the minimum size for updatable closures. This must be at
+   Here we define the minimum size for updatable closures. This must be at
    least 2, to allow for cons cells and linked indirections. All updates
    will be performed on closures of this size. For non-updatable closures
    the minimum size is 1 to allow for a forwarding pointer.
    Constants to do with specialised closure types.
    -------------------------------------------------------------------------- */
 
-/* We have some pre-compiled selector thunks defined in
- * StgSelectors.hc in the runtime system.  This constant defines the
- * highest selectee index that we can replace with a reference to the
- * pre-compiled code.
+/* We have some pre-compiled selector thunks defined in rts/StgStdThunks.hc.
+ * This constant defines the highest selectee index that we can replace with a 
+ * reference to the pre-compiled code.
  */
 
 #define MAX_SPEC_SELECTEE_SIZE 15
@@ -94,6 +63,7 @@
  */
 
 #define MAX_SPEC_AP_SIZE       8
+/* ToDo: make it 8 again */
 
 /* Specialised FUN/THUNK/CONSTR closure types */
 
 #define MAX_SPEC_CONSTR_SIZE   2
 
 /* -----------------------------------------------------------------------------
-   Update Frame Layout
-   GranSim uses an additional word as bitmask in the update frame; actually,
-   not really necessary, but uses standard closure layout that way
-   NB: UF_RET etc are *wrong* in a GranSim setup; should be increased by 1 
-       if compiling for GranSim (currently not used in compiler) -- HWL
-   -------------------------------------------------------------------------- */
-#define NOSCC_UF_SIZE  3
-#define GRAN_UF_SIZE   4
-#define SCC_UF_SIZE    4
-
-#define UF_RET         0
-#define UF_SU          1
-#define UF_UPDATEE     2
-#define UF_CCS         3
-
-/* -----------------------------------------------------------------------------
-   SEQ frame size
-
-   I don't think seq frames really need sccs --SDM
-   They don't need a GranSim bitmask either, but who cares anyway -- HWL
-   -------------------------------------------------------------------------- */
-
-#define NOSCC_SEQ_FRAME_SIZE 2
-#define GRAN_SEQ_FRAME_SIZE  3
-#define SCC_SEQ_FRAME_SIZE   3
-
-/* -----------------------------------------------------------------------------
    STG Registers.
 
    Note that in MachRegs.h we define how many of these registers are
 /* register is only used for returning (unboxed) 64-bit vals */
 #define MAX_LONG_REG    1
 
-/*---- The size of an StgDouble, in StgWords. */
-
-#if SIZEOF_VOID_P == SIZEOF_DOUBLE
-#define DOUBLE_SIZE    1
-#else
-#define DOUBLE_SIZE    2
-#endif
-
-/*---- The size of Stg{Int,Word}64e, in StgWords. */
-#if SIZEOF_VOID_P == 8
-#define WORD64_SIZE    1
-#define INT64_SIZE     1
-#else
-#define WORD64_SIZE    2
-#define INT64_SIZE     2
-#endif
-
-
-/*---- The size of StgWord, in bytes. */
-#define WORD_SIZE       SIZEOF_VOID_P
-
 /*---- Maximum number of constructors in a data type for direct-returns.  */
 
 #define MAX_VECTORED_RTN 8
 /* You can change these constants (I hope) but be sure to modify
    rts/StgMiscClosures.hs accordingly. */
 
-/*---- Minimum number of words left in heap after GC to carry on */
-
-#define HEAP_HWM_WORDS 1024
-
 /* -----------------------------------------------------------------------------
    Semi-Tagging constants
 
 
 /* -----------------------------------------------------------------------------
    How much C stack to reserve for local temporaries when in the STG
-   world.  Used in StgRun.S and StgCRun.c.
+   world.  Used in StgCRun.c.
    -------------------------------------------------------------------------- */
 
 #define RESERVED_C_STACK_BYTES (2048 * SIZEOF_LONG)
    
    This must be large enough to accomodate the largest stack frame
    pushed in one of the heap check fragments in HeapStackCheck.hc
-   (ie. currently the generic heap checks - 19 words).
+   (ie. currently the generic heap checks - 3 words for StgRetDyn,
+   18 words for the saved registers, see StgMacros.h).  
+
+   In the event of an unboxed tuple or let-no-escape stack/heap check
+   failure, there will be other words on the stack which are covered
+   by the RET_DYN frame.  These will have been accounted for by stack
+   checks however, so we don't need to allow for them here.
    -------------------------------------------------------------------------- */
 
-#define RESERVED_STACK_WORDS 19
+#define RESERVED_STACK_WORDS 21
 
 /* -----------------------------------------------------------------------------
    Storage manager constants
    -------------------------------------------------------------------------- */
 
-/* The size of a block */
-#define BLOCK_SIZE   0x1000
+/* The size of a block (2^BLOCK_SHIFT bytes) */
 #define BLOCK_SHIFT  12
 
-/* The size of a megablock */
-#define MBLOCK_SIZE    0x100000
+/* The size of a megablock (2^MBLOCK_SHIFT bytes) */
 #define MBLOCK_SHIFT   20
 
-/* the largest size an object can be before we give it a block of its
- * own and treat it as an immovable object during GC, expressed as a
- * fraction of BLOCK_SIZE.
+/* -----------------------------------------------------------------------------
+   Bitmap/size fields (used in info tables)
+   -------------------------------------------------------------------------- */
+
+/* In a 32-bit bitmap field, we use 5 bits for the size, and 27 bits
+ * for the bitmap.  If the bitmap requires more than 27 bits, then we
+ * store it in a separate array, and leave a pointer in the bitmap
+ * field.  On a 64-bit machine, the sizes are extended accordingly.
  */
-#define LARGE_OBJECT_THRESHOLD ((nat)(BLOCK_SIZE * 8 / 10))
+#if SIZEOF_VOID_P == 4
+#define BITMAP_SIZE_MASK     0x1f
+#define BITMAP_BITS_SHIFT    5
+#elif SIZEOF_VOID_P == 8
+#define BITMAP_SIZE_MASK     0x3f
+#define BITMAP_BITS_SHIFT    6
+#else
+#error unknown SIZEOF_VOID_P
+#endif
 
 #endif /* CONSTANTS_H */
-