From 28f4b2ae6a3bc32d048e73e6f49f9afdefaad780 Mon Sep 17 00:00:00 2001 From: simonmar Date: Thu, 13 Jun 2002 11:41:15 +0000 Subject: [PATCH] [project @ 2002-06-13 11:41:15 by simonmar] Fix a logic bug which caused some dead weak pointers to not get stubbed out with DEAD_WEAK. --- ghc/rts/Weak.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/ghc/rts/Weak.c b/ghc/rts/Weak.c index fabe792..f161b69 100644 --- a/ghc/rts/Weak.c +++ b/ghc/rts/Weak.c @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: Weak.c,v 1.23 2002/04/26 22:31:31 sof Exp $ + * $Id: Weak.c,v 1.24 2002/06/13 11:41:15 simonmar Exp $ * * (c) The GHC Team, 1998-1999 * @@ -69,11 +69,23 @@ scheduleFinalizers(StgWeak *list) StgMutArrPtrs *arr; nat n; - /* count number of finalizers first... */ + // count number of finalizers, and kill all the weak pointers first... for (n = 0, w = list; w; w = w->link) { if (w->header.info != &stg_DEAD_WEAK_info && - w->finalizer != &stg_NO_FINALIZER_closure) + w->finalizer != &stg_NO_FINALIZER_closure) { n++; + } + +#ifdef PROFILING + // A weak pointer is inherently used, so we do not need to call + // LDV_recordDead(). + // + // Furthermore, when PROFILING is turned on, dead weak + // pointers are exactly as large as weak pointers, so there is + // no need to fill the slop, either. See stg_DEAD_WEAK_info + // in StgMiscClosures.hc. +#endif + SET_HDR(w, &stg_DEAD_WEAK_info, w->header.prof.ccs); } if (n == 0) return; @@ -90,17 +102,6 @@ scheduleFinalizers(StgWeak *list) arr->payload[n] = w->finalizer; n++; } - -#ifdef PROFILING - // A weak pointer is inherently used, so we do not need to call - // LDV_recordDead(). - // - // Furthermore, when PROFILING is turned on, dead weak - // pointers are exactly as large as weak pointers, so there is - // no need to fill the slop, either. See stg_DEAD_WEAK_info - // in StgMiscClosures.hc. -#endif - SET_HDR(w, &stg_DEAD_WEAK_info, w->header.prof.ccs); } t = createIOThread(RtsFlags.GcFlags.initialStkSize, -- 1.7.10.4