summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--includes/rts/prof/CCS.h32
-rw-r--r--includes/stg/MiscClosures.h4
-rw-r--r--rts/Profiling.c86
-rw-r--r--rts/RtsSymbols.c3
4 files changed, 56 insertions, 69 deletions
diff --git a/includes/rts/prof/CCS.h b/includes/rts/prof/CCS.h
index 89c9fd2b13..e385a9b8fc 100644
--- a/includes/rts/prof/CCS.h
+++ b/includes/rts/prof/CCS.h
@@ -166,9 +166,6 @@ extern CostCentreStack CCS_IDLE[]; // capability is idle
#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(era);
/* -----------------------------------------------------------------------------
@@ -179,36 +176,7 @@ CostCentreStack * pushCostCentre (CostCentreStack *, CostCentre *);
void enterFunCCS (StgRegTable *reg, CostCentreStack *);
CostCentre *mkCostCentre (char *label, char *module, char *srcloc);
-/* -----------------------------------------------------------------------------
- Registering CCs and CCSs
-
- Registering a CC or CCS consists of
- - assigning it a unique ID
- - linking it onto the list of registered CCs/CCSs
-
- Cost centres are registered at startup by a C constructor function
- generated by the compiler in the _stub.c file for each module. The
- macros below are invoked by that C code to register CCs and CCSs.
- -------------------------------------------------------------------------- */
-
extern CostCentre * RTS_VAR(CC_LIST); // registered CC list
-extern CostCentreStack * RTS_VAR(CCS_LIST); // registered CCS list
-
-#define REGISTER_CC(cc) \
- do { \
- if ((cc)->link == (CostCentre *)0) { \
- (cc)->link = CC_LIST; \
- CC_LIST = (cc); \
- (cc)->ccID = CC_ID++; \
- }} while(0)
-
-#define REGISTER_CCS(ccs) \
- do { \
- if ((ccs)->prevStack == (CostCentreStack *)0) { \
- (ccs)->prevStack = CCS_LIST; \
- CCS_LIST = (ccs); \
- (ccs)->ccsID = CCS_ID++; \
- }} while(0)
/* -----------------------------------------------------------------------------
* Declaring Cost Centres & Cost Centre Stacks.
diff --git a/includes/stg/MiscClosures.h b/includes/stg/MiscClosures.h
index c13b5ff052..8c4cb9fc8c 100644
--- a/includes/stg/MiscClosures.h
+++ b/includes/stg/MiscClosures.h
@@ -523,12 +523,8 @@ extern StgWord RTS_VAR(stable_name_table);
// Profiling.c
extern unsigned int RTS_VAR(era);
extern unsigned int RTS_VAR(entering_PAP);
-extern StgWord RTS_VAR(CC_LIST); /* registered CC list */
-extern StgWord RTS_VAR(CCS_LIST); /* registered CCS list */
extern StgWord CCS_OVERHEAD[];
extern StgWord CCS_SYSTEM[];
-extern unsigned int RTS_VAR(CC_ID); /* global ids */
-extern unsigned int RTS_VAR(CCS_ID);
// Calls to these rts functions are generated directly
// by codegen (see compiler/codeGen/StgCmmProf.hs)
diff --git a/rts/Profiling.c b/rts/Profiling.c
index 70bf3750e3..3c7f52b6f4 100644
--- a/rts/Profiling.c
+++ b/rts/Profiling.c
@@ -43,8 +43,8 @@ static Arena *prof_arena;
* closure_cats
*/
-unsigned int CC_ID = 1;
-unsigned int CCS_ID = 1;
+static unsigned int CC_ID = 1;
+static unsigned int CCS_ID = 1;
/* Globals for opening the profiling log file(s)
*/
@@ -54,11 +54,11 @@ FILE *prof_file;
static char *hp_filename; /* heap profile (hp2ps style) log file */
FILE *hp_file;
-/* Linked lists to keep track of CCs and CCSs that haven't
- * been declared in the log file yet
- */
+// List of all cost centres. Used for reporting.
CostCentre *CC_LIST = NULL;
-CostCentreStack *CCS_LIST = NULL;
+// All cost centre stacks temporarily appear here, to be able to make CCS_MAIN a
+// parent of all cost centres stacks (done in initProfiling2()).
+static CostCentreStack *CCS_LIST = NULL;
#if defined(THREADED_RTS)
static Mutex ccs_mutex;
@@ -125,6 +125,8 @@ static IndexTable * addToIndexTable ( IndexTable *, CostCentreStack *,
CostCentre *, bool );
static void ccsSetSelected ( CostCentreStack *ccs );
static void aggregateCCCosts( CostCentreStack *ccs );
+static void registerCC ( CostCentre *cc );
+static void registerCCS ( CostCentreStack *ccs );
static void initTimeProfiling ( void );
static void initProfilingLogFile ( void );
@@ -158,21 +160,21 @@ void initProfiling (void)
/* Register all the cost centres / stacks in the program
* CC_MAIN gets link = 0, all others have non-zero link.
*/
- REGISTER_CC(CC_MAIN);
- REGISTER_CC(CC_SYSTEM);
- REGISTER_CC(CC_GC);
- REGISTER_CC(CC_OVERHEAD);
- REGISTER_CC(CC_DONT_CARE);
- REGISTER_CC(CC_PINNED);
- REGISTER_CC(CC_IDLE);
-
- REGISTER_CCS(CCS_SYSTEM);
- REGISTER_CCS(CCS_GC);
- REGISTER_CCS(CCS_OVERHEAD);
- REGISTER_CCS(CCS_DONT_CARE);
- REGISTER_CCS(CCS_PINNED);
- REGISTER_CCS(CCS_IDLE);
- REGISTER_CCS(CCS_MAIN);
+ registerCC(CC_MAIN);
+ registerCC(CC_SYSTEM);
+ registerCC(CC_GC);
+ registerCC(CC_OVERHEAD);
+ registerCC(CC_DONT_CARE);
+ registerCC(CC_PINNED);
+ registerCC(CC_IDLE);
+
+ registerCCS(CCS_SYSTEM);
+ registerCCS(CCS_GC);
+ registerCCS(CCS_OVERHEAD);
+ registerCCS(CCS_DONT_CARE);
+ registerCCS(CCS_PINNED);
+ registerCCS(CCS_IDLE);
+ registerCCS(CCS_MAIN);
/* find all the registered cost centre stacks, and make them
* children of CCS_MAIN.
@@ -199,10 +201,9 @@ void initProfiling (void)
//
void initProfiling2 (void)
{
- CostCentreStack *ccs, *next;
-
// make CCS_MAIN the parent of all the pre-defined CCSs.
- for (ccs = CCS_LIST; ccs != NULL; ) {
+ CostCentreStack *next;
+ for (CostCentreStack *ccs = CCS_LIST; ccs != NULL; ) {
next = ccs->prevStack;
ccs->prevStack = NULL;
actualPush_(CCS_MAIN,ccs->cc,ccs);
@@ -312,22 +313,47 @@ endProfiling ( void )
}
}
+/* -----------------------------------------------------------------------------
+ Registering CCs and CCSs
+
+ Registering a CC or CCS consists of
+ - assigning it a unique ID
+ - linking it onto the list of registered CCs/CCSs
+
+ Cost centres are registered at startup by a C constructor function
+ generated by the compiler (ProfInit.hs) in the _stub.c file for each module.
+ -------------------------------------------------------------------------- */
+
+static void
+registerCC(CostCentre *cc)
+{
+ if (cc->link == NULL) {
+ cc->link = CC_LIST;
+ CC_LIST = cc;
+ cc->ccID = CC_ID++;
+ }
+}
+
+static void registerCCS(CostCentreStack *ccs)
+{
+ if (ccs->prevStack == NULL) {
+ ccs->prevStack = CCS_LIST;
+ CCS_LIST = ccs;
+ ccs->ccsID = CCS_ID++;
+ }
+}
-/*
- These are used in the C stubs produced by the code generator
- to register code.
- */
void registerCcList(CostCentre **cc_list)
{
for (CostCentre **i = cc_list; *i != NULL; i++) {
- REGISTER_CC(*i);
+ registerCC(*i);
}
}
void registerCcsList(CostCentreStack **cc_list)
{
for (CostCentreStack **i = cc_list; *i != NULL; i++) {
- REGISTER_CCS(*i);
+ registerCCS(*i);
}
}
diff --git a/rts/RtsSymbols.c b/rts/RtsSymbols.c
index 404756e8cd..6966d6deb9 100644
--- a/rts/RtsSymbols.c
+++ b/rts/RtsSymbols.c
@@ -493,9 +493,6 @@
#define RTS_PROF_SYMBOLS \
SymI_HasProto(CCS_DONT_CARE) \
SymI_HasProto(CC_LIST) \
- SymI_HasProto(CC_ID) \
- SymI_HasProto(CCS_LIST) \
- SymI_HasProto(CCS_ID) \
SymI_HasProto(stg_restore_cccs_info) \
SymI_HasProto(enterFunCCS) \
SymI_HasProto(pushCostCentre) \