Follow Src{Loc,Span} changes in other parts of the tree
[ghc-hetmet.git] / includes / rts / storage / Block.h
index d6a4d4c..c73c9af 100644 (file)
  * on a 32-bit machine.
  */
 
+// Note: fields marked with [READ ONLY] must not be modified by the
+// client of the block allocator API.  All other fields can be
+// freely modified.
+
 #ifndef CMINUSMINUS
 typedef struct bdescr_ {
-    StgPtr start;              /* start addr of memory */
-    StgPtr free;               /* first free byte of memory */
-    struct bdescr_ *link;      /* used for chaining blocks together */
+
+    StgPtr start;              // [READ ONLY] start addr of memory
+
+    StgPtr free;               // first free byte of memory.
+                               // NB. during use this value should lie
+                               // between start and start + blocks *
+                               // BLOCK_SIZE.  Values outside this
+                               // range are reserved for use by the
+                               // block allocator.  In particular, the
+                               // value (StgPtr)(-1) is used to
+                               // indicate that a block is unallocated.
+
+    struct bdescr_ *link;      // used for chaining blocks together
+
     union {
-        struct bdescr_ *back;  /* used (occasionally) for doubly-linked lists*/
-        StgWord *bitmap;
-        StgPtr  scan;           /* scan pointer for copying GC */
+        struct bdescr_ *back;  // used (occasionally) for doubly-linked lists
+        StgWord *bitmap;       // bitmap for marking GC
+        StgPtr  scan;          // scan pointer for copying GC
     } u;
 
-    struct generation_ *gen;   /* generation */
-    struct generation_ *dest;  /* destination gen */
+    struct generation_ *gen;   // generation
+
+    StgWord16 gen_no;          // gen->no, cached
+    StgWord16 dest_no;         // number of destination generation
+    StgWord16 _pad1;
 
-    StgWord32 blocks;          /* no. of blocks (if grp head, 0 otherwise) */
+    StgWord16 flags;           // block flags, see below
+
+    StgWord32 blocks;          // [READ ONLY] no. of blocks in a group
+                               // (if group head, 0 otherwise)
 
-    StgWord16 gen_no;
-    StgWord16 flags;            /* block flags, see below */
 #if SIZEOF_VOID_P == 8
-    StgWord32 _padding[2];
+    StgWord32 _padding[3];
 #else
     StgWord32 _padding[0];
 #endif
@@ -98,6 +117,8 @@ typedef struct bdescr_ {
 #define BF_FRAGMENTED 64
 /* we know about this block (for finding leaks) */
 #define BF_KNOWN     128
+/* Block was swept in the last generation */
+#define BF_SWEPT     256
 
 /* Finding the block descriptor for a given block -------------------------- */
 
@@ -147,7 +168,9 @@ EXTERN_INLINE bdescr *Bdescr(StgPtr p)
 
 /* Number of usable blocks in a megablock */
 
+#ifndef CMINUSMINUS // already defined in DerivedConstants.h
 #define BLOCKS_PER_MBLOCK ((MBLOCK_SIZE - FIRST_BLOCK_OFF) / BLOCK_SIZE)
+#endif
 
 /* How many blocks in this megablock group */