X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fincludes%2FStgProf.h;h=f6af87f655c973393985f87e2d4844144c4afb3d;hb=3087014ae03067cf0f9c9e0d8d49fb885e2cd0a8;hp=0f71fec47c2d5989f831764fc4f3124f57493d35;hpb=17315bf6c11c17ad38ca5a65d7e938ac32d07d8a;p=ghc-hetmet.git diff --git a/ghc/includes/StgProf.h b/ghc/includes/StgProf.h index 0f71fec..f6af87f 100644 --- a/ghc/includes/StgProf.h +++ b/ghc/includes/StgProf.h @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: StgProf.h,v 1.7 1999/09/15 13:45:14 simonmar Exp $ + * $Id: StgProf.h,v 1.16 2001/12/12 14:59:41 simonmar Exp $ * * (c) The GHC Team, 1998 * @@ -9,9 +9,116 @@ #ifndef STGPROF_H #define STGPROF_H +/* ----------------------------------------------------------------------------- + * Data Structures + * ---------------------------------------------------------------------------*/ +typedef struct _CostCentre { + int ccID; + + char *label; + char *module; + + /* used for accumulating costs at the end of the run... */ + unsigned long time_ticks; + unsigned long long mem_alloc; + + char is_caf; + + struct _CostCentre *link; +} CostCentre; + + +typedef struct _CostCentreStack { + int ccsID; + + CostCentre *cc; + struct _CostCentreStack *prevStack; + struct _IndexTable *indexTable; + + unsigned int selected; + + unsigned long long scc_count; + + unsigned long time_ticks; + unsigned long long mem_alloc; + + unsigned long inherited_ticks; + unsigned long long inherited_alloc; + + CostCentre *root; +} CostCentreStack; + + +/* ----------------------------------------------------------------------------- + * The rest is PROFILING only... + * ---------------------------------------------------------------------------*/ + #if defined(PROFILING) /* ----------------------------------------------------------------------------- + * Constants + * ---------------------------------------------------------------------------*/ + +#define EMPTY_STACK NULL +#define EMPTY_TABLE NULL + +/* Constants used to set sumbsumed flag on CostCentres */ + +#define CC_IS_CAF 'c' /* 'c' => *is* a CAF cc */ +#define CC_IS_BORING 'B' /* 'B' => *not* a CAF/sub cc */ + + +/* ----------------------------------------------------------------------------- + * Data Structures + * ---------------------------------------------------------------------------*/ + +typedef struct _IndexTable { + CostCentre *cc; + CostCentreStack *ccs; + struct _IndexTable *next; + unsigned int back_edge; +} IndexTable; + + +/* ----------------------------------------------------------------------------- + Pre-defined cost centres and cost centre stacks + -------------------------------------------------------------------------- */ + +extern CostCentreStack *CCCS; /* current CCS */ + +extern CostCentre CC_MAIN[]; +extern CostCentreStack CCS_MAIN[]; /* Top CCS */ + +extern CostCentre CC_SYSTEM[]; +extern CostCentreStack CCS_SYSTEM[]; /* RTS costs */ + +extern CostCentre CC_GC[]; +extern CostCentreStack CCS_GC[]; /* Garbage collector costs */ + +extern CostCentre CC_SUBSUMED[]; +extern CostCentreStack CCS_SUBSUMED[]; /* Costs are subsumed by caller */ + +extern CostCentre CC_OVERHEAD[]; +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; + +/* ----------------------------------------------------------------------------- + * Functions + * ---------------------------------------------------------------------------*/ + +CostCentreStack *EnterFunCCS ( CostCentreStack *cccs, CostCentreStack *ccsfn ); +CostCentreStack *PushCostCentre ( CostCentreStack *, CostCentre * ); +CostCentreStack *AppendCCS ( CostCentreStack *ccs1, CostCentreStack *ccs2 ); + +extern unsigned int entering_PAP; + +/* ----------------------------------------------------------------------------- * Registering CCs Cost centres are registered at startup by calling a registering @@ -34,34 +141,9 @@ -------------------------------------------------------------------------- */ -extern F_ *register_stack; - extern CostCentre *CC_LIST; /* registered CC list */ extern CostCentreStack *CCS_LIST; /* registered CCS list */ -# define PUSH_REGISTER_STACK(reg_function) \ - *(register_stack++) = (F_)reg_function - -# define POP_REGISTER_STACK() \ - *(--register_stack) - -# define START_REGISTER_CCS(reg_mod_name) \ - static int _module_registered = 0; \ - FN_(reg_mod_name) { \ - FB_; \ - if (! _module_registered) { \ - _module_registered = 1 - -# define REGISTER_IMPORT(reg_mod_name) \ - do { EF_(reg_mod_name); \ - PUSH_REGISTER_STACK(reg_mod_name) ; \ - } while (0) - -# define END_REGISTER_CCS() \ - }; \ - JMP_(POP_REGISTER_STACK()); \ - FE_ } - #define REGISTER_CC(cc) \ do { \ extern CostCentre cc[]; \ @@ -84,29 +166,28 @@ extern CostCentreStack *CCS_LIST; /* registered CCS list */ * Declaring Cost Centres & Cost Centre Stacks. * -------------------------------------------------------------------------- */ -# define CC_DECLARE(cc_ident,name,module,group,subsumed,is_local) \ - is_local CostCentre cc_ident[1] \ - = {{ 0, \ - name, \ - module, \ - group, \ - 0, \ - 0, \ - subsumed, \ +# define CC_DECLARE(cc_ident,name,module,caf,is_local) \ + is_local CostCentre cc_ident[1] \ + = {{ 0, \ + name, \ + module, \ + 0, \ + 0, \ + caf, \ 0 }}; -# define CCS_DECLARE(ccs_ident,cc_ident,subsumed,is_local) \ +# define CCS_DECLARE(ccs_ident,cc_ident,is_local) \ is_local CostCentreStack ccs_ident[1] \ = {{ ccsID : 0, \ cc : cc_ident, \ prevStack : NULL, \ indexTable : NULL, \ + selected : 0, \ scc_count : 0, \ - sub_scc_count : 0, \ - sub_cafcc_count : 0, \ time_ticks : 0, \ mem_alloc : 0, \ - mem_resid : 0, \ + inherited_ticks : 0, \ + inherited_alloc : 0, \ root : 0, \ }}; @@ -117,8 +198,6 @@ extern CostCentreStack *CCS_LIST; /* registered CCS list */ * 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)) @@ -136,7 +215,6 @@ extern CostCentreStack *CCS_LIST; /* registered CCS list */ # define SET_CCC_X(cc,do_subcc_count,do_scc_count) \ do { \ - if (do_subcc_count) { CCCS->sub_scc_count++; } \ CCCS = PushCostCentre(CCCS,cc); \ if (do_scc_count) { CCCS->scc_count++; } \ } while(0) @@ -178,7 +256,6 @@ extern CostCentreStack *CCS_LIST; /* registered CCS list */ do { \ (stack)->scc_count = 0; \ (stack)->time_ticks = 0; \ - (stack)->sub_cafcc_count = 0; \ (stack)->mem_alloc = 0; \ } while(0) @@ -192,17 +269,10 @@ extern CostCentreStack *CCS_LIST; /* registered CCS list */ #define CCCS_DETAIL_COUNT(inc_this) /*nothing*/ #endif -#define IS_CAF_OR_SUB_CCS(ccs) \ - /* tests for lower case character */ \ - ((ccs)->is_subsumed & ' ') - - /* On entry to top level CAFs we count the scc ...*/ #define ENTER_CCS_CAF_X(ccs) \ do { \ - /* inc subcaf count of CCCS */ \ - CCCS->sub_cafcc_count++; \ /* set CCCS to ident ccs */ \ CCCS = (CostCentreStack *)(ccs); \ /* inc scc count of CAF ccs */ \ @@ -278,9 +348,15 @@ extern CostCentreStack *CCS_LIST; /* registered CCS list */ #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 */