summaryrefslogtreecommitdiff
path: root/ghc/rts/Weak.c
diff options
context:
space:
mode:
authorsimonmar <unknown>2001-11-22 14:25:13 +0000
committersimonmar <unknown>2001-11-22 14:25:13 +0000
commitdb61851c5472bf565cd1da900b33d6e033fd743d (patch)
tree661b08f223da69c594927b950e3a3cfe6575e581 /ghc/rts/Weak.c
parenta88cde3915095d33b283cbbf7fd83cd08558d609 (diff)
downloadhaskell-db61851c5472bf565cd1da900b33d6e033fd743d.tar.gz
[project @ 2001-11-22 14:25:11 by simonmar]
Retainer Profiling / Lag-drag-void profiling. This is mostly work by Sungwoo Park, who spent a summer internship at MSR Cambridge this year implementing these two types of heap profiling in GHC. Relative to Sungwoo's original work, I've made some improvements to the code: - it's now possible to apply constraints to retainer and LDV profiles in the same way as we do for other types of heap profile (eg. +RTS -hc{foo,bar} -hR -RTS gives you a retainer profiling considering only closures with cost centres 'foo' and 'bar'). - the heap-profile timer implementation is cleaned up. - heap profiling no longer has to be run in a two-space heap. - general cleanup of the code and application of the SDM C coding style guidelines. Profiling will be a little slower and require more space than before, mainly because closures have an extra header word to support either retainer profiling or LDV profiling (you can't do both at the same time). We've used the new profiling tools on GHC itself, with moderate success. Fixes for some space leaks in GHC to follow...
Diffstat (limited to 'ghc/rts/Weak.c')
-rw-r--r--ghc/rts/Weak.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/ghc/rts/Weak.c b/ghc/rts/Weak.c
index 1c03e69cdc..c80cf8c3c1 100644
--- a/ghc/rts/Weak.c
+++ b/ghc/rts/Weak.c
@@ -1,5 +1,5 @@
/* -----------------------------------------------------------------------------
- * $Id: Weak.c,v 1.18 2001/08/14 13:40:09 sewardj Exp $
+ * $Id: Weak.c,v 1.19 2001/11/22 14:25:13 simonmar Exp $
*
* (c) The GHC Team, 1998-1999
*
@@ -36,6 +36,15 @@ finalizeWeakPointersNow(void)
while ((w = weak_ptr_list)) {
weak_ptr_list = w->link;
if (w->header.info != &stg_DEAD_WEAK_info) {
+ // @LDV profiling
+ // Even thought the info type of w changes, we DO NOT perform any
+ // LDV profiling because at this moment, LDV profiling must already
+ // have been terminated. See the comments in shutdownHaskell().
+ // At any rate, there is no need to call LDV_recordDead() because
+ // weak pointers are inherently used.
+#ifdef PROFILING
+ ASSERT(ldvTime == 0); // LDV profiling is turned off.
+#endif
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) {
@@ -85,7 +94,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,