[project @ 1999-03-20 17:33:07 by sof]
[ghc-hetmet.git] / ghc / rts / Storage.h
index d197087..9c9b270 100644 (file)
@@ -1,5 +1,7 @@
 /* -----------------------------------------------------------------------------
- * $Id: Storage.h,v 1.3 1999/01/13 17:25:48 simonm Exp $
+ * $Id: Storage.h,v 1.8 1999/03/18 17:57:23 simonm Exp $
+ *
+ * (c) The GHC Team, 1998-1999
  *
  * External Storage Manger Interface
  *
@@ -25,6 +27,10 @@ extern void exitStorage(void);
    StgPtr allocate(int n)       Allocates a chunk of contiguous store
                                n words long, returning a pointer to
                                the first word.  Always succeeds.
+                               
+                               Don't forget to TICK_ALLOC_XXX(...)
+                               after calling allocate, 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.
@@ -87,13 +93,31 @@ extern StgClosure *MarkRoot(StgClosure *p);
 
    -------------------------------------------------------------------------- */
 
-extern void recordMutable(StgMutClosure *p);
+static inline void
+recordMutable(StgMutClosure *p)
+{
+  bdescr *bd;
 
-#ifdef TICKY_TICKY
-#error updateWithIndirection: maybe permanent indirection?
-# define Ind_info_TO_USE ((AllFlags.doUpdEntryCounts) ? &IND_PERM_info : &IND_info
-)
-#endif
+  ASSERT(closure_MUTABLE(p));
+
+  bd = Bdescr((P_)p);
+  if (bd->gen->no > 0) {
+    p->mut_link = bd->gen->mut_list;
+    bd->gen->mut_list = p;
+  }
+}
+
+static inline void
+recordOldToNewPtrs(StgMutClosure *p)
+{
+  bdescr *bd;
+  
+  bd = Bdescr((P_)p);
+  if (bd->gen->no > 0) {
+    p->mut_link = bd->gen->mut_once_list;
+    bd->gen->mut_once_list = p;
+  }
+}
 
 static inline void
 updateWithIndirection(StgClosure *p1, StgClosure *p2) 
@@ -104,20 +128,43 @@ updateWithIndirection(StgClosure *p1, StgClosure *p2)
   if (bd->gen->no == 0) {
     SET_INFO(p1,&IND_info);
     ((StgInd *)p1)->indirectee = p2;
+    TICK_UPD_NEW_IND();
   } else {
     SET_INFO(p1,&IND_OLDGEN_info);
     ((StgIndOldGen *)p1)->indirectee = p2;
-    ((StgIndOldGen *)p1)->mut_link = bd->gen->mut_list;
-    bd->gen->mut_list = (StgMutClosure *)p1;
+    ((StgIndOldGen *)p1)->mut_link = bd->gen->mut_once_list;
+    bd->gen->mut_once_list = (StgMutClosure *)p1;
+    TICK_UPD_OLD_IND();
   }
 }
 
+#ifdef PROFILING
+static inline void
+updateWithPermIndirection(StgClosure *p1, StgClosure *p2) 
+{
+  bdescr *bd;
+
+  bd = Bdescr((P_)p1);
+  if (bd->gen->no == 0) {
+    SET_INFO(p1,&IND_PERM_info);
+    ((StgInd *)p1)->indirectee = p2;
+    TICK_UPD_NEW_IND();
+  } else {
+    SET_INFO(p1,&IND_OLDGEN_PERM_info);
+    ((StgIndOldGen *)p1)->indirectee = p2;
+    ((StgIndOldGen *)p1)->mut_link = bd->gen->mut_once_list;
+    bd->gen->mut_once_list = (StgMutClosure *)p1;
+    TICK_UPD_OLD_IND();
+  }
+}
+#endif
+
 /* -----------------------------------------------------------------------------
    The CAF list - used to let us revert CAFs
 
    -------------------------------------------------------------------------- */
 
-StgCAF* enteredCAFs;
+extern StgCAF* enteredCAFs;
 
 #endif STORAGE_H