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