rts/Linker.c: distinct between DATA and CODE labels when importing
[ghc.git] / rts / RetainerProfile.h
1 /* -----------------------------------------------------------------------------
2 *
3 * (c) The GHC Team, 2001
4 * Author: Sungwoo Park
5 *
6 * Retainer profiling interface.
7 *
8 * ---------------------------------------------------------------------------*/
9
10 #ifndef RETAINERPROFILE_H
11 #define RETAINERPROFILE_H
12
13 #ifdef PROFILING
14
15 #include "RetainerSet.h"
16
17 #include "BeginPrivate.h"
18
19 void initRetainerProfiling ( void );
20 void endRetainerProfiling ( void );
21 void retainerProfile ( void );
22 void resetStaticObjectForRetainerProfiling( StgClosure *static_objects );
23
24 // flip is either 1 or 0, changed at the beginning of retainerProfile()
25 // It is used to tell whether a retainer set has been touched so far
26 // during this pass.
27 extern StgWord flip;
28
29 // extract the retainer set field from c
30 #define RSET(c) ((c)->header.prof.hp.rs)
31
32 #define isRetainerSetFieldValid(c) \
33 ((((StgWord)(c)->header.prof.hp.rs & 1) ^ flip) == 0)
34
35 static inline RetainerSet *
36 retainerSetOf( StgClosure *c )
37 {
38 ASSERT( isRetainerSetFieldValid(c) );
39 // StgWord has the same size as pointers, so the following type
40 // casting is okay.
41 return (RetainerSet *)((StgWord)RSET(c) ^ flip);
42 }
43
44 // Used by Storage.c:memInventory()
45 #ifdef DEBUG
46 extern W_ retainerStackBlocks ( void );
47 #endif
48
49 #include "EndPrivate.h"
50
51 #endif /* PROFILING */
52
53 #endif /* RETAINERPROFILE_H */