1 /* -----------------------------------------------------------------------------
2 * $Id: StgLdvProf.h,v 1.2 2001/11/26 16:54:22 simonmar Exp $
4 * (c) The GHC Team, 2001
7 * Lag/Drag/Void profiling.
9 * ---------------------------------------------------------------------------*/
15 An LDV word is divided into 3 parts: state bits (LDV_STATE_MASK), creation
16 time bits (LDV_CREATE_MASK), and last use time bits (LDV_LAST_MASK).
18 #if SIZEOF_VOID_P == 8
20 #define LDV_STATE_MASK 0x1000000000000000
21 #define LDV_CREATE_MASK 0x0FFFFFFFC0000000
22 #define LDV_LAST_MASK 0x000000003FFFFFFF
23 #define LDV_STATE_CREATE 0x0000000000000000
24 #define LDV_STATE_USE 0x1000000000000000
27 #define LDV_STATE_MASK 0x40000000
28 #define LDV_CREATE_MASK 0x3FFF8000
29 #define LDV_LAST_MASK 0x00007FFF
30 #define LDV_STATE_CREATE 0x00000000
31 #define LDV_STATE_USE 0x40000000
32 #endif // SIZEOF_VOID_P
38 // retrieves the LDV word from closure c
39 #define LDVW(c) (((StgClosure *)(c))->header.prof.hp.ldvw)
41 // Stores the creation time for closure c.
42 // This macro is called at the very moment of closure creation.
44 // NOTE: this initializes LDVW(c) to zero, which ensures that there
45 // is no conflict between retainer profiling and LDV profiling,
46 // because retainer profiling also expects LDVW(c) to be initialised
48 #define LDV_recordCreate(c) \
49 LDVW((c)) = (era << LDV_SHIFT) | LDV_STATE_CREATE
51 // Stores the last use time for closure c.
52 // This macro *must* be called whenever a closure is used, that is, it is
54 #define LDV_recordUse(c) \
57 LDVW((c)) = (LDVW((c)) & LDV_CREATE_MASK) | \
62 // Macros called when a closure is entered.
63 // The closure is not an 'inherently used' one.
64 // The closure is not IND or IND_OLDGEN because neither is considered for LDV
66 #define LDV_ENTER(c) LDV_recordUse((c))
73 #endif // STGLDVPROF_H