summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2022-03-01 13:49:57 -0500
committerBen Gamari <ben@smart-cactus.org>2022-03-03 14:25:04 -0500
commit35c93ce3c37ea40ecafe9c58213599e8ca28c58c (patch)
tree0d6aeb518de0081b38a33e7a961714289e972533
parentdc8ed73d39a6e2fb52c7b53c6cc927616c8f9234 (diff)
downloadhaskell-35c93ce3c37ea40ecafe9c58213599e8ca28c58c.tar.gz
rts: Factor out built-in GC roots
(cherry picked from commit 18d7007e0cd1140936b803df4816110cee0ed086)
-rw-r--r--rts/RtsStartup.c76
1 files changed, 41 insertions, 35 deletions
diff --git a/rts/RtsStartup.c b/rts/RtsStartup.c
index 21075f0401..d64f87cf7e 100644
--- a/rts/RtsStartup.c
+++ b/rts/RtsStartup.c
@@ -176,6 +176,45 @@ hs_restoreConsoleCP (void)
Starting up the RTS
-------------------------------------------------------------------------- */
+static void initBuiltinGcRoots(void)
+{
+ /* Add some GC roots for things in the base package that the RTS
+ * knows about. We don't know whether these turn out to be CAFs
+ * or refer to CAFs, but we have to assume that they might.
+ *
+ * Because these stable pointers will retain any CAF references in
+ * these closures `Id`s of these can be safely marked as non-CAFFY
+ * in the compiler.
+ */
+ getStablePtr((StgPtr)runIO_closure);
+ getStablePtr((StgPtr)runNonIO_closure);
+ getStablePtr((StgPtr)flushStdHandles_closure);
+
+ getStablePtr((StgPtr)runFinalizerBatch_closure);
+
+ getStablePtr((StgPtr)stackOverflow_closure);
+ getStablePtr((StgPtr)heapOverflow_closure);
+ getStablePtr((StgPtr)unpackCString_closure);
+ getStablePtr((StgPtr)blockedIndefinitelyOnMVar_closure);
+ getStablePtr((StgPtr)nonTermination_closure);
+ getStablePtr((StgPtr)blockedIndefinitelyOnSTM_closure);
+ getStablePtr((StgPtr)allocationLimitExceeded_closure);
+ getStablePtr((StgPtr)cannotCompactFunction_closure);
+ getStablePtr((StgPtr)cannotCompactPinned_closure);
+ getStablePtr((StgPtr)cannotCompactMutable_closure);
+ getStablePtr((StgPtr)nestedAtomically_closure);
+ getStablePtr((StgPtr)runSparks_closure);
+ getStablePtr((StgPtr)ensureIOManagerIsRunning_closure);
+ getStablePtr((StgPtr)interruptIOManager_closure);
+ getStablePtr((StgPtr)ioManagerCapabilitiesChanged_closure);
+#if !defined(mingw32_HOST_OS)
+ getStablePtr((StgPtr)blockedOnBadFD_closure);
+ getStablePtr((StgPtr)runHandlersPtr_closure);
+#else
+ getStablePtr((StgPtr)processRemoteCompletion_closure);
+#endif
+}
+
void
hs_init(int *argc, char **argv[])
{
@@ -313,41 +352,8 @@ hs_init_ghc(int *argc, char **argv[], RtsConfig rts_config)
/* initialise the stable name table */
initStableNameTable();
- /* Add some GC roots for things in the base package that the RTS
- * knows about. We don't know whether these turn out to be CAFs
- * or refer to CAFs, but we have to assume that they might.
- *
- * Because these stable pointers will retain any CAF references in
- * these closures `Id`s of these can be safely marked as non-CAFFY
- * in the compiler.
- */
- getStablePtr((StgPtr)runIO_closure);
- getStablePtr((StgPtr)runNonIO_closure);
- getStablePtr((StgPtr)flushStdHandles_closure);
-
- getStablePtr((StgPtr)runFinalizerBatch_closure);
-
- getStablePtr((StgPtr)stackOverflow_closure);
- getStablePtr((StgPtr)heapOverflow_closure);
- getStablePtr((StgPtr)unpackCString_closure);
- getStablePtr((StgPtr)blockedIndefinitelyOnMVar_closure);
- getStablePtr((StgPtr)nonTermination_closure);
- getStablePtr((StgPtr)blockedIndefinitelyOnSTM_closure);
- getStablePtr((StgPtr)allocationLimitExceeded_closure);
- getStablePtr((StgPtr)cannotCompactFunction_closure);
- getStablePtr((StgPtr)cannotCompactPinned_closure);
- getStablePtr((StgPtr)cannotCompactMutable_closure);
- getStablePtr((StgPtr)nestedAtomically_closure);
- getStablePtr((StgPtr)runSparks_closure);
- getStablePtr((StgPtr)ensureIOManagerIsRunning_closure);
- getStablePtr((StgPtr)interruptIOManager_closure);
- getStablePtr((StgPtr)ioManagerCapabilitiesChanged_closure);
-#if !defined(mingw32_HOST_OS)
- getStablePtr((StgPtr)blockedOnBadFD_closure);
- getStablePtr((StgPtr)runHandlersPtr_closure);
-#else
- getStablePtr((StgPtr)processRemoteCompletion_closure);
-#endif
+ /* create StablePtrs for builtin GC roots*/
+ initBuiltinGcRoots();
/*
* process any foreign exports which were registered while loading the