summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorSimon Marlow <marlowsd@gmail.com>2015-06-08 11:54:51 +0100
committerSimon Marlow <marlowsd@gmail.com>2015-06-08 11:59:22 +0100
commit19ec6a84d6344c2808d0d41da11956689a0e4ae9 (patch)
treee83ad4f659c4f6323b91d6e562bd1cdf7bacf765 /includes
parent89223ce1340654455a9f3aa9cbf25f30884227fd (diff)
downloadhaskell-19ec6a84d6344c2808d0d41da11956689a0e4ae9.tar.gz
Fix for CAF retention when dynamically loading & unloading code
In a situaion where we have some statically-linked code and we want to load and unload a series of objects, we need the CAFs in the statically-linked code to be retained indefinitely, while the CAFs in the dynamically-linked code should be GC'd as normal, so that we can detect when the code is unloadable. This was wrong before - we GC'd CAFs in the static code, leading to a crash in the rare case where we use a CAF, GC it, and then load a new object that uses it again. I also did some tidy up: RtsConfig now has a field keep_cafs to indicate whether we want CAFs to be retained in static code.
Diffstat (limited to 'includes')
-rw-r--r--includes/RtsAPI.h3
-rw-r--r--includes/rts/storage/GC.h6
2 files changed, 7 insertions, 2 deletions
diff --git a/includes/RtsAPI.h b/includes/RtsAPI.h
index 3b6de0f10c..4748060dee 100644
--- a/includes/RtsAPI.h
+++ b/includes/RtsAPI.h
@@ -73,6 +73,9 @@ typedef struct {
// True if GHC was not passed -no-hs-main
HsBool rts_hs_main;
+ // Whether to retain CAFs (default: false)
+ HsBool keep_cafs;
+
// Called before processing command-line flags, so that default
// settings for RtsFlags can be provided.
void (* defaultsHook) (void);
diff --git a/includes/rts/storage/GC.h b/includes/rts/storage/GC.h
index 444ef8871b..f7da838739 100644
--- a/includes/rts/storage/GC.h
+++ b/includes/rts/storage/GC.h
@@ -200,11 +200,13 @@ void performMajorGC(void);
The CAF table - used to let us revert CAFs in GHCi
-------------------------------------------------------------------------- */
-StgInd *newCAF (StgRegTable *reg, StgIndStatic *caf);
-StgInd *newDynCAF (StgRegTable *reg, StgIndStatic *caf);
+StgInd *newCAF (StgRegTable *reg, StgIndStatic *caf);
+StgInd *newRetainedCAF (StgRegTable *reg, StgIndStatic *caf);
+StgInd *newGCdCAF (StgRegTable *reg, StgIndStatic *caf);
void revertCAFs (void);
// Request that all CAFs are retained indefinitely.
+// (preferably use RtsConfig.keep_cafs instead)
void setKeepCAFs (void);
/* -----------------------------------------------------------------------------