Make allocatePinned use local storage, and other refactorings
[ghc-hetmet.git] / includes / rts / storage / GC.h
index df4ba9d..1cd57c9 100644 (file)
@@ -75,10 +75,6 @@ typedef struct step_ {
     // ------------------------------------
     // Fields below are used during GC only
 
-    // During GC, if we are collecting this step, blocks and n_blocks
-    // are copied into the following two fields.  After GC, these blocks
-    // are freed.
-
 #if defined(THREADED_RTS)
     char pad[128];                      // make sure the following is
                                         // on a separate cache line.
@@ -89,6 +85,9 @@ typedef struct step_ {
     int          mark;                 // mark (not copy)? (old gen only)
     int          compact;              // compact (not sweep)? (old gen only)
 
+    // During GC, if we are collecting this step, blocks and n_blocks
+    // are copied into the following two fields.  After GC, these blocks
+    // are freed.
     bdescr *     old_blocks;           // bdescr of first from-space block
     unsigned int n_old_blocks;         // number of blocks in from-space
     unsigned int live_estimate;         // for sweeping: estimate of live data
@@ -125,7 +124,6 @@ typedef struct generation_ {
 extern generation * generations;
 
 extern generation * g0;
-extern step * g0s0;
 extern generation * oldest_gen;
 extern step * all_steps;
 extern nat total_steps;
@@ -133,21 +131,14 @@ extern nat total_steps;
 /* -----------------------------------------------------------------------------
    Generic allocation
 
-   StgPtr allocateInGen(generation *g, nat n)
-                                Allocates a chunk of contiguous store
-                               n words long in generation g,
-                               returning a pointer to the first word.
-                               Always succeeds.
-                               
-   StgPtr allocate(nat n)       Equaivalent to allocateInGen(g0)
-                               
-   StgPtr allocateLocal(Capability *cap, nat n)
+   StgPtr allocate(Capability *cap, nat n)
                                 Allocates memory from the nursery in
                                the current Capability.  This can be
                                done without taking a global lock,
                                 unlike allocate().
 
-   StgPtr allocatePinned(nat n) Allocates a chunk of contiguous store
+   StgPtr allocatePinned(Capability *cap, nat n) 
+                                Allocates a chunk of contiguous store
                                n words long, which is at a fixed
                                address (won't be moved by GC).  
                                Returns a pointer to the first word.
@@ -163,25 +154,18 @@ extern nat total_steps;
                                allocatePinned, for the
                                benefit of the ticky-ticky profiler.
 
-   rtsBool doYouWantToGC(void)  Returns True if the storage manager is
-                               ready to perform a GC, False otherwise.
-
-   lnat  allocatedBytes(void)  Returns the number of bytes allocated
-                                via allocate() since the last GC.
-                               Used in the reporting of statistics.
-
    -------------------------------------------------------------------------- */
 
-StgPtr  allocate        ( lnat n );
-StgPtr  allocateInGen   ( generation *g, lnat n );
-StgPtr  allocateLocal   ( Capability *cap, lnat n );
-StgPtr  allocatePinned  ( lnat n );
-lnat    allocatedBytes  ( void );
+StgPtr  allocate        ( Capability *cap, lnat n );
+StgPtr  allocatePinned  ( Capability *cap, lnat n );
 
 /* memory allocator for executable memory */
 void * allocateExec(unsigned int len, void **exec_addr);
 void   freeExec (void *p);
 
+// Used by GC checks in external .cmm code:
+extern nat alloc_blocks_lim;
+
 /* -----------------------------------------------------------------------------
    Performing Garbage Collection
    -------------------------------------------------------------------------- */
@@ -197,8 +181,24 @@ void newCAF     (StgClosure*);
 void newDynCAF  (StgClosure *);
 void revertCAFs (void);
 
+/* -----------------------------------------------------------------------------
+   This is the write barrier for MUT_VARs, a.k.a. IORefs.  A
+   MUT_VAR_CLEAN object is not on the mutable list; a MUT_VAR_DIRTY
+   is.  When written to, a MUT_VAR_CLEAN turns into a MUT_VAR_DIRTY
+   and is put on the mutable list.
+   -------------------------------------------------------------------------- */
+
+void dirty_MUT_VAR(StgRegTable *reg, StgClosure *p);
+
 /* set to disable CAF garbage collection in GHCi. */
 /* (needed when dynamic libraries are used). */
 extern rtsBool keepCAFs;
 
+INLINE_HEADER void initBdescr(bdescr *bd, step *step)
+{
+    bd->step   = step;
+    bd->gen_no = step->gen_no;
+    bd->dest   = step->to;
+}
+
 #endif /* RTS_STORAGE_GC_H */