[project @ 2002-06-19 20:45:14 by sof]
[ghc-hetmet.git] / ghc / includes / Block.h
index 113145e..1f84f78 100644 (file)
@@ -1,5 +1,7 @@
 /* -----------------------------------------------------------------------------
- * $Id: Block.h,v 1.3 1999/01/13 17:25:51 simonm Exp $
+ * $Id: Block.h,v 1.10 2001/10/03 13:57:42 simonmar Exp $
+ *
+ * (c) The GHC Team, 1998-1999
  *
  * Block structure for the storage manager
  *
@@ -14,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)
 
@@ -22,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)
 
@@ -42,15 +46,18 @@ typedef struct _bdescr {
   StgPtr start;                        /* start addr of memory */
   StgPtr free;                 /* first free byte of memory */
   struct _bdescr *link;                /* used for chaining blocks together */
-  struct _bdescr *back;                /* used (occasionally) for doubly-linked lists*/
-  struct _generation *gen;     /* generation */
+  union { 
+      struct _bdescr *back;    /* used (occasionally) for doubly-linked lists*/
+      StgWord *bitmap;
+  } u;
+  unsigned int gen_no;         /* generation */
   struct _step *step;          /* step */
-  StgNat32 blocks;             /* no. of blocks (if grp head, 0 otherwise) */
-  StgNat32 evacuated;           /* block is in to-space */
+  StgWord32 blocks;            /* no. of blocks (if grp head, 0 otherwise) */
+  StgWord32 flags;              /* block is in to-space */
 #if SIZEOF_VOID_P == 8
-  StgNat32 _padding[2];
+  StgWord32 _padding[2];
 #else
-  StgNat32 _padding[0];
+  StgWord32 _padding[0];
 #endif
 } bdescr;
 
@@ -64,6 +71,19 @@ typedef struct _bdescr {
 #define BDESCR_SHIFT 5
 #endif
 
+#define BF_EVACUATED 1
+#define BF_LARGE     2
+
+/* Finding the block descriptor for a given block -------------------------- */
+
+static inline bdescr *Bdescr(StgPtr p)
+{
+  return (bdescr *)
+    ((((W_)p &  MBLOCK_MASK & ~BLOCK_MASK) >> (BLOCK_SHIFT-BDESCR_SHIFT)) 
+     | ((W_)p & ~MBLOCK_MASK)
+     );
+}
+
 /* Useful Macros ------------------------------------------------------------ */
 
 /* Offset of first real data block in a megablock */
@@ -98,4 +118,4 @@ typedef struct _bdescr {
 #define BLOCKS_TO_MBLOCKS(n) \
    (1 + (W_)MBLOCK_ROUND_UP((n-BLOCKS_PER_MBLOCK) * BLOCK_SIZE) / MBLOCK_SIZE)
 
-#endif BLOCK_H
+#endif /* BLOCK_H */