[project @ 2004-02-12 02:04:59 by mthomas]
[ghc-hetmet.git] / ghc / rts / RetainerProfile.h
1 /* -----------------------------------------------------------------------------
2  * $Id: RetainerProfile.h,v 1.3 2003/03/21 16:18:38 sof Exp $
3  *
4  * (c) The GHC Team, 2001
5  * Author: Sungwoo Park
6  *
7  * Retainer profiling interface.
8  *
9  * ---------------------------------------------------------------------------*/
10
11 #ifndef RETAINERPROFILE_H
12 #define RETAINERPROFILE_H
13
14 #ifdef PROFILING
15
16 #include "RetainerSet.h"
17
18 extern void  initRetainerProfiling ( void );
19 extern void  endRetainerProfiling  ( void );
20 extern void  printRetainer         ( FILE *, retainer );
21 extern void  retainerProfile       ( void );
22 extern void  resetStaticObjectForRetainerProfiling ( void );
23
24 extern StgWord flip;
25
26 // extract the retainer set field from c
27 #define RSET(c)   ((c)->header.prof.hp.rs)
28
29 #define isRetainerSetFieldValid(c) \
30   ((((StgWord)(c)->header.prof.hp.rs & 1) ^ flip) == 0)
31
32 static inline RetainerSet *
33 retainerSetOf( StgClosure *c )
34 {
35     ASSERT( isRetainerSetFieldValid(c) );
36     // StgWord has the same size as pointers, so the following type
37     // casting is okay.
38     return (RetainerSet *)((StgWord)RSET(c) ^ flip);
39 }
40
41 // Used by Storage.c:memInventory()
42 #ifdef DEBUG
43 extern lnat retainerStackBlocks ( void );
44 #endif
45
46 #endif /* PROFILING */
47
48 #endif /* RETAINERPROFILE_H */