[project @ 2001-10-03 13:57:42 by simonmar]
authorsimonmar <unknown>
Wed, 3 Oct 2001 13:57:42 +0000 (13:57 +0000)
committersimonmar <unknown>
Wed, 3 Oct 2001 13:57:42 +0000 (13:57 +0000)
Tidy up ghc/includes/Constants and related things.

Now all the constants that the compiler needs to know, such as header
size, update frame size, info table size and so on are generated
automatically into a header file, DeriviedConstants.h, by a small C
program in the same way as NativeDefs.h.  The C code in the RTS is
expected to use sizeof() directly (it already does).

Also tidied up the constants in MachDeps.h - all the constants
representing the sizes of various types are named SIZEOF_<foo>, to
match the constants defined in config.h.  PrelStorable.lhs now doesn't
contain any special knowledge about GHC's conventions as regards the
size of certain types, this is all in MachDeps.h.

13 files changed:
ghc/compiler/codeGen/CgStackery.lhs
ghc/compiler/main/Constants.lhs
ghc/includes/Block.h
ghc/includes/Closures.h
ghc/includes/Constants.h
ghc/includes/InfoTables.h
ghc/includes/MachDeps.h
ghc/includes/Makefile
ghc/includes/StgProf.h
ghc/includes/StgTypes.h
ghc/includes/mkDerivedConstants.c [new file with mode: 0644]
ghc/lib/std/PrelNum.lhs
ghc/lib/std/PrelStorable.lhs

index 896cfc7..a75b7e7 100644 (file)
@@ -1,7 +1,7 @@
 %
 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
 %
-% $Id: CgStackery.lhs,v 1.19 2001/09/12 15:52:40 sewardj Exp $
+% $Id: CgStackery.lhs,v 1.20 2001/10/03 13:57:42 simonmar Exp $
 %
 \section[CgStackery]{Stack management functions}
 
@@ -27,8 +27,9 @@ import AbsCUtils      ( mkAbstractCs, getAmodeRep )
 import PrimRep         ( getPrimRepSize, PrimRep(..), isFollowableRep )
 import CmdLineOpts     ( opt_SccProfilingOn, opt_GranMacros )
 import Panic           ( panic )
-import Constants       ( uF_SIZE, sCC_UF_SIZE, gRAN_UF_SIZE, 
-                         sEQ_FRAME_SIZE, sCC_SEQ_FRAME_SIZE, gRAN_SEQ_FRAME_SIZE )
+import Constants       ( uF_SIZE, pROF_UF_SIZE, gRAN_UF_SIZE, 
+                         sEQ_FRAME_SIZE, pROF_SEQ_FRAME_SIZE, 
+                         gRAN_SEQ_FRAME_SIZE )
 
 import Util            ( sortLt )
 import IOExts          ( trace )
@@ -222,11 +223,11 @@ getFinalStackHW fcode = do
 \end{code}
 
 \begin{code}
-updateFrameSize | opt_SccProfilingOn = sCC_UF_SIZE
+updateFrameSize | opt_SccProfilingOn = pROF_UF_SIZE
                | opt_GranMacros     = trace ("updateFrameSize = " ++ (show gRAN_UF_SIZE))gRAN_UF_SIZE
                | otherwise          = uF_SIZE
 
-seqFrameSize    | opt_SccProfilingOn  = sCC_SEQ_FRAME_SIZE
+seqFrameSize    | opt_SccProfilingOn  = pROF_SEQ_FRAME_SIZE
                | opt_GranMacros      = gRAN_SEQ_FRAME_SIZE
                | otherwise           = sEQ_FRAME_SIZE
 \end{code}                     
