X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fincludes%2FStgProf.h;h=9b3ce69a9f7d365b8b4e5f7d1e347b33695bf57a;hb=28a464a75e14cece5db40f2765a29348273ff2d2;hp=7e7be34760a640e88ed1e2e199f161e5190d1af9;hpb=d2206e762739e9999cc3bbd1addb82fd268140c5;p=ghc-hetmet.git diff --git a/ghc/includes/StgProf.h b/ghc/includes/StgProf.h index 7e7be34..9b3ce69 100644 --- a/ghc/includes/StgProf.h +++ b/ghc/includes/StgProf.h @@ -1,9 +1,9 @@ /* ----------------------------------------------------------------------------- - * $Id: StgProf.h,v 1.12 2001/10/18 13:19:49 simonmar Exp $ * - * (c) The GHC Team, 1998 + * (c) The GHC Team, 2004 * * Macros for profiling operations in STG code + * * ---------------------------------------------------------------------------*/ #ifndef STGPROF_H @@ -12,37 +12,42 @@ /* ----------------------------------------------------------------------------- * Data Structures * ---------------------------------------------------------------------------*/ +/* + * NB. be careful to avoid unwanted padding between fields, by + * putting the 8-byte fields on an 8-byte boundary. Padding can + * vary between C compilers, and we don't take into account any + * possible padding when generating CCS and CC decls in the code + * generator (compiler/codeGen/CgProf.hs). + */ + typedef struct _CostCentre { - int ccID; + StgInt ccID; - char *label; - char *module; + char * label; + char * module; /* used for accumulating costs at the end of the run... */ - unsigned long time_ticks; - unsigned long mem_alloc; + StgWord time_ticks; + StgWord64 mem_alloc; /* align 8 (see above) */ - char is_caf; + StgInt is_caf; struct _CostCentre *link; } CostCentre; - typedef struct _CostCentreStack { - int ccsID; + StgInt ccsID; CostCentre *cc; struct _CostCentreStack *prevStack; struct _IndexTable *indexTable; - - unsigned long scc_count; - - unsigned long time_ticks; - unsigned long mem_alloc; - unsigned long mem_resid; - unsigned long inherited_ticks; - unsigned long inherited_alloc; + StgWord64 scc_count; /* align 8 (see above) */ + StgWord selected; + StgWord time_ticks; + StgWord64 mem_alloc; /* align 8 (see above) */ + StgWord64 inherited_alloc; /* align 8 (see above) */ + StgWord inherited_ticks; CostCentre *root; } CostCentreStack; @@ -83,8 +88,30 @@ typedef struct _IndexTable { Pre-defined cost centres and cost centre stacks -------------------------------------------------------------------------- */ -extern CostCentreStack *CCCS; /* current CCS */ +extern CostCentreStack * RTS_VAR(CCCS); /* current CCS */ +#if IN_STG_CODE + +extern StgWord CC_MAIN[]; +extern StgWord CCS_MAIN[]; /* Top CCS */ + +extern StgWord CC_SYSTEM[]; +extern StgWord CCS_SYSTEM[]; /* RTS costs */ + +extern StgWord CC_GC[]; +extern StgWord CCS_GC[]; /* Garbage collector costs */ + +extern StgWord CC_SUBSUMED[]; +extern StgWord CCS_SUBSUMED[]; /* Costs are subsumed by caller */ + +extern StgWord CC_OVERHEAD[]; +extern StgWord CCS_OVERHEAD[]; /* Profiling overhead */ + +extern StgWord CC_DONT_CARE[]; +extern StgWord CCS_DONT_CARE[]; /* shouldn't ever get set */ + +#else + extern CostCentre CC_MAIN[]; extern CostCentreStack CCS_MAIN[]; /* Top CCS */ @@ -103,19 +130,23 @@ extern CostCentreStack CCS_OVERHEAD[]; /* Profiling overhead */ extern CostCentre CC_DONT_CARE[]; extern CostCentreStack CCS_DONT_CARE[]; /* shouldn't ever get set */ -extern unsigned int CC_ID; /* global ids */ -extern unsigned int CCS_ID; -extern unsigned int HP_ID; +#endif /* IN_STG_CODE */ + +extern unsigned int RTS_VAR(CC_ID); /* global ids */ +extern unsigned int RTS_VAR(CCS_ID); +extern unsigned int RTS_VAR(HP_ID); + +extern unsigned int RTS_VAR(era); /* ----------------------------------------------------------------------------- * Functions * ---------------------------------------------------------------------------*/ -CostCentreStack *EnterFunCCS ( CostCentreStack *cccs, CostCentreStack *ccsfn ); +void EnterFunCCS ( CostCentreStack *ccsfn ); CostCentreStack *PushCostCentre ( CostCentreStack *, CostCentre * ); CostCentreStack *AppendCCS ( CostCentreStack *ccs1, CostCentreStack *ccs2 ); -extern unsigned int entering_PAP; +extern unsigned int RTS_VAR(entering_PAP); /* ----------------------------------------------------------------------------- * Registering CCs @@ -140,8 +171,8 @@ extern unsigned int entering_PAP; -------------------------------------------------------------------------- */ -extern CostCentre *CC_LIST; /* registered CC list */ -extern CostCentreStack *CCS_LIST; /* registered CCS list */ +extern CostCentre * RTS_VAR(CC_LIST); /* registered CC list */ +extern CostCentreStack * RTS_VAR(CCS_LIST); /* registered CCS list */ #define REGISTER_CC(cc) \ do { \ @@ -181,186 +212,27 @@ extern CostCentreStack *CCS_LIST; /* registered CCS list */ cc : cc_ident, \ prevStack : NULL, \ indexTable : NULL, \ + selected : 0, \ scc_count : 0, \ time_ticks : 0, \ mem_alloc : 0, \ - mem_resid : 0, \ inherited_ticks : 0, \ inherited_alloc : 0, \ root : 0, \ }}; -# define CC_EXTERN(cc_ident) \ - extern CostCentre cc_ident[]; - /* ----------------------------------------------------------------------------- * Time / Allocation Macros * ---------------------------------------------------------------------------*/ -#define CCS_TICK(ccs) (ccs)->time_ticks++ - /* eliminate profiling overhead from allocation costs */ #define CCS_ALLOC(ccs, size) (ccs)->mem_alloc += ((size)-sizeofW(StgProfHeader)) -/* For grabbing the cost centre from a closure */ -#define CCS_HDR(closure) ((StgClosure *)(closure))->header.prof.ccs - -/* Restore the CCCS from a stack frame. - * (addr should always be Sp->header.prof.ccs) - */ -#define RESTORE_CCCS(addr) (CCCS = (CostCentreStack *)(addr)) - -/* ----------------------------------------------------------------------------- - * Pushing a new cost centre (i.e. for scc annotations) - * -------------------------------------------------------------------------- */ - -# define SET_CCC_X(cc,do_subcc_count,do_scc_count) \ - do { \ - CCCS = PushCostCentre(CCCS,cc); \ - if (do_scc_count) { CCCS->scc_count++; } \ - } while(0) - -/* We sometimes don't increment the scc_count field, for example when - * this scc has been placed by the compiler on an expression it - * floated outside the main scc annotation. - */ - -# define SET_CCC(cc_ident,do_scc_count) \ - SET_CCC_X(cc_ident,do_scc_count,do_scc_count) - -# define SET_CCS_TOP(cc_ident) \ - SET_CCC_X(cc_ident,0,1) - -/* ----------------------------------------------------------------------------- - * Allocating new cost centres / cost centre stacks. - * -------------------------------------------------------------------------- */ - -#define ASSIGN_CC_ID(ccID) \ - do { \ - ccID = CC_ID; \ - CC_ID++; \ - } while(0) - -#define ASSIGN_CCS_ID(ccsID) \ - do { \ - ccsID = CCS_ID; \ - CCS_ID++; \ - } while(0) - -#define ASSIGN_HP_ID(hpID) \ - do { \ - hpID = HP_ID; \ - HP_ID++; \ - } while(0) - -#define SET_STATS_TO_ZERO(stack) \ - do { \ - (stack)->scc_count = 0; \ - (stack)->time_ticks = 0; \ - (stack)->mem_alloc = 0; \ - } while(0) - -/* ----------------------------------------------------------------------------- - * Setting the cost centre when we enter a closure - * -------------------------------------------------------------------------- */ - -#if defined(PROFILING_DETAIL_COUNTS) -#define CCCS_DETAIL_COUNT(inc_this) ((inc_this)++) -#else -#define CCCS_DETAIL_COUNT(inc_this) /*nothing*/ -#endif - -/* On entry to top level CAFs we count the scc ...*/ - -#define ENTER_CCS_CAF_X(ccs) \ - do { \ - /* set CCCS to ident ccs */ \ - CCCS = (CostCentreStack *)(ccs); \ - /* inc scc count of CAF ccs */ \ - CCCS->scc_count++; \ - } while(0) - -#define ENTER_CCS_CAF(ccs_ident) ENTER_CCS_CAF_X(ccs_ident) -#define ENTER_CCS_CAF_CL(closure) ENTER_CCS_CAF_X(CCS_HDR(closure)) - -/* ---------------------------------------------------------------------------- - * Entering a Thunk - * - * On entering a closure we only count the enter to thunks ... - * ------------------------------------------------------------------------- */ - -#define ENTER_CCS_T(ccs) \ - do { \ - CCCS = (CostCentreStack *)(ccs); \ - CCCS_DETAIL_COUNT(CCCS->thunk_count); \ - } while(0) - -#define ENTER_CCS_TCL(closure) ENTER_CCS_T(CCS_HDR(closure)) - -/* ----------------------------------------------------------------------------- - * Entering a function - * - * Here is our special "hybrid" case when we do *not* set the CCCS. - * (a) The closure is a function, not a thunk; - * (b) The CCS is CAF-ish. - * -------------------------------------------------------------------------- */ - -#define ENTER_CCS_F(stack) \ - do { \ - CostCentreStack *ccs = (CostCentreStack *) (stack); \ - CCCS_DETAIL_COUNT(CCCS->function_count); \ - CCCS = EnterFunCCS(CCCS,ccs); \ - } while(0) - -#define ENTER_CCS_FCL(closure) ENTER_CCS_F(CCS_HDR(closure)) - -/* Entering a top-level function: costs are subsumed by the caller - */ -#define ENTER_CCS_FSUB() \ - do { \ - CCCS_DETAIL_COUNT(CCCS->subsumed_fun_count); \ - CCCS_DETAIL_COUNT(CCCS->function_count); \ - entering_PAP = 0; \ - } while(0) - -#define ENTER_CCS_FCAF(stack) \ - do { \ - CostCentreStack *ccs = (CostCentreStack *) (stack); \ - CCCS_DETAIL_COUNT(ccs->caffun_subsumed); \ - CCCS_DETAIL_COUNT(CCCS->subsumed_caf_count); \ - CCCS_DETAIL_COUNT(CCCS->function_count); \ - entering_PAP = 0; \ - } while(0) - -#define ENTER_CCS_FLOAD(ccs) \ - do { \ - CCCS = (CostCentreStack *)(ccs); \ - CCCS_DETAIL_COUNT(CCCS->function_count); \ - } while(0) - -/* These ENTER_CC_PAP things are only used in the RTS */ - -#define ENTER_CCS_PAP(stack) \ - do { \ - ENTER_CCS_F(stack); \ - entering_PAP = rtsTrue; \ - } while(0) - -#define ENTER_CCS_PAP_CL(closure) \ - ENTER_CCS_PAP((closure)->header.prof.ccs) - - /* temp EW */ -#define STATIC_CCS_REF(ccs) (ccs) - -/* ----------------------------------------------------------------------------- - When not profiling, these macros do nothing... - -------------------------------------------------------------------------- */ #else /* !PROFILING */ #define CCS_ALLOC(ccs, amount) doNothing() -#define ENTER_CC_PAP_CL(r) doNothing() -#define ENTER_CCS_PAP_CL(r) doNothing() #endif /* PROFILING */ #endif /* STGPROF_H */ +