Fix ticky build
[ghc-hetmet.git] / rts / Ticky.c
1 /* -----------------------------------------------------------------------------
2  *
3  * (c) The AQUA project, Glasgow University, 1992-1997
4  * (c) The GHC Team, 1998-1999
5  *
6  * Ticky-ticky profiling
7  *-------------------------------------------------------------------------- */
8
9 #if defined(TICKY_TICKY)
10
11 #define TICKY_C                 /* define those variables */
12 #include "PosixSource.h"
13 #include "Rts.h"
14
15 #include "Ticky.h"
16
17 /* -----------------------------------------------------------------------------
18    Print out all the counters
19    -------------------------------------------------------------------------- */
20
21 static void printRegisteredCounterInfo (FILE *); /* fwd decl */
22
23 #define INTAVG(a,b) ((b == 0) ? 0.0 : ((double) (a) / (double) (b)))
24 #define PC(a)       (100.0 * a)
25
26 #define AVG(thing) \
27         StgDouble avg##thing  = INTAVG(tot##thing,ctr##thing)
28
29 void
30 PrintTickyInfo(void)
31 {
32   // XXX This is only used in commented out or #if FALSE'd out code currently:
33   // unsigned long i;
34
35 /* XXX These are used only in an #if FALSE block below */
36 #if FALSE
37   unsigned long tot_allocs = /* total number of things allocated */
38         ALLOC_FUN_ctr + ALLOC_SE_THK_ctr + ALLOC_UP_THK_ctr + ALLOC_CON_ctr + ALLOC_TUP_ctr +
39         + ALLOC_TSO_ctr + ALLOC_BH_ctr  + ALLOC_PAP_ctr + ALLOC_PRIM_ctr
40       ; 
41
42   unsigned long tot_adm_wds = /* total number of admin words allocated */
43         ALLOC_FUN_adm + ALLOC_THK_adm + ALLOC_CON_adm + ALLOC_TUP_adm
44         + ALLOC_TSO_adm + ALLOC_BH_adm  + ALLOC_PAP_adm + ALLOC_PRIM_adm
45       ;
46
47   unsigned long tot_gds_wds = /* total number of words of ``good stuff'' allocated */
48         ALLOC_FUN_gds + ALLOC_THK_gds + ALLOC_CON_gds + ALLOC_TUP_gds
49         + ALLOC_TSO_gds + ALLOC_BH_gds  + ALLOC_PAP_gds + ALLOC_PRIM_gds
50       ;
51
52   unsigned long tot_slp_wds = /* total number of ``slop'' words allocated */
53         ALLOC_FUN_slp + ALLOC_THK_slp + ALLOC_CON_slp + ALLOC_TUP_slp
54         + ALLOC_TSO_slp + ALLOC_BH_slp  + ALLOC_PAP_slp + ALLOC_PRIM_slp
55       ;
56
57   unsigned long tot_wds = /* total words */
58         tot_adm_wds + tot_gds_wds + tot_slp_wds;
59 #endif
60
61   unsigned long tot_thk_enters = ENT_STATIC_THK_ctr + ENT_DYN_THK_ctr;
62   unsigned long tot_con_enters = ENT_STATIC_CON_ctr + ENT_DYN_CON_ctr;
63
64   unsigned long tot_fun_direct_enters = ENT_STATIC_FUN_DIRECT_ctr + ENT_DYN_FUN_DIRECT_ctr;
65   unsigned long tot_ind_enters = ENT_STATIC_IND_ctr + ENT_DYN_IND_ctr;
66   
67   // This is the number of times we entered a function via some kind
68   // of slow call.  It amounts to all the slow applications, not
69   // counting those that were to too few arguments.
70   /*
71   XXX This us unused - can we delete it? -- IGL 2008-04-25
72   unsigned long tot_fun_slow_enters = 
73       SLOW_CALL_ctr - 
74       SLOW_CALL_FUN_TOO_FEW_ctr -
75       SLOW_CALL_PAP_TOO_FEW_ctr;
76   */
77
78   unsigned long tot_known_calls =
79       KNOWN_CALL_ctr + KNOWN_CALL_TOO_FEW_ARGS_ctr + 
80       + KNOWN_CALL_EXTRA_ARGS_ctr;
81   unsigned long tot_tail_calls =
82       UNKNOWN_CALL_ctr + tot_known_calls;
83
84   unsigned long tot_enters = 
85       tot_con_enters + tot_fun_direct_enters +
86         tot_ind_enters + ENT_PERM_IND_ctr + ENT_PAP_ctr + tot_thk_enters;
87   unsigned long jump_direct_enters =
88         tot_enters - ENT_VIA_NODE_ctr;
89
90
91   unsigned long tot_returns =
92       RET_NEW_ctr + RET_OLD_ctr + RET_UNBOXED_TUP_ctr;
93
94   unsigned long tot_returns_of_new = RET_NEW_ctr;
95
96   unsigned long con_updates = UPD_CON_IN_NEW_ctr + UPD_CON_IN_PLACE_ctr;
97   unsigned long pap_updates = UPD_PAP_IN_NEW_ctr + UPD_PAP_IN_PLACE_ctr;
98
99   unsigned long tot_updates = UPD_SQUEEZED_ctr + pap_updates + con_updates;
100
101   unsigned long tot_new_updates   = UPD_NEW_IND_ctr + UPD_NEW_PERM_IND_ctr;
102   unsigned long tot_old_updates   = UPD_OLD_IND_ctr + UPD_OLD_PERM_IND_ctr;
103   unsigned long tot_gengc_updates = tot_new_updates + tot_old_updates;
104
105   FILE *tf = RtsFlags.TickyFlags.tickyFile;
106
107   /* If tf = NULL, that means the user passed in stderr for the ticky stats
108      file. According to a comment in RtsFlags.c, this means to use 
109      debugBelch to print out messages. But this function prints out a lot
110      of stuff so in order to avoid changing a lot of code, we just dump
111      the same output to stderr (for now). */
112   if( tf == NULL )
113     tf = stderr;
114
115   /* krc: avoid dealing with this just now */
116 #if FALSE
117   fprintf(tf,"\n\nALLOCATIONS: %ld (%ld words total: %ld admin, %ld goods, %ld slop)\n",
118           tot_allocs, tot_wds, tot_adm_wds, tot_gds_wds, tot_slp_wds);
119   fprintf(tf,"\t\t\t\ttotal words:\t    2     3     4     5    6+\n");
120
121 #define ALLOC_HISTO_MAGIC(categ) \
122         (PC(INTAVG(ALLOC_##categ##_hst[0], ALLOC_##categ##_ctr))), \
123         (PC(INTAVG(ALLOC_##categ##_hst[1], ALLOC_##categ##_ctr))), \
124         (PC(INTAVG(ALLOC_##categ##_hst[2], ALLOC_##categ##_ctr))), \
125         (PC(INTAVG(ALLOC_##categ##_hst[3], ALLOC_##categ##_ctr))), \
126         (PC(INTAVG(ALLOC_##categ##_hst[4], ALLOC_##categ##_ctr)))
127
128   fprintf(tf,"%7ld (%5.1f%%) function values",
129         ALLOC_FUN_ctr,
130         PC(INTAVG(ALLOC_FUN_ctr, tot_allocs)));
131   if (ALLOC_FUN_ctr != 0)
132       fprintf(tf,"\t\t%5.1f %5.1f %5.1f %5.1f %5.1f", ALLOC_HISTO_MAGIC(FUN));
133  
134
135   fprintf(tf,"\n%7ld (%5.1f%%) thunks",
136         ALLOC_SE_THK_ctr + ALLOC_UP_THK_ctr,
137         PC(INTAVG(ALLOC_SE_THK_ctr + ALLOC_UP_THK_ctr, tot_allocs)));
138
139 #define ALLOC_THK_ctr (ALLOC_UP_THK_ctr + ALLOC_SE_THK_ctr)
140   /* hack to make ALLOC_HISTO_MAGIC still work for THK */
141   if ((ALLOC_SE_THK_ctr + ALLOC_UP_THK_ctr) != 0)
142       fprintf(tf,"\t\t\t\t%5.1f %5.1f %5.1f %5.1f %5.1f", ALLOC_HISTO_MAGIC(THK));
143 #undef ALLOC_THK_ctr
144
145   fprintf(tf,"\n%7ld (%5.1f%%) data values",
146         ALLOC_CON_ctr,
147         PC(INTAVG(ALLOC_CON_ctr, tot_allocs)));
148   if (ALLOC_CON_ctr != 0)
149       fprintf(tf,"\t\t\t%5.1f %5.1f %5.1f %5.1f %5.1f", ALLOC_HISTO_MAGIC(CON));
150
151   fprintf(tf,"\n%7ld (%5.1f%%) big tuples",
152         ALLOC_TUP_ctr,
153         PC(INTAVG(ALLOC_TUP_ctr, tot_allocs)));
154   if (ALLOC_TUP_ctr != 0)
155       fprintf(tf,"\t\t\t%5.1f %5.1f %5.1f %5.1f %5.1f", ALLOC_HISTO_MAGIC(TUP));
156
157   fprintf(tf,"\n%7ld (%5.1f%%) black holes",
158         ALLOC_BH_ctr,
159         PC(INTAVG(ALLOC_BH_ctr, tot_allocs)));
160   if (ALLOC_BH_ctr != 0)
161       fprintf(tf,"\t\t\t%5.1f %5.1f %5.1f %5.1f %5.1f", ALLOC_HISTO_MAGIC(BH));
162
163   fprintf(tf,"\n%7ld (%5.1f%%) prim things",
164         ALLOC_PRIM_ctr,
165         PC(INTAVG(ALLOC_PRIM_ctr, tot_allocs)));
166   if (ALLOC_PRIM_ctr != 0)
167       fprintf(tf,"\t\t\t%5.1f %5.1f %5.1f %5.1f %5.1f", ALLOC_HISTO_MAGIC(PRIM));
168
169   fprintf(tf,"\n%7ld (%5.1f%%) partial applications",
170         ALLOC_PAP_ctr,
171         PC(INTAVG(ALLOC_PAP_ctr, tot_allocs)));
172   if (ALLOC_PAP_ctr != 0)
173       fprintf(tf,"\t\t%5.1f %5.1f %5.1f %5.1f %5.1f", ALLOC_HISTO_MAGIC(PAP));
174
175   fprintf(tf,"\n%7ld (%5.1f%%) thread state objects",
176         ALLOC_TSO_ctr,
177         PC(INTAVG(ALLOC_TSO_ctr, tot_allocs)));
178   if (ALLOC_TSO_ctr != 0)
179       fprintf(tf,"\t\t%5.1f %5.1f %5.1f %5.1f %5.1f", ALLOC_HISTO_MAGIC(TSO));
180
181   fprintf(tf,"\n");
182
183   fprintf(tf,"\nTotal storage-manager allocations: %ld (%ld words)\n\t[%ld words lost to speculative heap-checks]\n", ALLOC_HEAP_ctr, ALLOC_HEAP_tot, ALLOC_HEAP_tot - tot_wds);
184 #endif /* FALSE */
185
186
187   fprintf(tf,"\nSTACK USAGE:\n"); /* NB: some bits are direction sensitive */
188
189
190   fprintf(tf,"\nENTERS: %ld  of which %ld (%.1f%%) direct to the entry code\n\t\t  [the rest indirected via Node's info ptr]\n",
191         tot_enters,
192         jump_direct_enters,
193         PC(INTAVG(jump_direct_enters,tot_enters)));
194   fprintf(tf,"%7ld (%5.1f%%) thunks\n",
195         tot_thk_enters,
196         PC(INTAVG(tot_thk_enters,tot_enters)));
197   fprintf(tf,"%7ld (%5.1f%%) data values\n",
198         tot_con_enters,
199         PC(INTAVG(tot_con_enters,tot_enters)));
200   fprintf(tf,"%7ld (%5.1f%%) normal indirections\n",
201         tot_ind_enters,
202         PC(INTAVG(tot_ind_enters,tot_enters)));
203   fprintf(tf,"%7ld (%5.1f%%) permanent indirections\n",
204         ENT_PERM_IND_ctr,
205         PC(INTAVG(ENT_PERM_IND_ctr,tot_enters)));
206
207
208   fprintf(tf,"\nFUNCTION ENTRIES: %ld\n", tot_fun_direct_enters);
209
210   fprintf(tf, "\nTAIL CALLS: %ld, of which %ld (%.lf%%) were to known functions\n", 
211           tot_tail_calls, tot_known_calls,
212           PC(INTAVG(tot_known_calls,tot_tail_calls)));
213
214   fprintf(tf, "\nSLOW APPLICATIONS: %ld evaluated, %ld unevaluated\n",
215           SLOW_CALL_ctr, SLOW_CALL_UNEVALD_ctr);
216   fprintf(tf, "\n");
217   fprintf(tf, "         Too few args   Correct args   Too many args\n");
218   fprintf(tf, "   FUN     %8ld       %8ld        %8ld\n", 
219           SLOW_CALL_FUN_TOO_FEW_ctr, SLOW_CALL_FUN_CORRECT_ctr, SLOW_CALL_FUN_TOO_MANY_ctr);
220   fprintf(tf, "   PAP     %8ld       %8ld        %8ld\n", 
221           SLOW_CALL_PAP_TOO_FEW_ctr, SLOW_CALL_PAP_CORRECT_ctr, SLOW_CALL_PAP_TOO_MANY_ctr);
222   fprintf(tf, "\n");
223
224   fprintf(tf,"\nRETURNS: %ld\n", tot_returns);
225   fprintf(tf,"%7ld (%5.1f%%) from entering a new constructor\n\t\t  [the rest from entering an existing constructor]\n",
226         tot_returns_of_new,
227         PC(INTAVG(tot_returns_of_new,tot_returns)));
228
229   /* krc: comment out some of this stuff temporarily */
230
231   /*
232   fprintf(tf, "\nRET_NEW:         %7ld: ", RET_NEW_ctr);
233   for (i = 0; i < 9; i++) { fprintf(tf, "%5.1f%%",
234                                 PC(INTAVG(RET_NEW_hst[i],RET_NEW_ctr))); }
235   fprintf(tf, "\n");
236   fprintf(tf, "RET_OLD:         %7ld: ", RET_OLD_ctr);
237   for (i = 0; i < 9; i++) { fprintf(tf, "%5.1f%%",
238                                 PC(INTAVG(RET_OLD_hst[i],RET_OLD_ctr))); }
239   fprintf(tf, "\n");
240   fprintf(tf, "RET_UNBOXED_TUP: %7ld: ", RET_UNBOXED_TUP_ctr);
241   for (i = 0; i < 9; i++) { fprintf(tf, "%5.1f%%",
242                                     PC(INTAVG(RET_UNBOXED_TUP_hst[i],
243                                               RET_UNBOXED_TUP_ctr))); }
244   fprintf(tf, "\n");
245   */
246
247   fprintf(tf,"\nUPDATE FRAMES: %ld (%ld omitted from thunks)",
248         UPDF_PUSHED_ctr,
249         UPDF_OMITTED_ctr);
250
251   fprintf(tf,"\nCATCH FRAMES:  %ld", CATCHF_PUSHED_ctr);
252
253   if (UPDF_RCC_PUSHED_ctr != 0)
254      fprintf(tf,"%7ld restore cost centre frames (%ld omitted)\n",
255         UPDF_RCC_PUSHED_ctr,
256         UPDF_RCC_OMITTED_ctr);
257
258   fprintf(tf,"\nUPDATES: %ld\n", tot_updates);
259   fprintf(tf,"%7ld (%5.1f%%) data values\n\t\t  [%ld in place, %ld allocated new space]\n",
260         con_updates,
261         PC(INTAVG(con_updates,tot_updates)),
262         UPD_CON_IN_PLACE_ctr, UPD_CON_IN_NEW_ctr);
263   fprintf(tf,"%7ld (%5.1f%%) partial applications\n\t\t  [%ld in place, %ld allocated new space]\n",
264         pap_updates,
265         PC(INTAVG(pap_updates,tot_updates)),
266         UPD_PAP_IN_PLACE_ctr, UPD_PAP_IN_NEW_ctr);
267   fprintf(tf,"%7ld (%5.1f%%) updates by squeezing\n",
268         UPD_SQUEEZED_ctr,
269         PC(INTAVG(UPD_SQUEEZED_ctr, tot_updates)));
270
271   /* krc: also avoid dealing with this for now */
272 #if FALSE
273   fprintf(tf, "\nUPD_CON_IN_NEW:   %7ld: ", UPD_CON_IN_NEW_ctr);
274   for (i = 0; i < 9; i++) { fprintf(tf, "%7ld", UPD_CON_IN_NEW_hst[i]); }
275   fprintf(tf, "\n");
276   fprintf(tf, "UPD_CON_IN_PLACE: %7ld: ", UPD_CON_IN_PLACE_ctr);
277   for (i = 0; i < 9; i++) { fprintf(tf, "%7ld", UPD_CON_IN_PLACE_hst[i]); }
278   fprintf(tf, "\n");
279   fprintf(tf, "UPD_PAP_IN_NEW:   %7ld: ", UPD_PAP_IN_NEW_ctr);
280   for (i = 0; i < 9; i++) { fprintf(tf, "%7ld", UPD_PAP_IN_NEW_hst[i]); }
281   fprintf(tf, "\n");
282 #endif
283
284   if (tot_gengc_updates != 0) {
285       fprintf(tf,"\nNEW GEN UPDATES: %9ld (%5.1f%%)\n",
286               tot_new_updates,
287               PC(INTAVG(tot_new_updates,tot_gengc_updates)));
288       fprintf(tf,"OLD GEN UPDATES: %9ld (%5.1f%%)\n",
289               tot_old_updates,
290               PC(INTAVG(tot_old_updates,tot_gengc_updates)));
291   }
292
293   fprintf(tf,"\nTotal bytes copied during GC: %ld\n",
294           GC_WORDS_COPIED_ctr * sizeof(W_));
295
296   printRegisteredCounterInfo(tf);
297
298   fprintf(tf,"\n**************************************************\n");
299
300   /* here, we print out all the raw numbers; these are really
301     more useful when we want to snag them for subsequent
302     rdb-etc processing. WDP 95/11
303   */
304
305 #define PR_CTR(ctr) \
306   do { fprintf(tf,"%7ld " #ctr "\n", ctr); } while(0)
307 /* COND_PR_CTR takes a boolean; if false then msg is the printname rather than ctr */
308 #define COND_PR_CTR(ctr,b,msg) \
309     if (b) { fprintf(tf,"%7ld " #ctr "\n", ctr); } else { fprintf(tf,"%7ld " msg "\n", ctr); }
310 #define PR_HST(hst,i) \
311   do { fprintf(tf,"%7ld " #hst "_" #i "\n", hst[i]); } while(0)
312
313   PR_CTR(ALLOC_HEAP_ctr);
314   PR_CTR(ALLOC_HEAP_tot);
315
316   PR_CTR(ALLOC_FUN_ctr);
317   PR_CTR(ALLOC_FUN_adm);
318   PR_CTR(ALLOC_FUN_gds);
319   PR_CTR(ALLOC_FUN_slp);
320
321   /* krc: comment out some of this stuff temporarily
322   PR_HST(ALLOC_FUN_hst,0);
323   PR_HST(ALLOC_FUN_hst,1);
324   PR_HST(ALLOC_FUN_hst,2);
325   PR_HST(ALLOC_FUN_hst,3);
326   PR_HST(ALLOC_FUN_hst,4);
327   PR_CTR(ALLOC_UP_THK_ctr);
328   PR_CTR(ALLOC_SE_THK_ctr);
329   PR_CTR(ALLOC_THK_adm);
330   PR_CTR(ALLOC_THK_gds);
331   PR_CTR(ALLOC_THK_slp);
332   PR_HST(ALLOC_THK_hst,0);
333   PR_HST(ALLOC_THK_hst,1);
334   PR_HST(ALLOC_THK_hst,2);
335   PR_HST(ALLOC_THK_hst,3);
336   PR_HST(ALLOC_THK_hst,4);
337   PR_CTR(ALLOC_CON_ctr);
338   PR_CTR(ALLOC_CON_adm);
339   PR_CTR(ALLOC_CON_gds);
340   PR_CTR(ALLOC_CON_slp);
341   PR_HST(ALLOC_CON_hst,0);
342   PR_HST(ALLOC_CON_hst,1);
343   PR_HST(ALLOC_CON_hst,2);
344   PR_HST(ALLOC_CON_hst,3);
345   PR_HST(ALLOC_CON_hst,4);
346   PR_CTR(ALLOC_TUP_ctr);
347   PR_CTR(ALLOC_TUP_adm);
348   PR_CTR(ALLOC_TUP_gds);
349   PR_CTR(ALLOC_TUP_slp);
350   PR_HST(ALLOC_TUP_hst,0);
351   PR_HST(ALLOC_TUP_hst,1);
352   PR_HST(ALLOC_TUP_hst,2);
353   PR_HST(ALLOC_TUP_hst,3);
354   PR_HST(ALLOC_TUP_hst,4);
355   PR_CTR(ALLOC_BH_ctr);
356   PR_CTR(ALLOC_BH_adm);
357   PR_CTR(ALLOC_BH_gds);
358   PR_CTR(ALLOC_BH_slp);
359   PR_HST(ALLOC_BH_hst,0);
360   PR_HST(ALLOC_BH_hst,1);
361   PR_HST(ALLOC_BH_hst,2);
362   PR_HST(ALLOC_BH_hst,3);
363   PR_HST(ALLOC_BH_hst,4);
364   PR_CTR(ALLOC_PRIM_ctr);
365   PR_CTR(ALLOC_PRIM_adm);
366   PR_CTR(ALLOC_PRIM_gds);
367   PR_CTR(ALLOC_PRIM_slp);
368   PR_HST(ALLOC_PRIM_hst,0);
369   PR_HST(ALLOC_PRIM_hst,1);
370   PR_HST(ALLOC_PRIM_hst,2);
371   PR_HST(ALLOC_PRIM_hst,3);
372   PR_HST(ALLOC_PRIM_hst,4);
373   PR_CTR(ALLOC_PAP_ctr);
374   PR_CTR(ALLOC_PAP_adm);
375   PR_CTR(ALLOC_PAP_gds);
376   PR_CTR(ALLOC_PAP_slp);
377   PR_HST(ALLOC_PAP_hst,0);
378   PR_HST(ALLOC_PAP_hst,1);
379   PR_HST(ALLOC_PAP_hst,2);
380   PR_HST(ALLOC_PAP_hst,3);
381   PR_HST(ALLOC_PAP_hst,4);
382
383   PR_CTR(ALLOC_TSO_ctr);
384   PR_CTR(ALLOC_TSO_adm);
385   PR_CTR(ALLOC_TSO_gds);
386   PR_CTR(ALLOC_TSO_slp);
387   PR_HST(ALLOC_TSO_hst,0);
388   PR_HST(ALLOC_TSO_hst,1);
389   PR_HST(ALLOC_TSO_hst,2);
390   PR_HST(ALLOC_TSO_hst,3);
391   PR_HST(ALLOC_TSO_hst,4);
392   */
393
394   PR_CTR(ENT_VIA_NODE_ctr);
395   PR_CTR(ENT_STATIC_CON_ctr);
396   PR_CTR(ENT_DYN_CON_ctr);
397   PR_CTR(ENT_STATIC_FUN_DIRECT_ctr);
398   PR_CTR(ENT_DYN_FUN_DIRECT_ctr);
399   PR_CTR(ENT_STATIC_IND_ctr);
400   PR_CTR(ENT_DYN_IND_ctr);
401
402 /* The counters ENT_PERM_IND and UPD_{NEW,OLD}_PERM_IND are not dumped
403  * at the end of execution unless update squeezing is turned off (+RTS
404  * -Z =RtsFlags.GcFlags.squeezeUpdFrames), as they will be wrong
405  * otherwise.  Why?  Because for each update frame squeezed out, we
406  * count an UPD_NEW_PERM_IND *at GC time* (i.e., too early).  And
407  * further, when we enter the closure that has been updated, we count
408  * the ENT_PERM_IND, but we then enter the PERM_IND that was built for
409  * the next update frame below, and so on down the chain until we
410  * finally reach the value.  Thus we count many new ENT_PERM_INDs too
411  * early.  
412  * 
413  * This of course refers to the -ticky version that uses PERM_INDs to
414  * determine the number of closures entered 0/1/>1.  KSW 1999-04.  */
415   COND_PR_CTR(ENT_PERM_IND_ctr,RtsFlags.GcFlags.squeezeUpdFrames == rtsFalse,"E!NT_PERM_IND_ctr requires +RTS -Z");
416
417   PR_CTR(ENT_AP_ctr);
418   PR_CTR(ENT_PAP_ctr);
419   PR_CTR(ENT_AP_STACK_ctr);
420   PR_CTR(ENT_BH_ctr);
421   PR_CTR(ENT_STATIC_THK_ctr);
422   PR_CTR(ENT_DYN_THK_ctr);
423
424   PR_CTR(SLOW_CALL_v_ctr);
425   PR_CTR(SLOW_CALL_f_ctr);
426   PR_CTR(SLOW_CALL_d_ctr);
427   PR_CTR(SLOW_CALL_l_ctr);
428   PR_CTR(SLOW_CALL_n_ctr);
429   PR_CTR(SLOW_CALL_p_ctr);
430   PR_CTR(SLOW_CALL_pv_ctr);
431   PR_CTR(SLOW_CALL_pp_ctr);
432   PR_CTR(SLOW_CALL_ppv_ctr);
433   PR_CTR(SLOW_CALL_ppp_ctr);
434   PR_CTR(SLOW_CALL_pppv_ctr);
435   PR_CTR(SLOW_CALL_pppp_ctr);
436   PR_CTR(SLOW_CALL_ppppp_ctr);
437   PR_CTR(SLOW_CALL_pppppp_ctr);
438   PR_CTR(SLOW_CALL_OTHER_ctr);
439
440   PR_CTR(UNKNOWN_CALL_ctr);
441   PR_CTR(KNOWN_CALL_ctr);
442   PR_CTR(KNOWN_CALL_TOO_FEW_ARGS_ctr);
443   PR_CTR(KNOWN_CALL_EXTRA_ARGS_ctr);
444   PR_CTR(MULTI_CHUNK_SLOW_CALL_ctr);
445   PR_CTR(MULTI_CHUNK_SLOW_CALL_CHUNKS_ctr);
446   PR_CTR(SLOW_CALL_ctr);
447   PR_CTR(SLOW_CALL_FUN_TOO_FEW_ctr);
448   PR_CTR(SLOW_CALL_FUN_CORRECT_ctr);
449   PR_CTR(SLOW_CALL_FUN_TOO_MANY_ctr);
450   PR_CTR(SLOW_CALL_PAP_TOO_FEW_ctr);
451   PR_CTR(SLOW_CALL_PAP_CORRECT_ctr);
452   PR_CTR(SLOW_CALL_PAP_TOO_MANY_ctr);
453   PR_CTR(SLOW_CALL_UNEVALD_ctr);
454
455   /* krc: put off till later... */
456 #if FALSE
457   PR_HST(SLOW_CALL_hst,0);
458   PR_HST(SLOW_CALL_hst,1);
459   PR_HST(SLOW_CALL_hst,2);
460   PR_HST(SLOW_CALL_hst,3);
461   PR_HST(SLOW_CALL_hst,4);
462   PR_HST(SLOW_CALL_hst,5);
463   PR_HST(SLOW_CALL_hst,6);
464   PR_HST(SLOW_CALL_hst,7);
465 #endif
466
467   PR_CTR(RET_NEW_ctr);
468   PR_CTR(RET_OLD_ctr);
469   PR_CTR(RET_UNBOXED_TUP_ctr);
470
471   /* krc: put off till later... */
472 #if FALSE
473   PR_HST(RET_NEW_hst,0);
474   PR_HST(RET_NEW_hst,1);
475   PR_HST(RET_NEW_hst,2);
476   PR_HST(RET_NEW_hst,3);
477   PR_HST(RET_NEW_hst,4);
478   PR_HST(RET_NEW_hst,5);
479   PR_HST(RET_NEW_hst,6);
480   PR_HST(RET_NEW_hst,7);
481   PR_HST(RET_NEW_hst,8);
482   PR_HST(RET_OLD_hst,0);
483   PR_HST(RET_OLD_hst,1);
484   PR_HST(RET_OLD_hst,2);
485   PR_HST(RET_OLD_hst,3);
486   PR_HST(RET_OLD_hst,4);
487   PR_HST(RET_OLD_hst,5);
488   PR_HST(RET_OLD_hst,6);
489   PR_HST(RET_OLD_hst,7);
490   PR_HST(RET_OLD_hst,8);
491   PR_HST(RET_UNBOXED_TUP_hst,0);
492   PR_HST(RET_UNBOXED_TUP_hst,1);
493   PR_HST(RET_UNBOXED_TUP_hst,2);
494   PR_HST(RET_UNBOXED_TUP_hst,3);
495   PR_HST(RET_UNBOXED_TUP_hst,4);
496   PR_HST(RET_UNBOXED_TUP_hst,5);
497   PR_HST(RET_UNBOXED_TUP_hst,6);
498   PR_HST(RET_UNBOXED_TUP_hst,7);
499   PR_HST(RET_UNBOXED_TUP_hst,8);
500 #endif /* FALSE */
501
502   PR_CTR(UPDF_OMITTED_ctr);
503   PR_CTR(UPDF_PUSHED_ctr);
504   PR_CTR(CATCHF_PUSHED_ctr);
505
506   PR_CTR(UPDF_RCC_PUSHED_ctr);
507   PR_CTR(UPDF_RCC_OMITTED_ctr);
508
509   PR_CTR(UPD_SQUEEZED_ctr);
510   PR_CTR(UPD_CON_IN_NEW_ctr);
511   PR_CTR(UPD_CON_IN_PLACE_ctr);
512   PR_CTR(UPD_PAP_IN_NEW_ctr);
513   PR_CTR(UPD_PAP_IN_PLACE_ctr);
514
515   PR_CTR(UPD_BH_UPDATABLE_ctr);
516   PR_CTR(UPD_BH_SINGLE_ENTRY_ctr);
517   PR_CTR(UPD_CAF_BH_UPDATABLE_ctr);
518   PR_CTR(UPD_CAF_BH_SINGLE_ENTRY_ctr);
519
520   /* krc: put off till later...*/
521 #if FALSE
522   PR_HST(UPD_CON_IN_NEW_hst,0);
523   PR_HST(UPD_CON_IN_NEW_hst,1);
524   PR_HST(UPD_CON_IN_NEW_hst,2);
525   PR_HST(UPD_CON_IN_NEW_hst,3);
526   PR_HST(UPD_CON_IN_NEW_hst,4);
527   PR_HST(UPD_CON_IN_NEW_hst,5);
528   PR_HST(UPD_CON_IN_NEW_hst,6);
529   PR_HST(UPD_CON_IN_NEW_hst,7);
530   PR_HST(UPD_CON_IN_NEW_hst,8);
531   PR_HST(UPD_PAP_IN_NEW_hst,0);
532   PR_HST(UPD_PAP_IN_NEW_hst,1);
533   PR_HST(UPD_PAP_IN_NEW_hst,2);
534   PR_HST(UPD_PAP_IN_NEW_hst,3);
535   PR_HST(UPD_PAP_IN_NEW_hst,4);
536   PR_HST(UPD_PAP_IN_NEW_hst,5);
537   PR_HST(UPD_PAP_IN_NEW_hst,6);
538   PR_HST(UPD_PAP_IN_NEW_hst,7);
539   PR_HST(UPD_PAP_IN_NEW_hst,8);
540 #endif /* FALSE */
541
542   PR_CTR(UPD_NEW_IND_ctr);
543   /* see comment on ENT_PERM_IND_ctr */
544   COND_PR_CTR(UPD_NEW_PERM_IND_ctr,RtsFlags.GcFlags.squeezeUpdFrames == rtsFalse,"U!PD_NEW_PERM_IND_ctr requires +RTS -Z");
545   PR_CTR(UPD_OLD_IND_ctr);
546   /* see comment on ENT_PERM_IND_ctr */
547   COND_PR_CTR(UPD_OLD_PERM_IND_ctr,RtsFlags.GcFlags.squeezeUpdFrames == rtsFalse,"U!PD_OLD_PERM_IND_ctr requires +RTS -Z");
548
549   PR_CTR(GC_SEL_ABANDONED_ctr);
550   PR_CTR(GC_SEL_MINOR_ctr);
551   PR_CTR(GC_SEL_MAJOR_ctr);
552   PR_CTR(GC_FAILED_PROMOTION_ctr);
553   PR_CTR(GC_WORDS_COPIED_ctr);
554 }
555
556 /* Data structure used in ``registering'' one of these counters. */
557
558 StgEntCounter *ticky_entry_ctrs = NULL; /* root of list of them */
559
560 /* To print out all the registered-counter info: */
561
562 static void
563 printRegisteredCounterInfo (FILE *tf)
564 {
565     StgEntCounter *p;
566
567     if ( ticky_entry_ctrs != NULL ) {
568       fprintf(tf,"\n**************************************************\n\n");
569     }
570     fprintf(tf, "%11s%11s %6s%6s    %-11s%-30s\n",
571             "Entries", "Allocs", "Arity", "Stack", "Kinds", "Function");
572     fprintf(tf, "--------------------------------------------------------------------------------\n");
573     /* Function name at the end so it doesn't mess up the tabulation */
574
575     for (p = ticky_entry_ctrs; p != NULL; p = p->link) {
576         fprintf(tf, "%11ld%11ld %6zu%6zu    %-11s%-30s",
577                 p->entry_count,
578                 p->allocs,
579                 p->arity,
580                 p->stk_args,
581                 p->arg_kinds,
582                 p->str);
583
584         fprintf(tf, "\n");
585
586     }
587 }
588
589 /* Catch-all top-level counter struct.  Allocations from CAFs will go
590  * here.
591  */
592 StgEntCounter top_ct
593         = { 0, 0, 0,
594             "TOP", "",
595             0, 0, NULL };
596
597 #endif /* TICKY_TICKY */
598