- Register Cost Centres
-
- At the moment, this process just supplies a unique integer to each
- statically declared cost centre and cost centre stack in the
- program.
-
- The code generator inserts a small function "reg<moddule>" in each
- module which registers any cost centres from that module and calls
- the registration functions in each of the modules it imports. So,
- if we call "regMain", each reachable module in the program will be
- registered.
-
- The reg* functions are compiled in the same way as STG code,
- i.e. without normal C call/return conventions. Hence we must use
- StgRun to call this stuff.
- -------------------------------------------------------------------------- */
-
-/* The registration functions use an explicit stack...
- */
-#define REGISTER_STACK_SIZE (BLOCK_SIZE * 4)
-F_ *register_stack;
-
-static void
-registerCostCentres ( void )
-{
- /* this storage will be reclaimed by the garbage collector,
- * as a large block.
- */
- register_stack = (F_ *)allocate(REGISTER_STACK_SIZE / sizeof(W_));
-
- StgRun((StgFunPtr)stg_register, &MainRegTable);
-}
-
-
-/* -----------------------------------------------------------------------------
- Set cost centre stack when entering a function. Here we implement
- the rule
-
- "if CCSfn is an initial segment of CCCS,
- then set CCCS to CCSfn,
- else append CCSfn to CCCS"