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