From 557bca7326077b67324b87e4042be83638ff6581 Mon Sep 17 00:00:00 2001 From: sof Date: Fri, 21 Mar 2003 16:18:39 +0000 Subject: [PATCH] [project @ 2003-03-21 16:18:37 by sof] Friday morning code-wibbling: - made RetainerProfile.c:firstStack a 'static' - added RetainerProfile.c:retainerStackBlocks() --- ghc/rts/RetainerProfile.c | 19 +++++++++++++++++-- ghc/rts/RetainerProfile.h | 6 +++--- ghc/rts/Storage.c | 5 ++--- ghc/rts/Storage.h | 4 ++-- 4 files changed, 24 insertions(+), 10 deletions(-) diff --git a/ghc/rts/RetainerProfile.c b/ghc/rts/RetainerProfile.c index 916ce90..9ab12f1 100644 --- a/ghc/rts/RetainerProfile.c +++ b/ghc/rts/RetainerProfile.c @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: RetainerProfile.c,v 1.7 2003/02/22 04:51:52 sof Exp $ + * $Id: RetainerProfile.c,v 1.8 2003/03/21 16:18:37 sof Exp $ * * (c) The GHC Team, 2001 * Author: Sungwoo Park @@ -158,7 +158,7 @@ typedef struct { the topmost element on the previous block group so as to satisfy the invariants described above. */ -bdescr *firstStack = NULL; +static bdescr *firstStack = NULL; static bdescr *currentStack; static stackElement *stackBottom, *stackTop, *stackLimit; @@ -258,6 +258,21 @@ isEmptyRetainerStack( void ) } /* ----------------------------------------------------------------------------- + * Returns size of stack + * -------------------------------------------------------------------------- */ +lnat +retainerStackBlocks() +{ + bdescr* bd; + lnat res = 0; + + for (bd = firstStack; bd != NULL; bd = bd->link) + res += bd->blocks; + + return res; +} + +/* ----------------------------------------------------------------------------- * Returns rtsTrue if stackTop is at the stack boundary of the current stack, * i.e., if the current stack chunk is empty. * -------------------------------------------------------------------------- */ diff --git a/ghc/rts/RetainerProfile.h b/ghc/rts/RetainerProfile.h index 51ddc64..09dcb1c 100644 --- a/ghc/rts/RetainerProfile.h +++ b/ghc/rts/RetainerProfile.h @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: RetainerProfile.h,v 1.2 2001/11/26 16:54:21 simonmar Exp $ + * $Id: RetainerProfile.h,v 1.3 2003/03/21 16:18:38 sof Exp $ * * (c) The GHC Team, 2001 * Author: Sungwoo Park @@ -38,9 +38,9 @@ retainerSetOf( StgClosure *c ) return (RetainerSet *)((StgWord)RSET(c) ^ flip); } -// firstStack is exported because memInventory() in Schedule.c uses it. +// Used by Storage.c:memInventory() #ifdef DEBUG -extern bdescr *firstStack; +extern lnat retainerStackBlocks ( void ); #endif #endif /* PROFILING */ diff --git a/ghc/rts/Storage.c b/ghc/rts/Storage.c index f92e653..4e7cdb6 100644 --- a/ghc/rts/Storage.c +++ b/ghc/rts/Storage.c @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: Storage.c,v 1.76 2003/02/01 09:10:17 mthomas Exp $ + * $Id: Storage.c,v 1.77 2003/03/21 16:18:38 sof Exp $ * * (c) The GHC Team, 1998-1999 * @@ -832,8 +832,7 @@ memInventory(void) #ifdef PROFILING if (RtsFlags.ProfFlags.doHeapProfile == HEAP_BY_RETAINER) { - for (bd = firstStack; bd != NULL; bd = bd->link) - total_blocks += bd->blocks; + total_blocks += retainerStackBlocks(); } #endif diff --git a/ghc/rts/Storage.h b/ghc/rts/Storage.h index 70e7c2a..838248d 100644 --- a/ghc/rts/Storage.h +++ b/ghc/rts/Storage.h @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: Storage.h,v 1.47 2002/12/13 14:43:06 simonmar Exp $ + * $Id: Storage.h,v 1.48 2003/03/21 16:18:39 sof Exp $ * * (c) The GHC Team, 1998-2002 * @@ -53,7 +53,7 @@ extern void exitStorage(void); lnat allocated_bytes(void) Returns the number of bytes allocated via allocate() since the last GC. - Used in the reoprting of statistics. + Used in the reporting of statistics. SMP: allocate and doYouWantToGC can be used from STG code, they are surrounded by a mutex. -- 1.7.10.4