Add a 'setKeepCAFs' external function (#3900)
authorSimon Marlow <marlowsd@gmail.com>
Mon, 29 Mar 2010 11:00:36 +0000 (11:00 +0000)
committerSimon Marlow <marlowsd@gmail.com>
Mon, 29 Mar 2010 11:00:36 +0000 (11:00 +0000)
includes/rts/storage/GC.h
rts/sm/Storage.c

index 9749c02..15c22ab 100644 (file)
@@ -171,6 +171,9 @@ void newCAF     (StgRegTable *reg, StgClosure *);
 void newDynCAF  (StgRegTable *reg, StgClosure *);
 void revertCAFs (void);
 
+// Request that all CAFs are retained indefinitely.
+void setKeepCAFs (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
index d7e5b67..6aedb96 100644 (file)
@@ -268,7 +268,6 @@ freeStorage (void)
 void
 newCAF(StgRegTable *reg, StgClosure* caf)
 {
-#ifdef DYNAMIC
   if(keepCAFs)
   {
     // HACK:
@@ -289,7 +288,6 @@ newCAF(StgRegTable *reg, StgClosure* caf)
     RELEASE_SM_LOCK;
   }
   else
-#endif
   {
     // Put this CAF on the mutable list for the old generation.
     ((StgIndStatic *)caf)->saved_info = NULL;
@@ -297,6 +295,13 @@ newCAF(StgRegTable *reg, StgClosure* caf)
   }
 }
 
+// External API for setting the keepCAFs flag. see #3900.
+void
+setKeepCAFs (void)
+{
+    keepCAFs = 1;
+}
+
 // An alternate version of newCaf which is used for dynamically loaded
 // object code in GHCi.  In this case we want to retain *all* CAFs in
 // the object code, because they might be demanded at any time from an