[project @ 2002-03-25 05:21:19 by sof]
[ghc-hetmet.git] / ghc / rts / Weak.c
index 91a2fc0..5c71710 100644 (file)
@@ -1,5 +1,5 @@
 /* -----------------------------------------------------------------------------
- * $Id: Weak.c,v 1.17 2000/12/04 12:31:22 simonmar Exp $
+ * $Id: Weak.c,v 1.21 2002/02/18 13:26:13 sof Exp $
  *
  * (c) The GHC Team, 1998-1999
  *
@@ -7,6 +7,7 @@
  *
  * ---------------------------------------------------------------------------*/
 
+#include "PosixSource.h"
 #include "Rts.h"
 #include "RtsAPI.h"
 #include "SchedAPI.h"
@@ -55,6 +56,8 @@ finalizeWeakPointersNow(void)
  * The weak pointer object itself may not be alive - i.e. we may be
  * looking at either an object in from-space or one in to-space.  It
  * doesn't really matter either way.
+ *
+ * Pre-condition: sched_mutex _not_ held.
  */
 
 void
@@ -84,7 +87,17 @@ scheduleFinalizers(StgWeak *list)
            arr->payload[n] = w->finalizer;
            n++;
        }
-       w->header.info = &stg_DEAD_WEAK_info;
+
+#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,