summaryrefslogtreecommitdiff
path: root/rts
diff options
context:
space:
mode:
authorSimon Marlow <simonmar@microsoft.com>2007-10-30 13:00:52 +0000
committerSimon Marlow <simonmar@microsoft.com>2007-10-30 13:00:52 +0000
commit79c9408712af3ddd6340b0b5785ffde34f830042 (patch)
treeacf688a0b52cce3faee55306e81a13c10dca5bc1 /rts
parent0449741f968cbb8a9777ff44c5d43d47a5592b0e (diff)
downloadhaskell-79c9408712af3ddd6340b0b5785ffde34f830042.tar.gz
move GetRoots() to GC.c
Diffstat (limited to 'rts')
-rw-r--r--rts/Schedule.c81
-rw-r--r--rts/Schedule.h9
-rw-r--r--rts/sm/GC.c79
3 files changed, 79 insertions, 90 deletions
diff --git a/rts/Schedule.c b/rts/Schedule.c
index 1bd68c2297..2b7ebcb982 100644
--- a/rts/Schedule.c
+++ b/rts/Schedule.c
@@ -2673,87 +2673,6 @@ freeScheduler( void )
#endif
}
-/* ---------------------------------------------------------------------------
- Where are the roots that we know about?
-
- - all the threads on the runnable queue
- - all the threads on the blocked queue
- - all the threads on the sleeping queue
- - all the thread currently executing a _ccall_GC
- - all the "main threads"
-
- ------------------------------------------------------------------------ */
-
-/* This has to be protected either by the scheduler monitor, or by the
- garbage collection monitor (probably the latter).
- KH @ 25/10/99
-*/
-
-void
-GetRoots( evac_fn evac )
-{
- nat i;
- Capability *cap;
- Task *task;
-
-#if defined(GRAN)
- for (i=0; i<=RtsFlags.GranFlags.proc; i++) {
- if ((run_queue_hds[i] != END_TSO_QUEUE) && ((run_queue_hds[i] != NULL)))
- evac((StgClosure **)&run_queue_hds[i]);
- if ((run_queue_tls[i] != END_TSO_QUEUE) && ((run_queue_tls[i] != NULL)))
- evac((StgClosure **)&run_queue_tls[i]);
-
- if ((blocked_queue_hds[i] != END_TSO_QUEUE) && ((blocked_queue_hds[i] != NULL)))
- evac((StgClosure **)&blocked_queue_hds[i]);
- if ((blocked_queue_tls[i] != END_TSO_QUEUE) && ((blocked_queue_tls[i] != NULL)))
- evac((StgClosure **)&blocked_queue_tls[i]);
- if ((ccalling_threadss[i] != END_TSO_QUEUE) && ((ccalling_threadss[i] != NULL)))
- evac((StgClosure **)&ccalling_threads[i]);
- }
-
- markEventQueue();
-
-#else /* !GRAN */
-
- for (i = 0; i < n_capabilities; i++) {
- cap = &capabilities[i];
- evac((StgClosure **)(void *)&cap->run_queue_hd);
- evac((StgClosure **)(void *)&cap->run_queue_tl);
-#if defined(THREADED_RTS)
- evac((StgClosure **)(void *)&cap->wakeup_queue_hd);
- evac((StgClosure **)(void *)&cap->wakeup_queue_tl);
-#endif
- for (task = cap->suspended_ccalling_tasks; task != NULL;
- task=task->next) {
- debugTrace(DEBUG_sched,
- "evac'ing suspended TSO %lu", (unsigned long)task->suspended_tso->id);
- evac((StgClosure **)(void *)&task->suspended_tso);
- }
-
- }
-
-
-#if !defined(THREADED_RTS)
- evac((StgClosure **)(void *)&blocked_queue_hd);
- evac((StgClosure **)(void *)&blocked_queue_tl);
- evac((StgClosure **)(void *)&sleeping_queue);
-#endif
-#endif
-
- // evac((StgClosure **)&blackhole_queue);
-
-#if defined(THREADED_RTS) || defined(PARALLEL_HASKELL) || defined(GRAN)
- markSparkQueue(evac);
-#endif
-
-#if defined(RTS_USER_SIGNALS)
- // mark the signal handlers (signals should be already blocked)
- if (RtsFlags.MiscFlags.install_signal_handlers) {
- markSignalHandlers(evac);
- }
-#endif
-}
-
/* -----------------------------------------------------------------------------
performGC
diff --git a/rts/Schedule.h b/rts/Schedule.h
index ddac92be4b..a4a95f3c34 100644
--- a/rts/Schedule.h
+++ b/rts/Schedule.h
@@ -64,15 +64,6 @@ StgWord raiseExceptionHelper (StgRegTable *reg, StgTSO *tso, StgClosure *excepti
/* findRetryFrameHelper */
StgWord findRetryFrameHelper (StgTSO *tso);
-/* GetRoots(evac_fn f)
- *
- * Call f() for each root known to the scheduler.
- *
- * Called from STG : NO
- * Locks assumed : ????
- */
-void GetRoots(evac_fn);
-
/* workerStart()
*
* Entry point for a new worker task.
diff --git a/rts/sm/GC.c b/rts/sm/GC.c
index 4aa210cd7e..f686c6dd5f 100644
--- a/rts/sm/GC.c
+++ b/rts/sm/GC.c
@@ -1000,6 +1000,85 @@ GarbageCollect ( rtsBool force_major_gc )
RELEASE_SM_LOCK;
}
+/* ---------------------------------------------------------------------------
+ Where are the roots that we know about?
+
+ - all the threads on the runnable queue
+ - all the threads on the blocked queue
+ - all the threads on the sleeping queue
+ - all the thread currently executing a _ccall_GC
+ - all the "main threads"
+
+ ------------------------------------------------------------------------ */
+
+/* This has to be protected either by the scheduler monitor, or by the
+ garbage collection monitor (probably the latter).
+ KH @ 25/10/99
+*/
+
+void
+GetRoots( evac_fn evac )
+{
+ nat i;
+ Capability *cap;
+ Task *task;
+
+#if defined(GRAN)
+ for (i=0; i<=RtsFlags.GranFlags.proc; i++) {
+ if ((run_queue_hds[i] != END_TSO_QUEUE) && ((run_queue_hds[i] != NULL)))
+ evac((StgClosure **)&run_queue_hds[i]);
+ if ((run_queue_tls[i] != END_TSO_QUEUE) && ((run_queue_tls[i] != NULL)))
+ evac((StgClosure **)&run_queue_tls[i]);
+
+ if ((blocked_queue_hds[i] != END_TSO_QUEUE) && ((blocked_queue_hds[i] != NULL)))
+ evac((StgClosure **)&blocked_queue_hds[i]);
+ if ((blocked_queue_tls[i] != END_TSO_QUEUE) && ((blocked_queue_tls[i] != NULL)))
+ evac((StgClosure **)&blocked_queue_tls[i]);
+ if ((ccalling_threadss[i] != END_TSO_QUEUE) && ((ccalling_threadss[i] != NULL)))
+ evac((StgClosure **)&ccalling_threads[i]);
+ }
+
+ markEventQueue();
+
+#else /* !GRAN */
+
+ for (i = 0; i < n_capabilities; i++) {
+ cap = &capabilities[i];
+ evac((StgClosure **)(void *)&cap->run_queue_hd);
+ evac((StgClosure **)(void *)&cap->run_queue_tl);
+#if defined(THREADED_RTS)
+ evac((StgClosure **)(void *)&cap->wakeup_queue_hd);
+ evac((StgClosure **)(void *)&cap->wakeup_queue_tl);
+#endif
+ for (task = cap->suspended_ccalling_tasks; task != NULL;
+ task=task->next) {
+ debugTrace(DEBUG_sched,
+ "evac'ing suspended TSO %lu", (unsigned long)task->suspended_tso->id);
+ evac((StgClosure **)(void *)&task->suspended_tso);
+ }
+
+ }
+
+
+#if !defined(THREADED_RTS)
+ evac((StgClosure **)(void *)&blocked_queue_hd);
+ evac((StgClosure **)(void *)&blocked_queue_tl);
+ evac((StgClosure **)(void *)&sleeping_queue);
+#endif
+#endif
+
+ // evac((StgClosure **)&blackhole_queue);
+
+#if defined(THREADED_RTS) || defined(PARALLEL_HASKELL) || defined(GRAN)
+ markSparkQueue(evac);
+#endif
+
+#if defined(RTS_USER_SIGNALS)
+ // mark the signal handlers (signals should be already blocked)
+ markSignalHandlers(evac);
+#endif
+}
+
/* -----------------------------------------------------------------------------
isAlive determines whether the given closure is still alive (after
a garbage collection) or not. It returns the new address of the