index 0e6a179..daa1c84 100644 (file)
@@ -34,14 +34,14 @@ module Constants (
        mAX_FAMILY_SIZE_FOR_VEC_RETURNS,
 
        uF_SIZE,
-       sCC_UF_SIZE,
+       pROF_UF_SIZE,
        gRAN_UF_SIZE,  -- HWL
        uF_RET,
        uF_SU,
        uF_UPDATEE,
 
        sEQ_FRAME_SIZE,
-       sCC_SEQ_FRAME_SIZE,
+       pROF_SEQ_FRAME_SIZE,
        gRAN_SEQ_FRAME_SIZE, -- HWL
 
        mAX_Vanilla_REG,
@@ -81,6 +81,8 @@ module Constants (
 #include "../includes/config.h"
 #include "../includes/MachRegs.h"
 #include "../includes/Constants.h"
+#include "../includes/MachDeps.h"
+#include "../includes/DerivedConstants.h"
 
 -- import Util
 \end{code}
@@ -146,10 +148,10 @@ mAX_FAMILY_SIZE_FOR_VEC_RETURNS = (MAX_VECTORED_RTN::Int)  -- pretty arbitrary
 -- If you change this, you may need to change runtimes/standard/Update.lhc
 
 -- The update frame sizes
-uF_SIZE        = (NOSCC_UF_SIZE::Int)
+uF_SIZE        = (STD_UF_SIZE::Int)
 
 -- Same again, with profiling
-sCC_UF_SIZE = (SCC_UF_SIZE::Int)
+pROF_UF_SIZE = (PROF_UF_SIZE::Int)
 
 -- Same again, with gransim
 gRAN_UF_SIZE = (GRAN_UF_SIZE::Int)
@@ -163,8 +165,8 @@ uF_UPDATEE     = (UF_UPDATEE::Int)
 Seq frame sizes.
 
 \begin{code}
-sEQ_FRAME_SIZE = (NOSCC_SEQ_FRAME_SIZE::Int)
-sCC_SEQ_FRAME_SIZE = (SCC_SEQ_FRAME_SIZE::Int)
+sEQ_FRAME_SIZE = (STD_SEQ_FRAME_SIZE::Int)
+pROF_SEQ_FRAME_SIZE = (PROF_SEQ_FRAME_SIZE::Int)
 gRAN_SEQ_FRAME_SIZE = (GRAN_SEQ_FRAME_SIZE::Int)
 \end{code}
 
@@ -207,9 +209,9 @@ tICKY_ITBL_SIZE = (TICKY_ITBL_SIZE :: Int)
 Size of a double in StgWords.
 
 \begin{code}
-dOUBLE_SIZE    = (DOUBLE_SIZE   :: Int)
-wORD64_SIZE    = (WORD64_SIZE   :: Int)
-iNT64_SIZE     = (INT64_SIZE   :: Int)
+dOUBLE_SIZE     = (SIZEOF_DOUBLE `quot` SIZEOF_HSWORD :: Int)
+wORD64_SIZE     = (8 `quot` SIZEOF_HSWORD :: Int)
+iNT64_SIZE      = wORD64_SIZE
 \end{code}
 
 This tells the native code generator the size of the spill
@@ -229,7 +231,7 @@ rESERVED_STACK_WORDS = (RESERVED_STACK_WORDS :: Int)
 Size of a word, in bytes
 
 \begin{code}
-wORD_SIZE = (WORD_SIZE :: Int)
+wORD_SIZE = (SIZEOF_HSWORD :: Int)
 \end{code}
 
 Size of a storage manager block (in bytes).
index 599dc27..1f84f78 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: Block.h,v 1.9 2001/07/23 17:23:19 simonmar Exp $
+ * $Id: Block.h,v 1.10 2001/10/03 13:57:42 simonmar Exp $
  *
  * (c) The GHC Team, 1998-1999
  *
@@ -16,6 +16,7 @@
 
 /* Block related constants (4k blocks) */
 
+#define BLOCK_SIZE   (1<<BLOCK_SHIFT)
 #define BLOCK_SIZE_W (BLOCK_SIZE/sizeof(W_))
 #define BLOCK_MASK   (BLOCK_SIZE-1)
 
@@ -24,6 +25,7 @@
 
 /* Megablock related constants (1M megablocks) */
 
+#define MBLOCK_SIZE    (1<<MBLOCK_SHIFT)
 #define MBLOCK_SIZE_W  (MBLOCK_SIZE/sizeof(W_))
 #define MBLOCK_MASK    (MBLOCK_SIZE-1)
 
index 982b28f..5f0b570 100644 (file)
@@ -1,5 +1,5 @@
 /* ----------------------------------------------------------------------------
- * $Id: Closures.h,v 1.27 2001/08/29 17:24:25 qrczak Exp $
+ * $Id: Closures.h,v 1.28 2001/10/03 13:57:42 simonmar Exp $
  *
  * (c) The GHC Team, 1998-1999
  *
    The profiling header
    -------------------------------------------------------------------------- */
 
-#ifdef PROFILING
-
 typedef struct {
    CostCentreStack *ccs;
 } StgProfHeader;
 
-#else /* !PROFILING */
-
-typedef struct {
-       /* empty */
-} StgProfHeader;
-
-#endif /* PROFILING */
-
 /* -----------------------------------------------------------------------------
    The parallel header
    -------------------------------------------------------------------------- */
 
-#ifdef PAR
-
 typedef struct {
   /* StgWord ga; */  /* nope! global addresses are managed via a hash table */
 } StgParHeader;
 
-#else /* !PAR */
-
-typedef struct {
-  /* empty */
-} StgParHeader;
-
-#endif /* PAR */
-
 /* -----------------------------------------------------------------------------
    The GranSim header
    -------------------------------------------------------------------------- */
 
-#if defined(GRAN)
-
 typedef struct {
   StgWord procs; /* bitmask indicating on which PEs this closure resides */
 } StgGranHeader;
 
-#else /* !GRAN */
-
-typedef struct {
-  /* empty */
-} StgGranHeader;
-
-#endif /* GRAN */
-
 /* -----------------------------------------------------------------------------
    The ticky-ticky header
 
@@ -88,20 +58,10 @@ typedef struct {
    info tables to be @_Evacuate_1@ and @_Scavenge_1_0@.
    -------------------------------------------------------------------------- */
 
-#ifdef TICKY_TICKY
-
 typedef struct {
   /* old: W_ updated; */
 } StgTickyHeader;
 
-#else /* !TICKY_TICKY */
-
-typedef struct {
-       /* empty */
-} StgTickyHeader;
-
-#endif /* TICKY_TICKY */
-
 /* -----------------------------------------------------------------------------
    The full fixed-size closure header
 
index 5e02a98..ec20df6 100644 (file)
@@ -1,13 +1,17 @@
 /* ----------------------------------------------------------------------------
- * $Id: Constants.h,v 1.17 2001/08/01 08:20:33 simonmar Exp $
+ * $Id: Constants.h,v 1.18 2001/10/03 13:57:42 simonmar Exp $
  *
  * (c) The GHC Team, 1998-1999
  *
  * 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
 #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
-
-/* -----------------------------------------------------------------------------
-   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
    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
index 516b188..bfaa7d4 100644 (file)
@@ -1,5 +1,5 @@
 /* ----------------------------------------------------------------------------
- * $Id: InfoTables.h,v 1.22 2001/08/29 17:24:25 qrczak Exp $
+ * $Id: InfoTables.h,v 1.23 2001/10/03 13:57:42 simonmar Exp $
  * 
  * (c) The GHC Team, 1998-1999
  *
    Profiling info
    -------------------------------------------------------------------------- */
 
-#ifdef PROFILING
-
 typedef struct {
     char *closure_type;
     char *closure_desc;
 } StgProfInfo;
 
-#else /* !PROFILING */
-
-typedef struct {
-  /* empty */
-} StgProfInfo;
-
-#endif /* PROFILING */
-
 /* -----------------------------------------------------------------------------
    Parallelism info
    -------------------------------------------------------------------------- */
@@ -42,13 +32,12 @@ typedef struct {
   StgInfoTable *rbh_infoptr;     /* infoptr to the RBH  */
 } StgParInfo;
 
-#else /* !PAR */
+#endif /* 0 */
 
 typedef struct {
        /* empty */
 } StgParInfo;
 
-#endif /* PAR */
 
 /*
    Copied from ghc-0.29; ToDo: check this code -- HWL
@@ -98,6 +87,14 @@ typedef struct {
 #endif
 
 /* -----------------------------------------------------------------------------
+   Ticky info
+   -------------------------------------------------------------------------- */
+
+typedef struct {
+    /* empty */
+} StgTickyInfo;
+
+/* -----------------------------------------------------------------------------
    Debugging info
    -------------------------------------------------------------------------- */
 
@@ -217,6 +214,9 @@ typedef struct _StgInfoTable {
 #ifdef PROFILING
     StgProfInfo     prof;
 #endif
+#ifdef TICKY
+    StgTickyInfo    ticky;
+#endif
 #ifdef DEBUG_CLOSURE
     StgDebugInfo    debug;
 #endif
index f6a9bc9..0726210 100644 (file)
@@ -1,57 +1,89 @@
 /* -----------------------------------------------------------------------------
- * $Id: MachDeps.h,v 1.6 2001/08/17 17:18:53 apt Exp $
+ * $Id: MachDeps.h,v 1.7 2001/10/03 13:57:42 simonmar Exp $
  *
  * (c) The GRASP/AQUA Project, Glasgow University, 1998
  * (c) The GHC Team, 1998-1999
+ * (c) The University of Glasgow 2001
  * 
  * Definitions that characterise machine specific properties of basic
- * Stg types provided as unboxed types (mirrors the typedefs in
- * StgTypes.)
+ * types (C & Haskell).
  *
+ * NB: Keep in sync with HsFFI.h and StgTypes.h.
  * NB: THIS FILE IS INCLUDED IN HASKELL SOURCE!
  * ---------------------------------------------------------------------------*/
 
 #ifndef MACHDEPS_H
 #define MACHDEPS_H
 
+/* Sizes of C types come from here... */
 #include "config.h"
 
+/* Sizes of Haskell types follow.  These sizes correspond to:
+ *   - the number of bytes in the primitive type (eg. Int#)
+ *   - the number of bytes in the external representation (eg. HsInt)
+ *   - the scale offset used by writeFooOffAddr#
+ *
+ * In the heap, the type may take up more space: eg. SIZEOF_INT8 == 1,
+ * but it takes up SIZEOF_HSWORD (4 or 8) bytes in the heap.
+ */
 
+/* First, check some assumptions.. */
+#if SIZEOF_CHAR != 1
+#error GHC untested on this architecture: sizeof(char) != 1
+#endif
 
-#define CHAR_SIZE_IN_BYTES     1
-#define ADDR_SIZE_IN_BYTES     SIZEOF_VOID_P
-#define INT_SIZE_IN_BYTES      SIZEOF_LONG
-#define WORD_SIZE_IN_BYTES     SIZEOF_LONG
-
-#ifndef WORD_SIZE_IN_BITS
-#if WORD_SIZE_IN_BYTES == 4
-#define WORD_SIZE_IN_BITS       32
-#else 
-#define WORD_SIZE_IN_BITS       64
+#if SIZEOF_SHORT != 2
+#error GHC untested on this architecture: sizeof(short) != 2
 #endif
+
+#if SIZEOF_UNSIGNED_INT != 4
+#error GHC untested on this architecture: sizeof(unsigned int) != 4
 #endif
 
-#define FLOAT_SIZE_IN_BYTES    SIZEOF_FLOAT
-#define DOUBLE_SIZE_IN_BYTES   SIZEOF_DOUBLE
+#define SIZEOF_HSCHAR           SIZEOF_WORD32
+#define ALIGNMENT_HSCHAR        ALIGNMENT_WORD32
+
+#define SIZEOF_HSINT            SIZEOF_VOID_P
+#define ALIGNMENT_HSINT         ALIGNMENT_VOID_P
+
+#define SIZEOF_HSWORD          SIZEOF_VOID_P
+#define ALIGNMENT_HSWORD       ALIGNMENT_VOID_P
+
+#define SIZEOF_HSDOUBLE                SIZEOF_DOUBLE
+#define ALIGNMENT_HSDOUBLE     ALIGNMENT_DOUBLE
+
+#define SIZEOF_HSFLOAT         SIZEOF_FLOAT
+#define ALIGNMENT_HSFLOAT      ALIGNMENT_FLOAT
+
+#define SIZEOF_HSPTR            SIZEOF_VOID_P
+#define ALIGNMENT_HSPTR         ALIGNMENT_VOID_P
+
+#define SIZEOF_HSFUNPTR         SIZEOF_VOID_P
+#define ALIGNMENT_HSFUNPTR      ALIGNMENT_VOID_P
+
+#define SIZEOF_HSFOREIGNPTR     SIZEOF_VOID_P
+#define ALIGNMENT_HSFOREIGNPTR  ALIGNMENT_VOID_P
+
+#define SIZEOF_HSSTABLEPTR      SIZEOF_VOID_P
+#define ALIGNMENT_HSSTABLEPTR   ALIGNMENT_VOID_P
 
 #define SIZEOF_INT8             SIZEOF_CHAR
 #define ALIGNMENT_INT8          ALIGNMENT_CHAR
+
 #define SIZEOF_WORD8            SIZEOF_UNSIGNED_CHAR
 #define ALIGNMENT_WORD8         ALIGNMENT_UNSIGNED_CHAR
 
 #define SIZEOF_INT16            SIZEOF_SHORT
 #define ALIGNMENT_INT16         ALIGNMENT_SHORT
+
 #define SIZEOF_WORD16           SIZEOF_UNSIGNED_SHORT
 #define ALIGNMENT_WORD16        ALIGNMENT_UNSIGNED_SHORT
 
-#if SIZEOF_UNSIGNED_INT == 4
 #define SIZEOF_INT32            SIZEOF_INT
 #define ALIGNMENT_INT32         ALIGNMENT_INT
+
 #define SIZEOF_WORD32           SIZEOF_UNSIGNED_INT
 #define ALIGNMENT_WORD32        ALIGNMENT_UNSIGNED_INT
-#else
-#error GHC untested on this architecture: sizeof(unsigned int) != 4
-#endif
 
 #if HAVE_LONG_LONG && SIZEOF_VOID_P < 8
 /* assume long long is 64 bits */
 #error GHC untested on this architecture: sizeof(void *) < 8 and no long longs.
 #endif
 
+#ifndef WORD_SIZE_IN_BITS
+#if SIZEOF_HSWORD == 4
+#define WORD_SIZE_IN_BITS       32
+#else 
+#define WORD_SIZE_IN_BITS       64
+#endif
 #endif
+
+#endif /* MACHDEPS_H */
index a650ca9..fddd4d0 100644 (file)
@@ -1,5 +1,5 @@
 # -----------------------------------------------------------------------------
-# $Id: Makefile,v 1.15 2001/07/16 21:01:58 qrczak Exp $
+# $Id: Makefile,v 1.16 2001/10/03 13:57:42 simonmar Exp $
 #
 
 TOP = ..
@@ -64,8 +64,25 @@ endif
 # ---------------------------------------------------------------------------
 # Make NativeDefs.h for the NCG
 
-C_PROG = mkNativeHdr
-C_SRCS = mkNativeHdr.c
+all :: DerivedConstants.h
+
+mkDerivedConstantsHdr : mkDerivedConstants.o
+       $(CC) -o $@ $(CC_OPTS) $(LD_OPTS) mkDerivedConstants.o
+
+DerivedConstants.h : mkDerivedConstantsHdr
+       ./mkDerivedConstantsHdr >DerivedConstants.h
+
+CLEAN_FILES += DerivedConstants.h
+
+# ---------------------------------------------------------------------------
+# Make NativeDefs.h for the NCG
+
+all :: NativeDefs.h
+
+mkNativeHdr.o : DerivedConstants.h
+
+mkNativeHdr : mkNativeHdr.o
+       $(CC) -o $@ $(CC_OPTS) $(LD_OPTS) mkNativeHdr.o
 
 NativeDefs.h : mkNativeHdr
        ./mkNativeHdr >NativeDefs.h
index f19f4d2..46f8491 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: StgProf.h,v 1.10 2000/05/12 13:01:04 simonmar Exp $
+ * $Id: StgProf.h,v 1.11 2001/10/03 13:57:42 simonmar Exp $
  *
  * (c) The GHC Team, 1998
  *
@@ -9,33 +9,9 @@
 #ifndef STGPROF_H
 #define STGPROF_H
 
-#if !defined(PROFILING)
-  
-#define CCS_ALLOC(ccs, amount) doNothing()
-#define ENTER_CC_PAP_CL(r)     doNothing()
-#define ENTER_CCS_PAP_CL(r)    doNothing()
-#else /* PROFILING... */
-
-/* -----------------------------------------------------------------------------
- * Constants
- * ---------------------------------------------------------------------------*/
-
-#define EMPTY_STACK NULL
-#define EMPTY_TABLE NULL
-
-/* Constants used to set sumbsumed flag on CostCentres */
-
-#define CC_IS_CAF      'c'            /* 'c'  => *is* a CAF cc           */
-#define CC_IS_BORING   'B'            /* 'B'  => *not* a CAF/sub cc      */
-
 /* -----------------------------------------------------------------------------
  * Data Structures 
  * ---------------------------------------------------------------------------*/  
-/* 
- * CostCentre 
- */
-
 typedef struct _CostCentre {
   int ccID;
 
@@ -44,7 +20,7 @@ typedef struct _CostCentre {
  
   /* used for accumulating costs at the end of the run... */
   unsigned long time_ticks;
-  unsigned long mem_alloc;
+  unsigned long long mem_alloc;
 
   char is_caf;
 
@@ -52,11 +28,6 @@ typedef struct _CostCentre {
 } CostCentre;
 
 
-       
-/* 
- * CostCentreStack 
- */
-
 typedef struct _CostCentreStack {
   int ccsID;
 
@@ -64,20 +35,46 @@ typedef struct _CostCentreStack {
   struct _CostCentreStack *prevStack;
   struct _IndexTable *indexTable;
   
-  unsigned long scc_count;
+  unsigned long long scc_count;
     
   unsigned long time_ticks;
-  unsigned long mem_alloc;
+  unsigned long long mem_alloc;
   unsigned long mem_resid;
 
   unsigned long inherited_ticks;
-  unsigned long inherited_alloc;
+  unsigned long long inherited_alloc;
 
   CostCentre *root;
 } CostCentreStack;
 
 
+/* -----------------------------------------------------------------------------
+ * The rest is PROFILING only...
+ * ---------------------------------------------------------------------------*/
 
+#if !defined(PROFILING)
+  
+#define CCS_ALLOC(ccs, amount) doNothing()
+#define ENTER_CC_PAP_CL(r)     doNothing()
+#define ENTER_CCS_PAP_CL(r)    doNothing()
+#else /* PROFILING... */
+
+/* -----------------------------------------------------------------------------
+ * Constants
+ * ---------------------------------------------------------------------------*/
+
+#define EMPTY_STACK NULL
+#define EMPTY_TABLE NULL
+
+/* Constants used to set sumbsumed flag on CostCentres */
+
+#define CC_IS_CAF      'c'            /* 'c'  => *is* a CAF cc           */
+#define CC_IS_BORING   'B'            /* 'B'  => *not* a CAF/sub cc      */
+
+/* -----------------------------------------------------------------------------
+ * Data Structures 
+ * ---------------------------------------------------------------------------*/  
 /* 
  * IndexTable 
  */
index fd9401d..e864d81 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: StgTypes.h,v 1.17 2001/07/26 03:08:39 ken Exp $
+ * $Id: StgTypes.h,v 1.18 2001/10/03 13:57:42 simonmar Exp $
  *
  * (c) The GHC Team, 1998-2000
  *
@@ -25,7 +25,7 @@
        StgCode, StgArray, StgByteArray, StgStablePtr, StgFunPtr,
        StgUnion.
 
- * WARNING: Keep this file and HsFFI.h in synch!
+ * WARNING: Keep this file, MachDeps.h, and HsFFI.h in synch!
  *
  * NOTE: assumes #include "config.h"
  * 
diff --git a/ghc/includes/mkDerivedConstants.c b/ghc/includes/mkDerivedConstants.c
new file mode 100644 (file)
index 0000000..fc0e591
--- /dev/null
@@ -0,0 +1,61 @@
+/* --------------------------------------------------------------------------
+ * $Id: mkDerivedConstants.c,v 1.1 2001/10/03 13:57:42 simonmar Exp $
+ *
+ * (c) The GHC Team, 1992-1998
+ *
+ * Generate a header for the native code generator
+ *
+ * ------------------------------------------------------------------------*/
+
+#include "Rts.h"
+
+#define OFFSET(s_type, field) ((unsigned int)&(((s_type*)0)->field))
+
+int
+main(int argc, char *argv[])
+{
+    printf("-- This file is created automatically.  Do not edit by hand.\n\n");
+
+    printf("#define STD_HDR_SIZE   %d\n", sizeofW(StgHeader));
+    printf("#define PROF_HDR_SIZE  %d\n", sizeofW(StgProfHeader));
+    printf("#define GRAN_HDR_SIZE  %d\n", sizeofW(StgGranHeader));
+    printf("#define PAR_HDR_SIZE   %d\n", sizeofW(StgParHeader));
+    printf("#define TICKY_HDR_SIZE %d\n", sizeofW(StgTickyHeader));
+
+    printf("#define ARR_WORDS_HDR_SIZE  %d\n", 
+          sizeofW(StgArrWords) - sizeofW(StgHeader));
+
+    printf("#define ARR_PTRS_HDR_SIZE   %d\n", 
+          sizeofW(StgMutArrPtrs) - sizeofW(StgHeader));
+
+    printf("#define STD_ITBL_SIZE   %d\n", sizeofW(StgInfoTable));
+    printf("#define PROF_ITBL_SIZE  %d\n", sizeofW(StgProfInfo));
+    printf("#define GRAN_ITBL_SIZE  %d\n", 0);
+    printf("#define PAR_ITBL_SIZE   %d\n", sizeofW(StgParInfo));
+    printf("#define TICKY_ITBL_SIZE %d\n", sizeofW(StgTickyInfo));
+
+    printf("#define STD_UF_SIZE   %d\n", sizeofW(StgUpdateFrame));
+    printf("#define GRAN_UF_SIZE   %d\n",  
+          sizeofW(StgUpdateFrame) + sizeofW(StgGranHeader));
+    printf("#define PROF_UF_SIZE   %d\n",  
+          sizeofW(StgUpdateFrame) + sizeofW(StgProfHeader));
+
+    printf("#define UF_RET     %d\n",
+          OFFSET(StgUpdateFrame,header.info));
+
+    printf("#define UF_SU      %d\n",  
+          OFFSET(StgUpdateFrame,link) / sizeof(W_));
+
+    printf("#define UF_UPDATEE %d\n",
+          OFFSET(StgUpdateFrame,updatee) / sizeof(W_));
+
+    printf("#define STD_SEQ_FRAME_SIZE   %d\n", sizeofW(StgSeqFrame));
+    printf("#define GRAN_SEQ_FRAME_SIZE   %d\n",  
+          sizeofW(StgSeqFrame) + sizeofW(StgGranHeader));
+    printf("#define PROF_SEQ_FRAME_SIZE   %d\n",  
+          sizeofW(StgSeqFrame) + sizeofW(StgProfHeader));
+
+    printf("#define BLOCK_SIZE   %d\n", BLOCK_SIZE);
+    printf("#define MBLOCK_SIZE   %d\n", MBLOCK_SIZE);  
+    return 0;
+}
index a874a8e..6707bd5 100644 (file)
@@ -1,5 +1,5 @@
 % ------------------------------------------------------------------------------
-% $Id: PrelNum.lhs,v 1.40 2001/07/24 06:31:35 ken Exp $
+% $Id: PrelNum.lhs,v 1.41 2001/10/03 13:57:42 simonmar Exp $
 %
 % (c) The University of Glasgow, 1994-2000
 %
@@ -19,12 +19,12 @@ and the type
 {-# OPTIONS -fno-implicit-prelude #-}
 
 #include "MachDeps.h"
-#if WORD_SIZE_IN_BYTES == 4
+#if SIZEOF_HSWORD == 4
 #define LEFTMOST_BIT 2147483648
-#elif WORD_SIZE_IN_BYTES == 8
+#elif SIZEOF_HSWORD == 8
 #define LEFTMOST_BIT 9223372036854775808
 #else
-#error Please define LEFTMOST_BIT to be 2^(WORD_SIZE_IN_BYTES*8-1)
+#error Please define LEFTMOST_BIT to be 2^(SIZEOF_HSWORD*8-1)
 #endif
 
 module PrelNum where
index 0166232..b5f9089 100644 (file)
@@ -1,5 +1,5 @@
 % -----------------------------------------------------------------------------
-% $Id: PrelStorable.lhs,v 1.9 2001/08/17 17:18:54 apt Exp $
+% $Id: PrelStorable.lhs,v 1.10 2001/10/03 13:57:42 simonmar Exp $
 %
 % (c) The FFI task force, 2000
 %
@@ -106,25 +106,25 @@ instance Storable (T) where {                     \
 STORABLE(Char,SIZEOF_INT32,ALIGNMENT_INT32,
         readWideCharOffPtr,writeWideCharOffPtr)
 
-STORABLE(Int,SIZEOF_LONG,ALIGNMENT_LONG,
+STORABLE(Int,SIZEOF_HSINT,ALIGNMENT_HSINT,
         readIntOffPtr,writeIntOffPtr)
 
-STORABLE(Word,SIZEOF_LONG,ALIGNMENT_LONG,
+STORABLE(Word,SIZEOF_HSWORD,ALIGNMENT_HSWORD,
         readWordOffPtr,writeWordOffPtr)
 
-STORABLE((Ptr a),SIZEOF_VOID_P,ALIGNMENT_VOID_P,
+STORABLE((Ptr a),SIZEOF_HSPTR,ALIGNMENT_HSPTR,
         readPtrOffPtr,writePtrOffPtr)
 
-STORABLE((FunPtr a),SIZEOF_VOID_P,ALIGNMENT_VOID_P,
+STORABLE((FunPtr a),SIZEOF_HSFUNPTR,ALIGNMENT_HSFUNPTR,
         readFunPtrOffPtr,writeFunPtrOffPtr)
 
-STORABLE((StablePtr a),SIZEOF_VOID_P,ALIGNMENT_VOID_P,
+STORABLE((StablePtr a),SIZEOF_HSSTABLEPTR,ALIGNMENT_HSSTABLEPTR,
         readStablePtrOffPtr,writeStablePtrOffPtr)
 
-STORABLE(Float,SIZEOF_FLOAT,ALIGNMENT_FLOAT,
+STORABLE(Float,SIZEOF_HSFLOAT,ALIGNMENT_HSFLOAT,
         readFloatOffPtr,writeFloatOffPtr)
 
-STORABLE(Double,SIZEOF_DOUBLE,ALIGNMENT_DOUBLE,
+STORABLE(Double,SIZEOF_HSDOUBLE,ALIGNMENT_HSDOUBLE,
         readDoubleOffPtr,writeDoubleOffPtr)
 
 STORABLE(Word8,SIZEOF_WORD8,ALIGNMENT_WORD8,