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