summaryrefslogtreecommitdiff
path: root/rts/sm/GC.c
diff options
context:
space:
mode:
authorSimon Marlow <marlowsd@gmail.com>2010-05-25 15:04:35 +0000
committerSimon Marlow <marlowsd@gmail.com>2010-05-25 15:04:35 +0000
commitf9ce05ef56187d981b5d1af51e3f53fc6f202d5b (patch)
tree7f1e10b97c8592f784c6db4c8a7b0e2775155bf9 /rts/sm/GC.c
parent6c016f3803fec507f6a509a4929fc2344ee66fd8 (diff)
downloadhaskell-f9ce05ef56187d981b5d1af51e3f53fc6f202d5b.tar.gz
Make sparks into weak pointers (#2185)
The new strategies library (parallel-2.0+, preferably 2.2+) is now required for parallel programming, otherwise parallelism will be lost.
Diffstat (limited to 'rts/sm/GC.c')
-rw-r--r--rts/sm/GC.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/rts/sm/GC.c b/rts/sm/GC.c
index 4d63724ba0..e7166a203b 100644
--- a/rts/sm/GC.c
+++ b/rts/sm/GC.c
@@ -411,6 +411,16 @@ SET_GCT(gc_threads[0]);
// Now see which stable names are still alive.
gcStablePtrTable();
+#ifdef THREADED_RTS
+ if (n_gc_threads == 1) {
+ for (n = 0; n < n_capabilities; n++) {
+ pruneSparkQueue(&capabilities[n]);
+ }
+ } else {
+ pruneSparkQueue(&capabilities[gct->thread_index]);
+ }
+#endif
+
#ifdef PROFILING
// We call processHeapClosureForDead() on every closure destroyed during
// the current garbage collection, so we invoke LdvCensusForDead().
@@ -1072,6 +1082,16 @@ gcWorkerThread (Capability *cap)
scavenge_until_all_done();
+#ifdef THREADED_RTS
+ // Now that the whole heap is marked, we discard any sparks that
+ // were found to be unreachable. The main GC thread is currently
+ // marking heap reachable via weak pointers, so it is
+ // non-deterministic whether a spark will be retained if it is
+ // only reachable via weak pointers. To fix this problem would
+ // require another GC barrier, which is too high a price.
+ pruneSparkQueue(cap);
+#endif
+
#ifdef USE_PAPI
// count events in this thread towards the GC totals
papi_thread_stop_gc1_count(gct->papi_events);