[project @ 1999-11-11 17:50:47 by simonpj]
[ghc-hetmet.git] / ghc / rts / Ticky.c
1 /* -----------------------------------------------------------------------------
2  * $Id: Ticky.c,v 1.12 1999/11/11 17:50:48 simonpj Exp $
3  *
4  * (c) The AQUA project, Glasgow University, 1992-1997
5  * (c) The GHC Team, 1998-1999
6  *
7  * Ticky-ticky profiling
8  *-------------------------------------------------------------------------- */
9
10 #if defined(TICKY_TICKY)
11
12 #define TICKY_C                 /* define those variables */
13 #include "Rts.h"
14 #include "RtsFlags.h"
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   unsigned long i;
33   unsigned long tot_allocs = /* total number of things allocated */
34         ALLOC_FUN_ctr + ALLOC_SE_THK_ctr + ALLOC_UP_THK_ctr + ALLOC_CON_ctr + ALLOC_TUP_ctr +
35         ALLOC_TSO_ctr +
36 #ifdef PAR
37         ALLOC_FMBQ_ctr + ALLOC_FME_ctr + ALLOC_BF_ctr +
38 #endif
39         ALLOC_BH_ctr  + ALLOC_UPD_PAP_ctr + ALLOC_PRIM_ctr;
40
41   unsigned long tot_adm_wds = /* total number of admin words allocated */
42         ALLOC_FUN_adm + ALLOC_THK_adm + ALLOC_CON_adm + ALLOC_TUP_adm +
43         ALLOC_TSO_adm +
44 #ifdef PAR
45         ALLOC_FMBQ_adm + ALLOC_FME_adm + ALLOC_BF_adm +
46 #endif
47         ALLOC_BH_adm  + ALLOC_UPD_PAP_adm + ALLOC_PRIM_adm;
48
49   unsigned long tot_gds_wds = /* total number of words of ``good stuff'' allocated */
50         ALLOC_FUN_gds + ALLOC_THK_gds + ALLOC_CON_gds + ALLOC_TUP_gds +
51         ALLOC_TSO_gds +
52 #ifdef PAR
53         ALLOC_FMBQ_gds + ALLOC_FME_gds + ALLOC_BF_gds +
54 #endif
55
56         ALLOC_BH_gds  + ALLOC_UPD_PAP_gds + ALLOC_PRIM_gds;
57
58   unsigned long tot_slp_wds = /* total number of ``slop'' words allocated */
59         ALLOC_FUN_slp + ALLOC_THK_slp + ALLOC_CON_slp + ALLOC_TUP_slp +
60         ALLOC_TSO_slp +
61 #ifdef PAR
62         ALLOC_FMBQ_slp + ALLOC_FME_slp + ALLOC_BF_slp +
63 #endif
64         ALLOC_BH_slp  + ALLOC_UPD_PAP_slp + ALLOC_PRIM_slp;
65
66   unsigned long tot_wds = /* total words */
67         tot_adm_wds + tot_gds_wds + tot_slp_wds;
68
69   unsigned long tot_enters =
70         ENT_CON_ctr + ENT_FUN_DIRECT_ctr +
71         ENT_IND_ctr + ENT_PERM_IND_ctr + ENT_PAP_ctr + ENT_THK_ctr;
72   unsigned long jump_direct_enters =
73         tot_enters - ENT_VIA_NODE_ctr;
74   unsigned long bypass_enters =
75         ENT_FUN_DIRECT_ctr -
76         (ENT_FUN_STD_ctr - UPD_PAP_IN_NEW_ctr);
77
78   unsigned long tot_returns =
79         RET_NEW_ctr + RET_OLD_ctr + RET_UNBOXED_TUP_ctr +
80         RET_SEMI_IN_HEAP_ctr + RET_SEMI_BY_DEFAULT_ctr/*?*/;
81
82   unsigned long tot_returns_of_new = RET_NEW_ctr;
83
84   unsigned long con_updates = UPD_CON_IN_NEW_ctr + UPD_CON_IN_PLACE_ctr;
85   unsigned long pap_updates = UPD_PAP_IN_NEW_ctr + UPD_PAP_IN_PLACE_ctr;
86
87   unsigned long tot_updates = UPD_SQUEEZED_ctr + pap_updates + con_updates;
88
89   unsigned long tot_new_updates   = UPD_NEW_IND_ctr + UPD_NEW_PERM_IND_ctr;
90   unsigned long tot_old_updates   = UPD_OLD_IND_ctr + UPD_OLD_PERM_IND_ctr;
91   unsigned long tot_gengc_updates = tot_new_updates + tot_old_updates;
92
93   FILE *tf = RtsFlags.TickyFlags.tickyFile;
94
95   fprintf(tf,"\n\nALLOCATIONS: %ld (%ld words total: %ld admin, %ld goods, %ld slop)\n",
96           tot_allocs, tot_wds, tot_adm_wds, tot_gds_wds, tot_slp_wds);
97   fprintf(tf,"\t\t\t\ttotal words:\t    2     3     4     5    6+\n");
98
99 #define ALLOC_HISTO_MAGIC(categ) \
100         (PC(INTAVG(ALLOC_##categ##_hst[0], ALLOC_##categ##_ctr))), \
101         (PC(INTAVG(ALLOC_##categ##_hst[1], ALLOC_##categ##_ctr))), \
102         (PC(INTAVG(ALLOC_##categ##_hst[2], ALLOC_##categ##_ctr))), \
103         (PC(INTAVG(ALLOC_##categ##_hst[3], ALLOC_##categ##_ctr))), \
104         (PC(INTAVG(ALLOC_##categ##_hst[4], ALLOC_##categ##_ctr)))
105
106   fprintf(tf,"%7ld (%5.1f%%) function values",
107         ALLOC_FUN_ctr,
108         PC(INTAVG(ALLOC_FUN_ctr, tot_allocs)));
109   if (ALLOC_FUN_ctr != 0)
110       fprintf(tf,"\t\t%5.1f %5.1f %5.1f %5.1f %5.1f", ALLOC_HISTO_MAGIC(FUN));
111
112   fprintf(tf,"\n%7ld (%5.1f%%) thunks",
113         ALLOC_SE_THK_ctr + ALLOC_UP_THK_ctr,
114         PC(INTAVG(ALLOC_SE_THK_ctr + ALLOC_UP_THK_ctr, tot_allocs)));
115
116 #define ALLOC_THK_ctr (ALLOC_UP_THK_ctr + ALLOC_SE_THK_ctr)
117   /* hack to make ALLOC_HISTO_MAGIC still work for THK */
118   if ((ALLOC_SE_THK_ctr + ALLOC_UP_THK_ctr) != 0)
119       fprintf(tf,"\t\t\t\t%5.1f %5.1f %5.1f %5.1f %5.1f", ALLOC_HISTO_MAGIC(THK));
120 #undef ALLOC_THK_ctr
121
122   fprintf(tf,"\n%7ld (%5.1f%%) data values",
123         ALLOC_CON_ctr,
124         PC(INTAVG(ALLOC_CON_ctr, tot_allocs)));
125   if (ALLOC_CON_ctr != 0)
126       fprintf(tf,"\t\t\t%5.1f %5.1f %5.1f %5.1f %5.1f", ALLOC_HISTO_MAGIC(CON));
127
128   fprintf(tf,"\n%7ld (%5.1f%%) big tuples",
129         ALLOC_TUP_ctr,
130         PC(INTAVG(ALLOC_TUP_ctr, tot_allocs)));
131   if (ALLOC_TUP_ctr != 0)
132       fprintf(tf,"\t\t\t%5.1f %5.1f %5.1f %5.1f %5.1f", ALLOC_HISTO_MAGIC(TUP));
133
134   fprintf(tf,"\n%7ld (%5.1f%%) black holes",
135         ALLOC_BH_ctr,
136         PC(INTAVG(ALLOC_BH_ctr, tot_allocs)));
137   if (ALLOC_BH_ctr != 0)
138       fprintf(tf,"\t\t\t%5.1f %5.1f %5.1f %5.1f %5.1f", ALLOC_HISTO_MAGIC(BH));
139
140   fprintf(tf,"\n%7ld (%5.1f%%) prim things",
141         ALLOC_PRIM_ctr,
142         PC(INTAVG(ALLOC_PRIM_ctr, tot_allocs)));
143   if (ALLOC_PRIM_ctr != 0)
144       fprintf(tf,"\t\t\t%5.1f %5.1f %5.1f %5.1f %5.1f", ALLOC_HISTO_MAGIC(PRIM));
145
146   fprintf(tf,"\n%7ld (%5.1f%%) partial applications",
147         ALLOC_UPD_PAP_ctr,
148         PC(INTAVG(ALLOC_UPD_PAP_ctr, tot_allocs)));
149   if (ALLOC_UPD_PAP_ctr != 0)
150       fprintf(tf,"\t\t%5.1f %5.1f %5.1f %5.1f %5.1f", ALLOC_HISTO_MAGIC(UPD_PAP));
151
152   fprintf(tf,"\n%7ld (%5.1f%%) thread state objects",
153         ALLOC_TSO_ctr,
154         PC(INTAVG(ALLOC_TSO_ctr, tot_allocs)));
155   if (ALLOC_TSO_ctr != 0)
156       fprintf(tf,"\t\t%5.1f %5.1f %5.1f %5.1f %5.1f", ALLOC_HISTO_MAGIC(TSO));
157 #ifdef PAR
158   fprintf(tf,"\n%7ld (%5.1f%%) thread state objects",
159         ALLOC_FMBQ_ctr,
160         PC(INTAVG(ALLOC_FMBQ_ctr, tot_allocs)));
161   if (ALLOC_FMBQ_ctr != 0)
162       fprintf(tf,"\t\t%5.1f %5.1f %5.1f %5.1f %5.1f", ALLOC_HISTO_MAGIC(FMBQ));
163   fprintf(tf,"\n%7ld (%5.1f%%) thread state objects",
164         ALLOC_FME_ctr,
165         PC(INTAVG(ALLOC_FME_ctr, tot_allocs)));
166   if (ALLOC_FME_ctr != 0)
167       fprintf(tf,"\t\t%5.1f %5.1f %5.1f %5.1f %5.1f", ALLOC_HISTO_MAGIC(FME));
168   fprintf(tf,"\n%7ld (%5.1f%%) thread state objects",
169         ALLOC_BF_ctr,
170         PC(INTAVG(ALLOC_BF_ctr, tot_allocs)));
171   if (ALLOC_BF_ctr != 0)
172       fprintf(tf,"\t\t%5.1f %5.1f %5.1f %5.1f %5.1f", ALLOC_HISTO_MAGIC(BF));
173 #endif
174   fprintf(tf,"\n");
175
176   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);
177
178   fprintf(tf,"\nSTACK USAGE:\n"); /* NB: some bits are direction sensitive */
179
180   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",
181         tot_enters,
182         jump_direct_enters,
183         PC(INTAVG(jump_direct_enters,tot_enters)));
184   fprintf(tf,"%7ld (%5.1f%%) thunks\n",
185         ENT_THK_ctr,
186         PC(INTAVG(ENT_THK_ctr,tot_enters)));
187   fprintf(tf,"%7ld (%5.1f%%) data values\n",
188         ENT_CON_ctr,
189         PC(INTAVG(ENT_CON_ctr,tot_enters)));
190   fprintf(tf,"%7ld (%5.1f%%) function values\n\t\t  [of which %ld (%.1f%%) bypassed arg-satisfaction chk]\n",
191         ENT_FUN_DIRECT_ctr,
192         PC(INTAVG(ENT_FUN_DIRECT_ctr,tot_enters)),
193         bypass_enters,
194         PC(INTAVG(bypass_enters,ENT_FUN_DIRECT_ctr)));
195   fprintf(tf,"%7ld (%5.1f%%) partial applications\n",
196         ENT_PAP_ctr,
197         PC(INTAVG(ENT_PAP_ctr,tot_enters)));
198   fprintf(tf,"%7ld (%5.1f%%) normal indirections\n",
199         ENT_IND_ctr,
200         PC(INTAVG(ENT_IND_ctr,tot_enters)));
201   fprintf(tf,"%7ld (%5.1f%%) permanent indirections\n",
202         ENT_PERM_IND_ctr,
203         PC(INTAVG(ENT_PERM_IND_ctr,tot_enters)));
204
205   fprintf(tf,"\nRETURNS: %ld\n", tot_returns);
206   fprintf(tf,"%7ld (%5.1f%%) from entering a new constructor\n\t\t  [the rest from entering an existing constructor]\n",
207         tot_returns_of_new,
208         PC(INTAVG(tot_returns_of_new,tot_returns)));
209   fprintf(tf,"%7ld (%5.1f%%) vectored [the rest unvectored]\n",
210         VEC_RETURN_ctr,
211         PC(INTAVG(VEC_RETURN_ctr,tot_returns)));
212
213   fprintf(tf, "\nRET_NEW:         %7ld: ", RET_NEW_ctr);
214   for (i = 0; i < 9; i++) { fprintf(tf, "%5.1f%%",
215                                 PC(INTAVG(RET_NEW_hst[i],RET_NEW_ctr))); }
216   fprintf(tf, "\n");
217   fprintf(tf, "RET_OLD:         %7ld: ", RET_OLD_ctr);
218   for (i = 0; i < 9; i++) { fprintf(tf, "%5.1f%%",
219                                 PC(INTAVG(RET_OLD_hst[i],RET_OLD_ctr))); }
220   fprintf(tf, "\n");
221   fprintf(tf, "RET_UNBOXED_TUP: %7ld: ", RET_UNBOXED_TUP_ctr);
222   for (i = 0; i < 9; i++) { fprintf(tf, "%5.1f%%",
223                                     PC(INTAVG(RET_UNBOXED_TUP_hst[i],
224                                               RET_UNBOXED_TUP_ctr))); }
225   fprintf(tf, "\n");
226   fprintf(tf, "\nRET_VEC_RETURN : %7ld: ", VEC_RETURN_ctr);
227   for (i = 0; i < 9; i++) { fprintf(tf, "%5.1f%%",
228                                 PC(INTAVG(RET_VEC_RETURN_hst[i],VEC_RETURN_ctr))); }
229   fprintf(tf, "\n");
230
231   fprintf(tf,"\nUPDATE FRAMES: %ld (%ld omitted from thunks)",
232         UPDF_PUSHED_ctr,
233         UPDF_OMITTED_ctr);
234
235   fprintf(tf,"\nSEQ FRAMES:    %ld", SEQF_PUSHED_ctr);
236
237   fprintf(tf,"\nCATCH FRAMES:  %ld", CATCHF_PUSHED_ctr);
238
239   if (UPDF_RCC_PUSHED_ctr != 0)
240      fprintf(tf,"%7ld restore cost centre frames (%ld omitted)\n",
241         UPDF_RCC_PUSHED_ctr,
242         UPDF_RCC_OMITTED_ctr);
243
244   fprintf(tf,"\nUPDATES: %ld\n", tot_updates);
245   fprintf(tf,"%7ld (%5.1f%%) data values\n\t\t  [%ld in place, %ld allocated new space]\n",
246         con_updates,
247         PC(INTAVG(con_updates,tot_updates)),
248         UPD_CON_IN_PLACE_ctr, UPD_CON_IN_NEW_ctr);
249   fprintf(tf,"%7ld (%5.1f%%) partial applications\n\t\t  [%ld in place, %ld allocated new space]\n",
250         pap_updates,
251         PC(INTAVG(pap_updates,tot_updates)),
252         UPD_PAP_IN_PLACE_ctr, UPD_PAP_IN_NEW_ctr);
253   fprintf(tf,"%7ld (%5.1f%%) updates by squeezing\n",
254         UPD_SQUEEZED_ctr,
255         PC(INTAVG(UPD_SQUEEZED_ctr, tot_updates)));
256
257   fprintf(tf, "\nUPD_CON_IN_NEW:   %7ld: ", UPD_CON_IN_NEW_ctr);
258   for (i = 0; i < 9; i++) { fprintf(tf, "%7ld", UPD_CON_IN_NEW_hst[i]); }
259   fprintf(tf, "\n");
260   fprintf(tf, "UPD_CON_IN_PLACE: %7ld: ", UPD_CON_IN_PLACE_ctr);
261   for (i = 0; i < 9; i++) { fprintf(tf, "%7ld", UPD_CON_IN_PLACE_hst[i]); }
262   fprintf(tf, "\n");
263   fprintf(tf, "UPD_PAP_IN_NEW:   %7ld: ", UPD_PAP_IN_NEW_ctr);
264   for (i = 0; i < 9; i++) { fprintf(tf, "%7ld", UPD_PAP_IN_NEW_hst[i]); }
265   fprintf(tf, "\n");
266
267   if (tot_gengc_updates != 0) {
268       fprintf(tf,"\nNEW GEN UPDATES: %9ld (%5.1f%%)\n",
269               tot_new_updates,
270               PC(INTAVG(tot_new_updates,tot_gengc_updates)));
271       fprintf(tf,"OLD GEN UPDATES: %9ld (%5.1f%%)\n",
272               tot_old_updates,
273               PC(INTAVG(tot_old_updates,tot_gengc_updates)));
274   }
275
276   fprintf(tf,"\nTotal bytes copied during GC: %ld\n",
277           GC_WORDS_COPIED_ctr * sizeof(W_));
278
279   printRegisteredCounterInfo(tf);
280
281   fprintf(tf,"\n**************************************************\n");
282
283   /* here, we print out all the raw numbers; these are really
284     more useful when we want to snag them for subsequent
285     rdb-etc processing. WDP 95/11
286   */
287
288 #define PR_CTR(ctr) \
289   do { fprintf(tf,"%7ld " #ctr "\n", ctr); } while(0)
290 /* COND_PR_CTR takes a boolean; if false then msg is the printname rather than ctr */
291 #define COND_PR_CTR(ctr,b,msg) \
292     if (b) { fprintf(tf,"%7ld " #ctr "\n", ctr); } else { fprintf(tf,"%7ld " msg "\n", ctr); }
293 #define PR_HST(hst,i) \
294   do { fprintf(tf,"%7ld " #hst "_" #i "\n", hst[i]); } while(0)
295
296   PR_CTR(ALLOC_HEAP_ctr);
297   PR_CTR(ALLOC_HEAP_tot);
298
299   PR_CTR(ALLOC_FUN_ctr);
300   PR_CTR(ALLOC_FUN_adm);
301   PR_CTR(ALLOC_FUN_gds);
302   PR_CTR(ALLOC_FUN_slp);
303   PR_HST(ALLOC_FUN_hst,0);
304   PR_HST(ALLOC_FUN_hst,1);
305   PR_HST(ALLOC_FUN_hst,2);
306   PR_HST(ALLOC_FUN_hst,3);
307   PR_HST(ALLOC_FUN_hst,4);
308   PR_CTR(ALLOC_UP_THK_ctr);
309   PR_CTR(ALLOC_SE_THK_ctr);
310   PR_CTR(ALLOC_THK_adm);
311   PR_CTR(ALLOC_THK_gds);
312   PR_CTR(ALLOC_THK_slp);
313   PR_HST(ALLOC_THK_hst,0);
314   PR_HST(ALLOC_THK_hst,1);
315   PR_HST(ALLOC_THK_hst,2);
316   PR_HST(ALLOC_THK_hst,3);
317   PR_HST(ALLOC_THK_hst,4);
318   PR_CTR(ALLOC_CON_ctr);
319   PR_CTR(ALLOC_CON_adm);
320   PR_CTR(ALLOC_CON_gds);
321   PR_CTR(ALLOC_CON_slp);
322   PR_HST(ALLOC_CON_hst,0);
323   PR_HST(ALLOC_CON_hst,1);
324   PR_HST(ALLOC_CON_hst,2);
325   PR_HST(ALLOC_CON_hst,3);
326   PR_HST(ALLOC_CON_hst,4);
327   PR_CTR(ALLOC_TUP_ctr);
328   PR_CTR(ALLOC_TUP_adm);
329   PR_CTR(ALLOC_TUP_gds);
330   PR_CTR(ALLOC_TUP_slp);
331   PR_HST(ALLOC_TUP_hst,0);
332   PR_HST(ALLOC_TUP_hst,1);
333   PR_HST(ALLOC_TUP_hst,2);
334   PR_HST(ALLOC_TUP_hst,3);
335   PR_HST(ALLOC_TUP_hst,4);
336   PR_CTR(ALLOC_BH_ctr);
337   PR_CTR(ALLOC_BH_adm);
338   PR_CTR(ALLOC_BH_gds);
339   PR_CTR(ALLOC_BH_slp);
340   PR_HST(ALLOC_BH_hst,0);
341   PR_HST(ALLOC_BH_hst,1);
342   PR_HST(ALLOC_BH_hst,2);
343   PR_HST(ALLOC_BH_hst,3);
344   PR_HST(ALLOC_BH_hst,4);
345   PR_CTR(ALLOC_PRIM_ctr);
346   PR_CTR(ALLOC_PRIM_adm);
347   PR_CTR(ALLOC_PRIM_gds);
348   PR_CTR(ALLOC_PRIM_slp);
349   PR_HST(ALLOC_PRIM_hst,0);
350   PR_HST(ALLOC_PRIM_hst,1);
351   PR_HST(ALLOC_PRIM_hst,2);
352   PR_HST(ALLOC_PRIM_hst,3);
353   PR_HST(ALLOC_PRIM_hst,4);
354   PR_CTR(ALLOC_UPD_PAP_ctr);
355   PR_CTR(ALLOC_UPD_PAP_adm);
356   PR_CTR(ALLOC_UPD_PAP_gds);
357   PR_CTR(ALLOC_UPD_PAP_slp);
358   PR_HST(ALLOC_UPD_PAP_hst,0);
359   PR_HST(ALLOC_UPD_PAP_hst,1);
360   PR_HST(ALLOC_UPD_PAP_hst,2);
361   PR_HST(ALLOC_UPD_PAP_hst,3);
362   PR_HST(ALLOC_UPD_PAP_hst,4);
363
364   PR_CTR(ALLOC_TSO_ctr);
365   PR_CTR(ALLOC_TSO_adm);
366   PR_CTR(ALLOC_TSO_gds);
367   PR_CTR(ALLOC_TSO_slp);
368   PR_HST(ALLOC_TSO_hst,0);
369   PR_HST(ALLOC_TSO_hst,1);
370   PR_HST(ALLOC_TSO_hst,2);
371   PR_HST(ALLOC_TSO_hst,3);
372   PR_HST(ALLOC_TSO_hst,4);
373
374 #ifdef PAR
375   PR_CTR(ALLOC_FMBQ_ctr);
376   PR_CTR(ALLOC_FMBQ_adm);
377   PR_CTR(ALLOC_FMBQ_gds);
378   PR_CTR(ALLOC_FMBQ_slp);
379   PR_HST(ALLOC_FMBQ_hst,0);
380   PR_HST(ALLOC_FMBQ_hst,1);
381   PR_HST(ALLOC_FMBQ_hst,2);
382   PR_HST(ALLOC_FMBQ_hst,3);
383   PR_HST(ALLOC_FMBQ_hst,4);
384   PR_CTR(ALLOC_FME_ctr);
385   PR_CTR(ALLOC_FME_adm);
386   PR_CTR(ALLOC_FME_gds);
387   PR_CTR(ALLOC_FME_slp);
388   PR_HST(ALLOC_FME_hst,0);
389   PR_HST(ALLOC_FME_hst,1);
390   PR_HST(ALLOC_FME_hst,2);
391   PR_HST(ALLOC_FME_hst,3);
392   PR_HST(ALLOC_FME_hst,4);
393   PR_CTR(ALLOC_BF_ctr);
394   PR_CTR(ALLOC_BF_adm);
395   PR_CTR(ALLOC_BF_gds);
396   PR_CTR(ALLOC_BF_slp);
397   PR_HST(ALLOC_BF_hst,0);
398   PR_HST(ALLOC_BF_hst,1);
399   PR_HST(ALLOC_BF_hst,2);
400   PR_HST(ALLOC_BF_hst,3);
401   PR_HST(ALLOC_BF_hst,4);
402 #endif
403
404   PR_CTR(ENT_VIA_NODE_ctr);
405   PR_CTR(ENT_CON_ctr);
406   PR_CTR(ENT_FUN_STD_ctr);
407   PR_CTR(ENT_FUN_DIRECT_ctr);
408   PR_CTR(ENT_IND_ctr);
409
410 /* The counters ENT_PERM_IND and UPD_{NEW,OLD}_PERM_IND are not dumped
411  * at the end of execution unless update squeezing is turned off (+RTS
412  * -Z =RtsFlags.GcFlags.squeezeUpdFrames), as they will be wrong
413  * otherwise.  Why?  Because for each update frame squeezed out, we
414  * count an UPD_NEW_PERM_IND *at GC time* (i.e., too early).  And
415  * further, when we enter the closure that has been updated, we count
416  * the ENT_PERM_IND, but we then enter the PERM_IND that was built for
417  * the next update frame below, and so on down the chain until we
418  * finally reach the value.  Thus we count many new ENT_PERM_INDs too
419  * early.  
420  * 
421  * This of course refers to the -ticky version that uses PERM_INDs to
422  * determine the number of closures entered 0/1/>1.  KSW 1999-04.  */
423   COND_PR_CTR(ENT_PERM_IND_ctr,RtsFlags.GcFlags.squeezeUpdFrames == rtsTrue,"E!NT_PERM_IND_ctr requires +RTS -Z");
424
425   PR_CTR(ENT_PAP_ctr);
426   PR_CTR(ENT_AP_UPD_ctr);
427   PR_CTR(ENT_BH_ctr);
428   PR_CTR(ENT_THK_ctr);
429
430   PR_CTR(RET_NEW_ctr);
431   PR_CTR(RET_OLD_ctr);
432   PR_CTR(RET_UNBOXED_TUP_ctr);
433   PR_CTR(RET_SEMI_BY_DEFAULT_ctr);
434   PR_CTR(RET_SEMI_IN_HEAP_ctr);
435   PR_CTR(RET_SEMI_FAILED_IND_ctr);
436   PR_CTR(RET_SEMI_FAILED_UNEVAL_ctr);
437   PR_CTR(VEC_RETURN_ctr);
438
439   PR_HST(RET_NEW_hst,0);
440   PR_HST(RET_NEW_hst,1);
441   PR_HST(RET_NEW_hst,2);
442   PR_HST(RET_NEW_hst,3);
443   PR_HST(RET_NEW_hst,4);
444   PR_HST(RET_NEW_hst,5);
445   PR_HST(RET_NEW_hst,6);
446   PR_HST(RET_NEW_hst,7);
447   PR_HST(RET_NEW_hst,8);
448   PR_HST(RET_OLD_hst,0);
449   PR_HST(RET_OLD_hst,1);
450   PR_HST(RET_OLD_hst,2);
451   PR_HST(RET_OLD_hst,3);
452   PR_HST(RET_OLD_hst,4);
453   PR_HST(RET_OLD_hst,5);
454   PR_HST(RET_OLD_hst,6);
455   PR_HST(RET_OLD_hst,7);
456   PR_HST(RET_OLD_hst,8);
457   PR_HST(RET_UNBOXED_TUP_hst,0);
458   PR_HST(RET_UNBOXED_TUP_hst,1);
459   PR_HST(RET_UNBOXED_TUP_hst,2);
460   PR_HST(RET_UNBOXED_TUP_hst,3);
461   PR_HST(RET_UNBOXED_TUP_hst,4);
462   PR_HST(RET_UNBOXED_TUP_hst,5);
463   PR_HST(RET_UNBOXED_TUP_hst,6);
464   PR_HST(RET_UNBOXED_TUP_hst,7);
465   PR_HST(RET_UNBOXED_TUP_hst,8);
466   PR_HST(RET_SEMI_IN_HEAP_hst,0);
467   PR_HST(RET_SEMI_IN_HEAP_hst,1);
468   PR_HST(RET_SEMI_IN_HEAP_hst,2);
469   PR_HST(RET_SEMI_IN_HEAP_hst,3);
470   PR_HST(RET_SEMI_IN_HEAP_hst,4);
471   PR_HST(RET_SEMI_IN_HEAP_hst,5);
472   PR_HST(RET_SEMI_IN_HEAP_hst,6);
473   PR_HST(RET_SEMI_IN_HEAP_hst,7);
474   PR_HST(RET_SEMI_IN_HEAP_hst,8);
475   PR_HST(RET_VEC_RETURN_hst,0);
476   PR_HST(RET_VEC_RETURN_hst,1);
477   PR_HST(RET_VEC_RETURN_hst,2);
478   PR_HST(RET_VEC_RETURN_hst,3);
479   PR_HST(RET_VEC_RETURN_hst,4);
480   PR_HST(RET_VEC_RETURN_hst,5);
481   PR_HST(RET_VEC_RETURN_hst,6);
482   PR_HST(RET_VEC_RETURN_hst,7);
483   PR_HST(RET_VEC_RETURN_hst,8);
484
485   PR_CTR(RET_SEMI_loads_avoided);
486
487   PR_CTR(UPDF_OMITTED_ctr);
488   PR_CTR(UPDF_PUSHED_ctr);
489   PR_CTR(SEQF_PUSHED_ctr);
490   PR_CTR(CATCHF_PUSHED_ctr);
491
492   PR_CTR(UPDF_RCC_PUSHED_ctr);
493   PR_CTR(UPDF_RCC_OMITTED_ctr);
494
495   PR_CTR(UPD_SQUEEZED_ctr);
496   PR_CTR(UPD_CON_IN_NEW_ctr);
497   PR_CTR(UPD_CON_IN_PLACE_ctr);
498   PR_CTR(UPD_PAP_IN_NEW_ctr);
499   PR_CTR(UPD_PAP_IN_PLACE_ctr);
500
501   PR_CTR(UPD_BH_UPDATABLE_ctr);
502   PR_CTR(UPD_BH_SINGLE_ENTRY_ctr);
503   PR_CTR(UPD_CAF_BH_UPDATABLE_ctr);
504   PR_CTR(UPD_CAF_BH_SINGLE_ENTRY_ctr);
505
506   PR_HST(UPD_CON_IN_NEW_hst,0);
507   PR_HST(UPD_CON_IN_NEW_hst,1);
508   PR_HST(UPD_CON_IN_NEW_hst,2);
509   PR_HST(UPD_CON_IN_NEW_hst,3);
510   PR_HST(UPD_CON_IN_NEW_hst,4);
511   PR_HST(UPD_CON_IN_NEW_hst,5);
512   PR_HST(UPD_CON_IN_NEW_hst,6);
513   PR_HST(UPD_CON_IN_NEW_hst,7);
514   PR_HST(UPD_CON_IN_NEW_hst,8);
515   PR_HST(UPD_PAP_IN_NEW_hst,0);
516   PR_HST(UPD_PAP_IN_NEW_hst,1);
517   PR_HST(UPD_PAP_IN_NEW_hst,2);
518   PR_HST(UPD_PAP_IN_NEW_hst,3);
519   PR_HST(UPD_PAP_IN_NEW_hst,4);
520   PR_HST(UPD_PAP_IN_NEW_hst,5);
521   PR_HST(UPD_PAP_IN_NEW_hst,6);
522   PR_HST(UPD_PAP_IN_NEW_hst,7);
523   PR_HST(UPD_PAP_IN_NEW_hst,8);
524
525   PR_CTR(UPD_NEW_IND_ctr);
526   /* see comment on ENT_PERM_IND_ctr */
527   COND_PR_CTR(UPD_NEW_PERM_IND_ctr,RtsFlags.GcFlags.squeezeUpdFrames == rtsTrue,"U!PD_NEW_PERM_IND_ctr requires +RTS -Z");
528   PR_CTR(UPD_OLD_IND_ctr);
529   /* see comment on ENT_PERM_IND_ctr */
530   COND_PR_CTR(UPD_OLD_PERM_IND_ctr,RtsFlags.GcFlags.squeezeUpdFrames == rtsTrue,"U!PD_OLD_PERM_IND_ctr requires +RTS -Z");
531
532   PR_CTR(GC_SEL_ABANDONED_ctr);
533   PR_CTR(GC_SEL_MINOR_ctr);
534   PR_CTR(GC_SEL_MAJOR_ctr);
535   PR_CTR(GC_FAILED_PROMOTION_ctr);
536   PR_CTR(GC_WORDS_COPIED_ctr);
537 }
538
539 /* Data structure used in ``registering'' one of these counters. */
540
541 StgEntCounter *ticky_entry_ctrs = NULL; /* root of list of them */
542
543 /* To print out all the registered-counter info: */
544
545 static void
546 printRegisteredCounterInfo (FILE *tf)
547 {
548     StgEntCounter *p;
549
550     if ( ticky_entry_ctrs != NULL ) {
551       fprintf(tf,"\n**************************************************\n\n");
552     }
553     fprintf(tf, "%11s%11s%11s %6s%6s    %-11s%-30s\n",
554             "Entries", "Slow ent", "Allocs", "Arity", "Stack", "Kinds", "Function");
555     fprintf(tf, "--------------------------------------------------------------------------------\n");
556     /* Function name at the end so it doesn't mess up the tabulation */
557
558     for (p = ticky_entry_ctrs; p != NULL; p = p->link) {
559         fprintf(tf, "%11ld%11ld%11ld %6u%6u    %-11s%-30s",
560                 p->entry_count,
561                 p->slow_entry_count,
562                 p->allocs,
563                 p->arity,
564                 p->stk_args,
565                 p->arg_kinds,
566                 p->str);
567
568         fprintf(tf, "\n");
569
570     }
571 }
572
573 /* Catch-all top-level counter struct.  Allocations from CAFs will go
574  * here.
575  */
576 StgEntCounter top_ct
577         = { 0, 0, 0,
578             "TOP", "",
579             0, 0, 0, NULL };
580
581 #endif /* TICKY_TICKY */
582