From: Simon Marlow Date: Tue, 30 Oct 2007 13:00:52 +0000 (+0000) Subject: move GetRoots() to GC.c X-Git-Tag: Before_cabalised-GHC~306 X-Git-Url: http://git.megacz.com/?p=ghc-hetmet.git;a=commitdiff_plain;h=79c9408712af3ddd6340b0b5785ffde34f830042 move GetRoots() to GC.c --- diff --git a/includes/Storage.h b/includes/Storage.h index 238b858..af4b9bb 100644 --- a/includes/Storage.h +++ b/includes/Storage.h @@ -186,8 +186,7 @@ extern void freeExec (void *p); 'get_roots' is called to find all the roots that the system knows about. - StgClosure Called by get_roots on each root. - MarkRoot(StgClosure *p) Returns the new location of the root. + -------------------------------------------------------------------------- */ extern void GarbageCollect(rtsBool force_major_gc); @@ -495,6 +494,7 @@ typedef void (*evac_fn)(StgClosure **); extern void threadPaused ( Capability *cap, StgTSO * ); extern StgClosure * isAlive ( StgClosure *p ); extern void markCAFs ( evac_fn evac ); +extern void GetRoots ( evac_fn evac ); /* ----------------------------------------------------------------------------- Stats 'n' DEBUG stuff diff --git a/rts/Schedule.c b/rts/Schedule.c index 1bd68c2..2b7ebcb 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 ddac92b..a4a95f3 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 4aa210c..f686c6d 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