X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Frts%2FWeak.c;h=012acc90f1653c3ba2f6118ccb90d7eb3c2c93b3;hb=cbc7228335a0489362d8f5deadaecacc8731a4ce;hp=a0ae5cbe3c6962df435481c7f97b226ce94eeacd;hpb=0bffc410964e1688ad80d277d53400659e697ab5;p=ghc-hetmet.git diff --git a/ghc/rts/Weak.c b/ghc/rts/Weak.c index a0ae5cb..012acc9 100644 --- a/ghc/rts/Weak.c +++ b/ghc/rts/Weak.c @@ -1,5 +1,4 @@ /* ----------------------------------------------------------------------------- - * $Id: Weak.c,v 1.26 2002/12/11 15:36:54 simonmar Exp $ * * (c) The GHC Team, 1998-1999 * @@ -10,43 +9,18 @@ #include "PosixSource.h" #define COMPILING_RTS_MAIN #include "Rts.h" +#include "RtsUtils.h" #include "SchedAPI.h" #include "RtsFlags.h" #include "Weak.h" #include "Storage.h" +#include "Schedule.h" #include "Prelude.h" #include "RtsAPI.h" StgWeak *weak_ptr_list; /* - * finalizeWeakPointersNow() is called just before the system is shut - * down. It runs the finalizer for each weak pointer still in the - * system. - * - * Careful here - rts_evalIO might cause a garbage collection, which - * might change weak_ptr_list. Must re-load weak_ptr_list each time - * around the loop. - */ - -void -finalizeWeakPointersNow(void) -{ - StgWeak *w; - - while ((w = weak_ptr_list)) { - weak_ptr_list = w->link; - if (w->header.info != &stg_DEAD_WEAK_info) { - w->header.info = &stg_DEAD_WEAK_info; - IF_DEBUG(weak,fprintf(stderr,"Finalising weak pointer at %p -> %p\n", w, w->key)); - if (w->finalizer != &stg_NO_FINALIZER_closure) { - rts_mainEvalIO(w->finalizer,NULL); - } - } - } -} - -/* * scheduleFinalizers() is called on the list of weak pointers found * to be dead after a garbage collection. It overwrites each object * with DEAD_WEAK, and creates a new thread to run the pending finalizers. @@ -96,7 +70,7 @@ scheduleFinalizers(StgWeak *list) // No finalizers to run? if (n == 0) return; - IF_DEBUG(weak,fprintf(stderr,"weak: batching %d finalizers\n", n)); + IF_DEBUG(weak,debugBelch("weak: batching %d finalizers\n", n)); arr = (StgMutArrPtrs *)allocate(sizeofW(StgMutArrPtrs) + n); TICK_ALLOC_PRIM(sizeofW(StgMutArrPtrs), n, 0);