[project @ 1996-01-08 20:28:12 by partain]
[ghc-hetmet.git] / ghc / runtime / main / RednCounts.lc
1 %
2 % (c) The GRASP Project, Glasgow University, 1992-1993
3 %
4 %************************************************************************
5 %*                                                                      *
6 \section[RednCounts.lc]{Stuff for ``ticky-ticky'' profiling}
7 %*                                                                      *
8 %************************************************************************
9
10 Goes with \tr{imports/RednCounts.lh}; more documentation there.
11
12 %************************************************************************
13 %*                                                                      *
14 \subsection[RednCounts-counters]{Declare all the counters}
15 %*                                                                      *
16 %************************************************************************
17
18 \begin{code}
19 #define NULL_REG_MAP    /* Not threaded */
20
21 #include "../storage/SMinternal.h" /* Bad boy, Will (ToDo) */
22
23 #if defined(DO_REDN_COUNTING)
24
25 extern FILE *tickyfile;
26
27 I_ ALLOC_HEAP_ctr = 0;
28 I_ ALLOC_HEAP_tot = 0;
29
30 PP_ max_SpA; /* set in re_enterable_part_of_main */
31 P_  max_SpB;
32
33 /* not used at all
34 I_ A_STK_REUSE_ctr = 0;
35 I_ B_STK_REUSE_ctr = 0;
36 */
37 I_ A_STK_STUB_ctr = 0;
38
39 I_ ALLOC_FUN_ctr = 0;
40 I_ ALLOC_FUN_adm = 0;
41 I_ ALLOC_FUN_gds = 0;
42 I_ ALLOC_FUN_slp = 0;
43 I_ ALLOC_FUN_hst[5] = {0,0,0,0,0};
44 I_ ALLOC_THK_ctr = 0;
45 I_ ALLOC_THK_adm = 0;
46 I_ ALLOC_THK_gds = 0;
47 I_ ALLOC_THK_slp = 0;
48 I_ ALLOC_THK_hst[5] = {0,0,0,0,0};
49 I_ ALLOC_CON_ctr = 0;
50 I_ ALLOC_CON_adm = 0;
51 I_ ALLOC_CON_gds = 0;
52 I_ ALLOC_CON_slp = 0;
53 I_ ALLOC_CON_hst[5] = {0,0,0,0,0};
54 I_ ALLOC_TUP_ctr = 0;
55 I_ ALLOC_TUP_adm = 0;
56 I_ ALLOC_TUP_gds = 0;
57 I_ ALLOC_TUP_slp = 0;
58 I_ ALLOC_TUP_hst[5] = {0,0,0,0,0};
59 I_ ALLOC_BH_ctr = 0;
60 I_ ALLOC_BH_adm = 0;
61 I_ ALLOC_BH_gds = 0;
62 I_ ALLOC_BH_slp = 0;
63 I_ ALLOC_BH_hst[5] = {0,0,0,0,0};
64 /*
65 I_ ALLOC_PAP_ctr = 0;
66 I_ ALLOC_PAP_adm = 0;
67 I_ ALLOC_PAP_gds = 0;
68 I_ ALLOC_PAP_slp = 0;
69 I_ ALLOC_PAP_hst[5] = {0,0,0,0,0};
70 */
71 I_ ALLOC_PRIM_ctr = 0;
72 I_ ALLOC_PRIM_adm = 0;
73 I_ ALLOC_PRIM_gds = 0;
74 I_ ALLOC_PRIM_slp = 0;
75 I_ ALLOC_PRIM_hst[5] = {0,0,0,0,0};
76 /*
77 I_ ALLOC_UPD_CON_ctr = 0;
78 I_ ALLOC_UPD_CON_adm = 0;
79 I_ ALLOC_UPD_CON_gds = 0;
80 I_ ALLOC_UPD_CON_slp = 0;
81 I_ ALLOC_UPD_CON_hst[5] = {0,0,0,0,0};
82 */
83 I_ ALLOC_UPD_PAP_ctr = 0;
84 I_ ALLOC_UPD_PAP_adm = 0;
85 I_ ALLOC_UPD_PAP_gds = 0;
86 I_ ALLOC_UPD_PAP_slp = 0;
87 I_ ALLOC_UPD_PAP_hst[5] = {0,0,0,0,0};
88
89 #ifdef CONCURRENT
90 I_ ALLOC_STK_ctr = 0;
91 I_ ALLOC_STK_adm = 0;
92 I_ ALLOC_STK_gds = 0;
93 I_ ALLOC_STK_slp = 0;
94 I_ ALLOC_STK_hst[5] = {0,0,0,0,0};
95 I_ ALLOC_TSO_ctr = 0;
96 I_ ALLOC_TSO_adm = 0;
97 I_ ALLOC_TSO_gds = 0;
98 I_ ALLOC_TSO_slp = 0;
99 I_ ALLOC_TSO_hst[5] = {0,0,0,0,0};
100
101 #ifdef PAR
102 I_ ALLOC_FMBQ_ctr = 0;
103 I_ ALLOC_FMBQ_adm = 0;
104 I_ ALLOC_FMBQ_gds = 0;
105 I_ ALLOC_FMBQ_slp = 0;
106 I_ ALLOC_FMBQ_hst[5] = {0,0,0,0,0};
107 I_ ALLOC_FME_ctr = 0;
108 I_ ALLOC_FME_adm = 0;
109 I_ ALLOC_FME_gds = 0;
110 I_ ALLOC_FME_slp = 0;
111 I_ ALLOC_FME_hst[5] = {0,0,0,0,0};
112 I_ ALLOC_BF_ctr = 0;
113 I_ ALLOC_BF_adm = 0;
114 I_ ALLOC_BF_gds = 0;
115 I_ ALLOC_BF_slp = 0;
116 I_ ALLOC_BF_hst[5] = {0,0,0,0,0};
117 #endif
118 #endif
119
120 I_ ENT_VIA_NODE_ctr = 0;
121 I_ ENT_CON_ctr = 0;
122 I_ ENT_FUN_STD_ctr = 0;
123 I_ ENT_FUN_DIRECT_ctr = 0;
124 I_ ENT_IND_ctr = 0;
125 I_ ENT_PAP_ctr = 0;
126 I_ ENT_THK_ctr = 0;
127
128 I_ RET_NEW_IN_HEAP_ctr = 0;
129 I_ RET_NEW_IN_REGS_ctr = 0;
130 I_ RET_OLD_IN_HEAP_ctr = 0;
131 I_ RET_OLD_IN_REGS_ctr = 0;
132 I_ RET_SEMI_BY_DEFAULT_ctr = 0;
133 I_ RET_SEMI_IN_HEAP_ctr = 0;
134 I_ RET_SEMI_IN_REGS_ctr = 0;
135 I_ VEC_RETURN_ctr = 0;
136
137 I_ ReturnInRegsNodeValid = 0; /* i.e., False */
138
139 I_ UPDF_OMITTED_ctr = 0;
140 I_ UPDF_STD_PUSHED_ctr = 0;
141 I_ UPDF_CON_PUSHED_ctr = 0;
142 I_ UPDF_HOLE_PUSHED_ctr = 0;
143
144 I_ UPDF_RCC_PUSHED_ctr = 0;
145 I_ UPDF_RCC_OMITTED_ctr = 0;
146
147 I_ UPD_EXISTING_ctr = 0;
148 I_ UPD_CON_W_NODE_ctr = 0;
149 I_ UPD_CON_IN_PLACE_ctr = 0;
150 I_ UPD_CON_IN_NEW_ctr = 0;
151 I_ UPD_PAP_IN_PLACE_ctr = 0;
152 I_ UPD_PAP_IN_NEW_ctr = 0;
153
154 I_ UPD_ENTERED_ctr = 0;
155 I_ UPD_ENTERED_AGAIN_ctr = 0;
156
157 I_ UPD_NEW_IND_ctr = 0;
158 I_ UPD_NEW_IN_PLACE_PTRS_ctr = 0;
159 I_ UPD_NEW_IN_PLACE_NOPTRS_ctr = 0;
160 I_ UPD_OLD_IND_ctr = 0;
161 I_ UPD_OLD_IN_PLACE_PTRS_ctr = 0;
162 I_ UPD_OLD_IN_PLACE_NOPTRS_ctr = 0;
163
164 I_ UPD_IN_PLACE_COPY_ctr = 0;
165 \end{code}
166
167 \begin{code}
168 #if 0
169 /* testing only */
170 void
171 TICKY_PARANOIA(const char *file, I_ line)
172 {
173   I_ tot_adm_wds = /* total number of admin words allocated */
174         ALLOC_FUN_adm + ALLOC_THK_adm + ALLOC_CON_adm + ALLOC_TUP_adm +
175         ALLOC_BH_adm  /*+ ALLOC_PAP_adm*/ /*+ ALLOC_UPD_CON_adm*/ + ALLOC_UPD_PAP_adm +
176         ALLOC_PRIM_adm;
177   I_ tot_gds_wds = /* total number of words of ``good stuff'' allocated */
178         ALLOC_FUN_gds + ALLOC_THK_gds + ALLOC_CON_gds + ALLOC_TUP_gds +
179         ALLOC_BH_gds  /*+ ALLOC_PAP_gds*/ /*+ ALLOC_UPD_CON_gds*/ + ALLOC_UPD_PAP_gds +
180         ALLOC_PRIM_gds;
181   I_ tot_slp_wds = /* total number of ``slop'' words allocated */
182         ALLOC_FUN_slp + ALLOC_THK_slp + ALLOC_CON_slp + ALLOC_TUP_slp +
183         ALLOC_BH_slp  /*+ ALLOC_PAP_slp*/ /*+ ALLOC_UPD_CON_slp*/ + ALLOC_UPD_PAP_slp +
184         ALLOC_PRIM_slp;
185   I_ tot_wds = /* total words */
186         tot_adm_wds + tot_gds_wds + tot_slp_wds;
187   if (ALLOC_HEAP_tot != tot_wds) {
188         fprintf(stderr, "Eek! %ld != %ld, %s, %d\n",ALLOC_HEAP_tot, tot_wds, file, line);
189   } else {
190         fprintf(stderr, "OK. %ld != %ld, %s, %d\n",ALLOC_HEAP_tot, tot_wds, file, line);
191   }
192 }
193 #endif /* 0 */
194 \end{code}
195
196 %************************************************************************
197 %*                                                                      *
198 \subsection[RednCounts-print]{Print out all the counters}
199 %*                                                                      *
200 %************************************************************************
201
202 \begin{code}
203 extern void printRegisteredCounterInfo (STG_NO_ARGS); /* fwd decl */
204
205 #define INTAVG(a,b) ((b == 0) ? 0.0 : ((StgDouble) (a) / (StgDouble) (b)))
206 #define PC(a)       (100.0 * a)
207
208 #define AVG(thing) \
209         StgDouble CAT2(avg,thing)  = INTAVG(CAT2(tot,thing),CAT2(ctr,thing))
210
211 void
212 PrintRednCountInfo()
213 {
214   I_ tot_allocs = /* total number of things allocated */
215         ALLOC_FUN_ctr + ALLOC_THK_ctr + ALLOC_CON_ctr + ALLOC_TUP_ctr +
216 #ifdef CONCURRENT
217         ALLOC_STK_ctr + ALLOC_TSO_ctr +
218 #ifdef PAR
219         ALLOC_FMBQ_ctr + ALLOC_FME_ctr + ALLOC_BF_ctr +
220 #endif
221 #endif
222         ALLOC_BH_ctr  /*+ ALLOC_PAP_ctr*/ /*+ ALLOC_UPD_CON_ctr*/ + ALLOC_UPD_PAP_ctr +
223         ALLOC_PRIM_ctr;
224   I_ tot_adm_wds = /* total number of admin words allocated */
225         ALLOC_FUN_adm + ALLOC_THK_adm + ALLOC_CON_adm + ALLOC_TUP_adm +
226 #ifdef CONCURRENT
227         ALLOC_STK_adm + ALLOC_TSO_adm +
228 #ifdef PAR
229         ALLOC_FMBQ_adm + ALLOC_FME_adm + ALLOC_BF_adm +
230 #endif
231 #endif
232         ALLOC_BH_adm  /*+ ALLOC_PAP_adm*/ /*+ ALLOC_UPD_CON_adm*/ + ALLOC_UPD_PAP_adm +
233         ALLOC_PRIM_adm;
234   I_ tot_gds_wds = /* total number of words of ``good stuff'' allocated */
235         ALLOC_FUN_gds + ALLOC_THK_gds + ALLOC_CON_gds + ALLOC_TUP_gds +
236 #ifdef CONCURRENT
237         ALLOC_STK_gds + ALLOC_TSO_gds +
238 #ifdef PAR
239         ALLOC_FMBQ_gds + ALLOC_FME_gds + ALLOC_BF_gds +
240 #endif
241 #endif
242         ALLOC_BH_gds  /*+ ALLOC_PAP_gds*/ /*+ ALLOC_UPD_CON_gds*/ + ALLOC_UPD_PAP_gds +
243         ALLOC_PRIM_gds;
244   I_ tot_slp_wds = /* total number of ``slop'' words allocated */
245         ALLOC_FUN_slp + ALLOC_THK_slp + ALLOC_CON_slp + ALLOC_TUP_slp +
246 #ifdef CONCURRENT
247         ALLOC_STK_slp + ALLOC_TSO_slp +
248 #ifdef PAR
249         ALLOC_FMBQ_slp + ALLOC_FME_slp + ALLOC_BF_slp +
250 #endif
251 #endif
252         ALLOC_BH_slp  /*+ ALLOC_PAP_slp*/ /*+ ALLOC_UPD_CON_slp*/ + ALLOC_UPD_PAP_slp +
253         ALLOC_PRIM_slp;
254   I_ tot_wds = /* total words */
255         tot_adm_wds + tot_gds_wds + tot_slp_wds;
256
257   I_ tot_enters =
258         ENT_CON_ctr + ENT_FUN_DIRECT_ctr +
259         ENT_IND_ctr + ENT_PAP_ctr + ENT_THK_ctr;
260   I_ jump_direct_enters =
261         tot_enters - ENT_VIA_NODE_ctr;
262   I_ bypass_enters =
263         ENT_FUN_DIRECT_ctr -
264         (ENT_FUN_STD_ctr - UPD_PAP_IN_PLACE_ctr - UPD_PAP_IN_NEW_ctr);
265
266   I_ tot_returns_in_regs =
267         RET_NEW_IN_REGS_ctr + RET_OLD_IN_REGS_ctr + RET_SEMI_IN_REGS_ctr;
268   I_ tot_returns_in_heap =
269         RET_NEW_IN_HEAP_ctr + RET_OLD_IN_HEAP_ctr + RET_SEMI_IN_HEAP_ctr + RET_SEMI_BY_DEFAULT_ctr/*???*/;
270   I_ tot_returns_of_new =
271         RET_NEW_IN_REGS_ctr + RET_NEW_IN_HEAP_ctr;
272   I_ tot_returns_of_old = /* NB: NOT USED ???!  94/05 WDP */
273         RET_OLD_IN_REGS_ctr + RET_OLD_IN_HEAP_ctr +
274         RET_SEMI_BY_DEFAULT_ctr + RET_SEMI_IN_HEAP_ctr + RET_SEMI_IN_REGS_ctr /*???*/;
275
276   I_ tot_returns =
277         tot_returns_in_regs + tot_returns_in_heap;
278
279   I_ tot_upd_frames =
280         UPDF_STD_PUSHED_ctr + UPDF_CON_PUSHED_ctr;      /*DBH*/
281
282   I_ con_updates =
283         UPD_CON_W_NODE_ctr + UPD_CON_IN_PLACE_ctr + UPD_CON_IN_NEW_ctr;
284   I_ pap_updates =
285         UPD_PAP_IN_PLACE_ctr + UPD_PAP_IN_NEW_ctr;
286   I_ tot_updates =
287         UPD_EXISTING_ctr + con_updates + pap_updates;
288   I_ tot_in_place_updates =
289         UPD_CON_IN_PLACE_ctr + UPD_PAP_IN_PLACE_ctr;
290
291   I_ tot_new_updates = 
292         UPD_NEW_IN_PLACE_NOPTRS_ctr + UPD_NEW_IN_PLACE_PTRS_ctr + UPD_NEW_IND_ctr;
293   I_ tot_old_updates =
294         UPD_OLD_IN_PLACE_NOPTRS_ctr + UPD_OLD_IN_PLACE_PTRS_ctr + UPD_OLD_IND_ctr;
295   I_ tot_gengc_updates =
296         tot_new_updates + tot_old_updates;
297
298   fprintf(tickyfile,"\n\nALLOCATIONS: %ld (%ld words total: %ld admin, %ld goods, %ld slop)\n",
299         tot_allocs, tot_wds, tot_adm_wds, tot_gds_wds, tot_slp_wds);
300   fprintf(tickyfile,"\t\t\t\ttotal words:\t    2     3     4     5    6+\n");
301
302 #define ALLOC_HISTO_MAGIC(categ) \
303         (PC(INTAVG(CAT3(ALLOC_,categ,_hst)[0], CAT3(ALLOC_,categ,_ctr)))), \
304         (PC(INTAVG(CAT3(ALLOC_,categ,_hst)[1], CAT3(ALLOC_,categ,_ctr)))), \
305         (PC(INTAVG(CAT3(ALLOC_,categ,_hst)[2], CAT3(ALLOC_,categ,_ctr)))), \
306         (PC(INTAVG(CAT3(ALLOC_,categ,_hst)[3], CAT3(ALLOC_,categ,_ctr)))), \
307         (PC(INTAVG(CAT3(ALLOC_,categ,_hst)[4], CAT3(ALLOC_,categ,_ctr))))
308
309   fprintf(tickyfile,"%7ld (%5.1f%%) function values",
310         ALLOC_FUN_ctr,
311         PC(INTAVG(ALLOC_FUN_ctr, tot_allocs)));
312   if (ALLOC_FUN_ctr != 0)
313       fprintf(tickyfile,"\t\t%5.1f %5.1f %5.1f %5.1f %5.1f", ALLOC_HISTO_MAGIC(FUN));
314
315   fprintf(tickyfile,"\n%7ld (%5.1f%%) thunks",
316         ALLOC_THK_ctr,
317         PC(INTAVG(ALLOC_THK_ctr, tot_allocs)));
318   if (ALLOC_THK_ctr != 0)
319       fprintf(tickyfile,"\t\t\t\t%5.1f %5.1f %5.1f %5.1f %5.1f", ALLOC_HISTO_MAGIC(THK));
320
321   fprintf(tickyfile,"\n%7ld (%5.1f%%) data values",
322         ALLOC_CON_ctr,
323         PC(INTAVG(ALLOC_CON_ctr, tot_allocs)));
324   if (ALLOC_CON_ctr != 0)
325       fprintf(tickyfile,"\t\t\t%5.1f %5.1f %5.1f %5.1f %5.1f", ALLOC_HISTO_MAGIC(CON));
326
327   fprintf(tickyfile,"\n%7ld (%5.1f%%) big tuples",
328         ALLOC_TUP_ctr,
329         PC(INTAVG(ALLOC_TUP_ctr, tot_allocs)));
330   if (ALLOC_TUP_ctr != 0)
331       fprintf(tickyfile,"\t\t\t%5.1f %5.1f %5.1f %5.1f %5.1f", ALLOC_HISTO_MAGIC(TUP));
332
333   fprintf(tickyfile,"\n%7ld (%5.1f%%) black holes",
334         ALLOC_BH_ctr,
335         PC(INTAVG(ALLOC_BH_ctr, tot_allocs)));
336   if (ALLOC_BH_ctr != 0)
337       fprintf(tickyfile,"\t\t\t%5.1f %5.1f %5.1f %5.1f %5.1f", ALLOC_HISTO_MAGIC(BH));
338
339   fprintf(tickyfile,"\n%7ld (%5.1f%%) prim things",
340         ALLOC_PRIM_ctr,
341         PC(INTAVG(ALLOC_PRIM_ctr, tot_allocs)));
342   if (ALLOC_PRIM_ctr != 0)
343       fprintf(tickyfile,"\t\t\t%5.1f %5.1f %5.1f %5.1f %5.1f", ALLOC_HISTO_MAGIC(PRIM));
344
345 #if 0
346   fprintf(tickyfile,"\n%7ld (%5.1f%%) partial applications",
347         ALLOC_PAP_ctr,
348         PC(INTAVG(ALLOC_PAP_ctr, tot_allocs)));
349   if (ALLOC_PAP_ctr != 0)
350       fprintf(tickyfile,"\t\t%5.1f %5.1f %5.1f %5.1f %5.1f", ALLOC_HISTO_MAGIC(PAP));
351 #endif /* 0 */
352
353   fprintf(tickyfile,"\n%7ld (%5.1f%%) partial applications",
354         ALLOC_UPD_PAP_ctr,
355         PC(INTAVG(ALLOC_UPD_PAP_ctr, tot_allocs)));
356   if (ALLOC_UPD_PAP_ctr != 0)
357       fprintf(tickyfile,"\t\t%5.1f %5.1f %5.1f %5.1f %5.1f", ALLOC_HISTO_MAGIC(UPD_PAP));
358
359 #if 0
360   fprintf(tickyfile,"\n%7ld (%5.1f%%) data-value updates",
361         ALLOC_UPD_CON_ctr,
362         PC(INTAVG(ALLOC_UPD_CON_ctr, tot_allocs)));
363   if (ALLOC_UPD_CON_ctr != 0)
364       fprintf(tickyfile,"\t\t%5.1f %5.1f %5.1f %5.1f %5.1f", ALLOC_HISTO_MAGIC(UPD_CON));
365 #endif /* 0 */
366
367 #ifdef CONCURRENT
368   fprintf(tickyfile,"\n%7ld (%5.1f%%) stack objects",
369         ALLOC_STK_ctr,
370         PC(INTAVG(ALLOC_STK_ctr, tot_allocs)));
371   if (ALLOC_STK_ctr != 0)
372       fprintf(tickyfile,"\t\t\t%5.1f %5.1f %5.1f %5.1f %5.1f", ALLOC_HISTO_MAGIC(STK));
373   fprintf(tickyfile,"\n%7ld (%5.1f%%) thread state objects",
374         ALLOC_TSO_ctr,
375         PC(INTAVG(ALLOC_TSO_ctr, tot_allocs)));
376   if (ALLOC_TSO_ctr != 0)
377       fprintf(tickyfile,"\t\t%5.1f %5.1f %5.1f %5.1f %5.1f", ALLOC_HISTO_MAGIC(TSO));
378 #ifdef PAR
379   fprintf(tickyfile,"\n%7ld (%5.1f%%) thread state objects",
380         ALLOC_FMBQ_ctr,
381         PC(INTAVG(ALLOC_FMBQ_ctr, tot_allocs)));
382   if (ALLOC_FMBQ_ctr != 0)
383       fprintf(tickyfile,"\t\t%5.1f %5.1f %5.1f %5.1f %5.1f", ALLOC_HISTO_MAGIC(FMBQ));
384   fprintf(tickyfile,"\n%7ld (%5.1f%%) thread state objects",
385         ALLOC_FME_ctr,
386         PC(INTAVG(ALLOC_FME_ctr, tot_allocs)));
387   if (ALLOC_FME_ctr != 0)
388       fprintf(tickyfile,"\t\t%5.1f %5.1f %5.1f %5.1f %5.1f", ALLOC_HISTO_MAGIC(FME));
389   fprintf(tickyfile,"\n%7ld (%5.1f%%) thread state objects",
390         ALLOC_BF_ctr,
391         PC(INTAVG(ALLOC_BF_ctr, tot_allocs)));
392   if (ALLOC_BF_ctr != 0)
393       fprintf(tickyfile,"\t\t%5.1f %5.1f %5.1f %5.1f %5.1f", ALLOC_HISTO_MAGIC(BF));
394 #endif
395 #endif
396   fprintf(tickyfile,"\n");
397
398   fprintf(tickyfile,"\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);
399
400   fprintf(tickyfile,"\nSTACK USAGE:\n"); /* NB: some bits are direction sensitive */
401   fprintf(tickyfile,"\tA stack slots stubbed: %ld\n", A_STK_STUB_ctr);
402 /* not used at all
403   fprintf(tickyfile,"\tA stack slots re-used: %ld\n", A_STK_REUSE_ctr);
404   fprintf(tickyfile,"\tB stack slots re-used: %ld\n", B_STK_REUSE_ctr);
405 */
406 #ifndef CONCURRENT
407   fprintf(tickyfile,"\tA stack max. depth: %ld words\n",
408                 (I_) (stackInfo.botA - max_SpA));
409   fprintf(tickyfile,"\tB stack max. depth: %ld words\n",
410                 (I_) (max_SpB - stackInfo.botB));       /* And cheating, too (ToDo) */
411 #endif
412
413   fprintf(tickyfile,"\nENTERS: %ld  of which %ld (%.1f%%) direct to the entry code\n\t\t  [the rest indirected via Node's info ptr]\n",
414         tot_enters,
415         jump_direct_enters,
416         PC(INTAVG(jump_direct_enters,tot_enters)));
417   fprintf(tickyfile,"%7ld (%5.1f%%) thunks\n",
418         ENT_THK_ctr,
419         PC(INTAVG(ENT_THK_ctr,tot_enters)));
420   fprintf(tickyfile,"%7ld (%5.1f%%) data values\n",
421         ENT_CON_ctr,
422         PC(INTAVG(ENT_CON_ctr,tot_enters)));
423   fprintf(tickyfile,"%7ld (%5.1f%%) function values\n\t\t  [of which %ld (%.1f%%) bypassed arg-satisfaction chk]\n",
424         ENT_FUN_DIRECT_ctr,
425         PC(INTAVG(ENT_FUN_DIRECT_ctr,tot_enters)),
426         bypass_enters,
427         PC(INTAVG(bypass_enters,ENT_FUN_DIRECT_ctr)));
428   fprintf(tickyfile,"%7ld (%5.1f%%) partial applications\n",
429         ENT_PAP_ctr,
430         PC(INTAVG(ENT_PAP_ctr,tot_enters)));
431   fprintf(tickyfile,"%7ld (%5.1f%%) indirections\n",
432         ENT_IND_ctr,
433         PC(INTAVG(ENT_IND_ctr,tot_enters)));
434
435   fprintf(tickyfile,"\nRETURNS: %ld\n", tot_returns);
436   fprintf(tickyfile,"%7ld (%5.1f%%) in registers [the rest in the heap]\n",
437         tot_returns_in_regs,
438         PC(INTAVG(tot_returns_in_regs,tot_returns)));
439   fprintf(tickyfile,"%7ld (%5.1f%%) from entering a new constructor\n\t\t  [the rest from entering an existing constructor]\n",
440         tot_returns_of_new,
441         PC(INTAVG(tot_returns_of_new,tot_returns)));
442   fprintf(tickyfile,"%7ld (%5.1f%%) vectored [the rest unvectored]\n",
443         VEC_RETURN_ctr,
444         PC(INTAVG(VEC_RETURN_ctr,tot_returns)));
445
446   fprintf(tickyfile,"\nUPDATE FRAMES: %ld (%ld omitted from thunks)\n",
447         tot_upd_frames,
448         UPDF_OMITTED_ctr);
449   fprintf(tickyfile,"%7ld (%5.1f%%) standard frames\n",
450         UPDF_STD_PUSHED_ctr,
451         PC(INTAVG(UPDF_STD_PUSHED_ctr,tot_upd_frames)));
452   fprintf(tickyfile,"%7ld (%5.1f%%) constructor frames\n",
453         UPDF_CON_PUSHED_ctr,
454         PC(INTAVG(UPDF_CON_PUSHED_ctr,tot_upd_frames)));
455   fprintf(tickyfile,"\t\t  [of which %ld (%.1f%%) were for black-holes]\n",
456         UPDF_HOLE_PUSHED_ctr,
457         PC(INTAVG(UPDF_HOLE_PUSHED_ctr,UPDF_CON_PUSHED_ctr)));  /*DBH*/
458
459   if (UPDF_RCC_PUSHED_ctr != 0)
460      fprintf(tickyfile,"%7ld restore cost centre frames (%ld omitted)\n",
461         UPDF_RCC_PUSHED_ctr,
462         UPDF_RCC_OMITTED_ctr);
463
464   fprintf(tickyfile,"\nUPDATES: %ld\n", tot_updates);
465   fprintf(tickyfile,"%7ld (%5.1f%%) data values\n\t\t  [%ld in place, %ld allocated new space, %ld with Node]\n",
466         con_updates,
467         PC(INTAVG(con_updates,tot_updates)),
468         UPD_CON_IN_PLACE_ctr, UPD_CON_IN_NEW_ctr, UPD_CON_W_NODE_ctr);
469   fprintf(tickyfile,"%7ld (%5.1f%%) partial applications\n\t\t  [%ld in place, %ld allocated new space]\n",
470         pap_updates,
471         PC(INTAVG(pap_updates,tot_updates)),
472         UPD_PAP_IN_PLACE_ctr, UPD_PAP_IN_NEW_ctr);
473   fprintf(tickyfile,"%7ld (%5.1f%%) updates to existing heap objects\n",
474         UPD_EXISTING_ctr,
475         PC(INTAVG(UPD_EXISTING_ctr,tot_updates)));
476   fprintf(tickyfile,"%7ld (%5.1f%%) in-place updates copied\n",
477         UPD_IN_PLACE_COPY_ctr,
478         PC(INTAVG(UPD_IN_PLACE_COPY_ctr,tot_in_place_updates)));
479   if (UPD_ENTERED_ctr != 0) {
480       fprintf(tickyfile,"%7ld (%5.1f%%) subsequently entered\n",
481               UPD_ENTERED_ctr,
482               PC(INTAVG(UPD_ENTERED_ctr,tot_updates)));
483       fprintf(tickyfile,"%7ld (%5.1f%%) subsequently entered more than once\n",
484               UPD_ENTERED_AGAIN_ctr,
485               PC(INTAVG(UPD_ENTERED_AGAIN_ctr,tot_updates)));
486   }
487
488   if (tot_gengc_updates != 0) {
489       fprintf(tickyfile,"\nNEW GEN UPDATES: %ld (%5.1f%%)\n",
490               tot_new_updates,
491               PC(INTAVG(tot_new_updates,tot_gengc_updates)));
492       fprintf(tickyfile,"%7ld (%5.1f%%) indirections\n",
493               UPD_NEW_IND_ctr,
494               PC(INTAVG(UPD_NEW_IND_ctr,tot_gengc_updates)));
495       fprintf(tickyfile,"%7ld (%5.1f%%) inplace with ptrs\n",
496               UPD_NEW_IN_PLACE_PTRS_ctr,
497               PC(INTAVG(UPD_NEW_IN_PLACE_PTRS_ctr,tot_gengc_updates)));
498       fprintf(tickyfile,"%7ld (%5.1f%%) inplace without ptrs\n",
499               UPD_NEW_IN_PLACE_NOPTRS_ctr,
500               PC(INTAVG(UPD_NEW_IN_PLACE_NOPTRS_ctr,tot_gengc_updates)));
501       fprintf(tickyfile,"\nOLD GEN UPDATES: %ld (%5.1f%%)\n",
502               tot_old_updates,
503               PC(INTAVG(tot_old_updates,tot_gengc_updates)));
504       fprintf(tickyfile,"%7ld (%5.1f%%) indirections\n",
505               UPD_OLD_IND_ctr,
506               PC(INTAVG(UPD_OLD_IND_ctr,tot_gengc_updates)));
507       fprintf(tickyfile,"%7ld (%5.1f%%) inplace with ptrs\n",
508               UPD_OLD_IN_PLACE_PTRS_ctr,
509               PC(INTAVG(UPD_OLD_IN_PLACE_PTRS_ctr,tot_gengc_updates)));
510       fprintf(tickyfile,"%7ld (%5.1f%%) inplace without ptrs\n",
511               UPD_OLD_IN_PLACE_NOPTRS_ctr,
512               PC(INTAVG(UPD_OLD_IN_PLACE_NOPTRS_ctr,tot_gengc_updates)));
513   }
514
515   printRegisteredCounterInfo();
516
517   fprintf(tickyfile,"\n**************************************************\n");
518   fprintf(tickyfile,"%6ld  ALLOC_HEAP_ctr\n",   ALLOC_HEAP_ctr);
519   fprintf(tickyfile,"%6ld  ALLOC_HEAP_tot\n",   ALLOC_HEAP_tot);
520
521 #ifndef CONCURRENT
522   fprintf(tickyfile,"%6ld  HWM_SpA\n",          (I_) (stackInfo.botA - max_SpA));
523   fprintf(tickyfile,"%6ld  HWM_SpB\n",          (I_) (max_SpB - stackInfo.botB));
524 #endif
525
526   fprintf(tickyfile,"%6ld  ALLOC_FUN_ctr\n",    ALLOC_FUN_ctr);
527   fprintf(tickyfile,"%6ld  ALLOC_FUN_adm\n",    ALLOC_FUN_adm);
528   fprintf(tickyfile,"%6ld  ALLOC_FUN_gds\n",    ALLOC_FUN_gds);
529   fprintf(tickyfile,"%6ld  ALLOC_FUN_slp\n",    ALLOC_FUN_slp);
530   fprintf(tickyfile,"%6ld  ALLOC_THK_ctr\n",    ALLOC_THK_ctr);
531   fprintf(tickyfile,"%6ld  ALLOC_THK_adm\n",    ALLOC_THK_adm);
532   fprintf(tickyfile,"%6ld  ALLOC_THK_gds\n",    ALLOC_THK_gds);
533   fprintf(tickyfile,"%6ld  ALLOC_THK_slp\n",    ALLOC_THK_slp);
534   fprintf(tickyfile,"%6ld  ALLOC_CON_ctr\n",    ALLOC_CON_ctr);
535   fprintf(tickyfile,"%6ld  ALLOC_CON_adm\n",    ALLOC_CON_adm);
536   fprintf(tickyfile,"%6ld  ALLOC_CON_gds\n",    ALLOC_CON_gds);
537   fprintf(tickyfile,"%6ld  ALLOC_CON_slp\n",    ALLOC_CON_slp);
538   fprintf(tickyfile,"%6ld  ALLOC_TUP_ctr\n",    ALLOC_TUP_ctr);
539   fprintf(tickyfile,"%6ld  ALLOC_TUP_adm\n",    ALLOC_TUP_adm);
540   fprintf(tickyfile,"%6ld  ALLOC_TUP_gds\n",    ALLOC_TUP_gds);
541   fprintf(tickyfile,"%6ld  ALLOC_TUP_slp\n",    ALLOC_TUP_slp);
542   fprintf(tickyfile,"%6ld  ALLOC_BH_ctr\n",             ALLOC_BH_ctr);
543   fprintf(tickyfile,"%6ld  ALLOC_BH_adm\n",             ALLOC_BH_adm);
544   fprintf(tickyfile,"%6ld  ALLOC_BH_gds\n",             ALLOC_BH_gds);
545   fprintf(tickyfile,"%6ld  ALLOC_BH_slp\n",             ALLOC_BH_slp);
546 /*
547   fprintf(tickyfile,"%6ld  ALLOC_PAP_ctr\n",    ALLOC_PAP_ctr);
548   fprintf(tickyfile,"%6ld  ALLOC_PAP_adm\n",    ALLOC_PAP_adm);
549   fprintf(tickyfile,"%6ld  ALLOC_PAP_gds\n",    ALLOC_PAP_gds);
550   fprintf(tickyfile,"%6ld  ALLOC_PAP_slp\n",    ALLOC_PAP_slp);
551 */
552   fprintf(tickyfile,"%6ld  ALLOC_PRIM_ctr\n",   ALLOC_PRIM_ctr);
553   fprintf(tickyfile,"%6ld  ALLOC_PRIM_adm\n",   ALLOC_PRIM_adm);
554   fprintf(tickyfile,"%6ld  ALLOC_PRIM_gds\n",   ALLOC_PRIM_gds);
555   fprintf(tickyfile,"%6ld  ALLOC_PRIM_slp\n",   ALLOC_PRIM_slp);
556 /*
557   fprintf(tickyfile,"%6ld  ALLOC_UPD_CON_ctr\n",        ALLOC_UPD_CON_ctr);
558   fprintf(tickyfile,"%6ld  ALLOC_UPD_CON_adm\n",        ALLOC_UPD_CON_adm);
559   fprintf(tickyfile,"%6ld  ALLOC_UPD_CON_gds\n",        ALLOC_UPD_CON_gds);
560   fprintf(tickyfile,"%6ld  ALLOC_UPD_CON_slp\n",        ALLOC_UPD_CON_slp);
561 */
562   fprintf(tickyfile,"%6ld  ALLOC_UPD_PAP_ctr\n",        ALLOC_UPD_PAP_ctr);
563   fprintf(tickyfile,"%6ld  ALLOC_UPD_PAP_adm\n",        ALLOC_UPD_PAP_adm);
564   fprintf(tickyfile,"%6ld  ALLOC_UPD_PAP_gds\n",        ALLOC_UPD_PAP_gds);
565   fprintf(tickyfile,"%6ld  ALLOC_UPD_PAP_slp\n",        ALLOC_UPD_PAP_slp);
566
567 #ifdef CONCURRENT
568   fprintf(tickyfile,"%6ld  ALLOC_STK_ctr\n",    ALLOC_STK_ctr);
569   fprintf(tickyfile,"%6ld  ALLOC_STK_adm\n",    ALLOC_STK_adm);
570   fprintf(tickyfile,"%6ld  ALLOC_STK_gds\n",    ALLOC_STK_gds);
571   fprintf(tickyfile,"%6ld  ALLOC_STK_slp\n",    ALLOC_STK_slp);
572   fprintf(tickyfile,"%6ld  ALLOC_TSO_ctr\n",    ALLOC_TSO_ctr);
573   fprintf(tickyfile,"%6ld  ALLOC_TSO_adm\n",    ALLOC_TSO_adm);
574   fprintf(tickyfile,"%6ld  ALLOC_TSO_gds\n",    ALLOC_TSO_gds);
575   fprintf(tickyfile,"%6ld  ALLOC_TSO_slp\n",    ALLOC_TSO_slp);
576 #ifdef PAR
577   fprintf(tickyfile,"%6ld  ALLOC_FMBQ_ctr\n",   ALLOC_FMBQ_ctr);
578   fprintf(tickyfile,"%6ld  ALLOC_FMBQ_adm\n",   ALLOC_FMBQ_adm);
579   fprintf(tickyfile,"%6ld  ALLOC_FMBQ_gds\n",   ALLOC_FMBQ_gds);
580   fprintf(tickyfile,"%6ld  ALLOC_FMBQ_slp\n",   ALLOC_FMBQ_slp);
581   fprintf(tickyfile,"%6ld  ALLOC_FME_ctr\n",    ALLOC_FME_ctr);
582   fprintf(tickyfile,"%6ld  ALLOC_FME_adm\n",    ALLOC_FME_adm);
583   fprintf(tickyfile,"%6ld  ALLOC_FME_gds\n",    ALLOC_FME_gds);
584   fprintf(tickyfile,"%6ld  ALLOC_FME_slp\n",    ALLOC_FME_slp);
585   fprintf(tickyfile,"%6ld  ALLOC_BF_ctr\n",     ALLOC_BF_ctr);
586   fprintf(tickyfile,"%6ld  ALLOC_BF_adm\n",     ALLOC_BF_adm);
587   fprintf(tickyfile,"%6ld  ALLOC_BF_gds\n",     ALLOC_BF_gds);
588   fprintf(tickyfile,"%6ld  ALLOC_BF_slp\n",     ALLOC_BF_slp);
589 #endif
590 #endif
591
592   fprintf(tickyfile,"%6ld  ENT_VIA_NODE_ctr\n", ENT_VIA_NODE_ctr);
593   fprintf(tickyfile,"%6ld  ENT_CON_ctr\n",              ENT_CON_ctr);
594   fprintf(tickyfile,"%6ld  ENT_FUN_STD_ctr\n",  ENT_FUN_STD_ctr);
595   fprintf(tickyfile,"%6ld  ENT_FUN_DIRECT_ctr\n",       ENT_FUN_DIRECT_ctr);
596   fprintf(tickyfile,"%6ld  ENT_IND_ctr\n",              ENT_IND_ctr);
597   fprintf(tickyfile,"%6ld  ENT_PAP_ctr\n",              ENT_PAP_ctr);
598   fprintf(tickyfile,"%6ld  ENT_THK_ctr\n",              ENT_THK_ctr);
599
600   fprintf(tickyfile,"%6ld  RET_NEW_IN_HEAP_ctr\n",      RET_NEW_IN_HEAP_ctr);
601   fprintf(tickyfile,"%6ld  RET_NEW_IN_REGS_ctr\n",      RET_NEW_IN_REGS_ctr);
602   fprintf(tickyfile,"%6ld  RET_OLD_IN_HEAP_ctr\n",      RET_OLD_IN_HEAP_ctr);
603   fprintf(tickyfile,"%6ld  RET_OLD_IN_REGS_ctr\n",      RET_OLD_IN_REGS_ctr);
604   fprintf(tickyfile,"%6ld  RET_SEMI_BY_DEFAULT_ctr\n",  RET_SEMI_BY_DEFAULT_ctr);
605   fprintf(tickyfile,"%6ld  RET_SEMI_IN_HEAP_ctr\n",     RET_SEMI_IN_HEAP_ctr);
606   fprintf(tickyfile,"%6ld  RET_SEMI_IN_REGS_ctr\n",     RET_SEMI_IN_REGS_ctr);
607   fprintf(tickyfile,"%6ld  VEC_RETURN_ctr\n",   VEC_RETURN_ctr);
608
609   fprintf(tickyfile,"%6ld  UPDF_OMITTED_ctr\n", UPDF_OMITTED_ctr);
610   fprintf(tickyfile,"%6ld  UPDF_STD_PUSHED_ctr\n",      UPDF_STD_PUSHED_ctr);
611   fprintf(tickyfile,"%6ld  UPDF_CON_PUSHED_ctr\n",      UPDF_CON_PUSHED_ctr);
612   fprintf(tickyfile,"%6ld  UPDF_HOLE_PUSHED_ctr\n",     UPDF_HOLE_PUSHED_ctr);
613
614   fprintf(tickyfile,"%6ld  UPDF_RCC_PUSHED_ctr\n",      UPDF_RCC_PUSHED_ctr);
615   fprintf(tickyfile,"%6ld  UPDF_RCC_OMITTED_ctr\n",     UPDF_RCC_OMITTED_ctr);
616
617   fprintf(tickyfile,"%6ld  UPD_EXISTING_ctr\n",         UPD_EXISTING_ctr);
618   fprintf(tickyfile,"%6ld  UPD_CON_W_NODE_ctr\n",       UPD_CON_W_NODE_ctr);
619   fprintf(tickyfile,"%6ld  UPD_CON_IN_PLACE_ctr\n",     UPD_CON_IN_PLACE_ctr);
620   fprintf(tickyfile,"%6ld  UPD_CON_IN_NEW_ctr\n",       UPD_CON_IN_NEW_ctr);
621   fprintf(tickyfile,"%6ld  UPD_PAP_IN_PLACE_ctr\n",     UPD_PAP_IN_PLACE_ctr);
622   fprintf(tickyfile,"%6ld  UPD_PAP_IN_NEW_ctr\n",       UPD_PAP_IN_NEW_ctr);
623   fprintf(tickyfile,"%6ld  UPD_ENTERED_ctr\n",  UPD_ENTERED_ctr);
624   fprintf(tickyfile,"%6ld  UPD_ENTERED_AGAIN_ctr\n",UPD_ENTERED_AGAIN_ctr);
625
626   fprintf(tickyfile,"%6ld  UPD_NEW_IND_ctr\n",          UPD_NEW_IND_ctr);
627   fprintf(tickyfile,"%6ld  UPD_NEW_IN_PLACE_PTRS_ctr\n",        UPD_NEW_IN_PLACE_PTRS_ctr);
628   fprintf(tickyfile,"%6ld  UPD_NEW_IN_PLACE_NOPTRS_ctr\n",      UPD_NEW_IN_PLACE_NOPTRS_ctr);
629   fprintf(tickyfile,"%6ld  UPD_OLD_IND_ctr\n",          UPD_OLD_IND_ctr);
630   fprintf(tickyfile,"%6ld  UPD_OLD_IN_PLACE_PTRS_ctr\n",        UPD_OLD_IN_PLACE_PTRS_ctr);
631   fprintf(tickyfile,"%6ld  UPD_OLD_IN_PLACE_NOPTRS_ctr\n",      UPD_OLD_IN_PLACE_NOPTRS_ctr);
632 }
633 \end{code}
634
635 %************************************************************************
636 %*                                                                      *
637 \subsection[RednCounts-ent-counters]{Handle named entry counters}
638 %*                                                                      *
639 %************************************************************************
640
641 Data structure used in ``registering'' one of these counters.
642 \begin{code}
643 struct ent_counter *ListOfEntryCtrs = NULL; /* root of list of them */
644 \end{code}
645
646 To print out all the registered-counter info:
647 \begin{code}
648 void
649 printRegisteredCounterInfo ( STG_NO_ARGS )
650 {
651     struct ent_counter *p;
652
653     if ( ListOfEntryCtrs != NULL ) {
654         fprintf(tickyfile,"\n**************************************************\n");
655     }
656
657     for (p = ListOfEntryCtrs; p != NULL; p = p->link) {
658         /* common stuff first; then the wrapper info if avail */
659         fprintf(tickyfile, "%-40s%u\t%u\t%u\t%-16s%ld",
660                 p->f_str,
661                 p->arity,
662                 p->Astk_args,
663                 p->Bstk_args,
664                 p->f_arg_kinds,
665                 p->ctr);
666
667         if ( p->wrap_str == NULL ) {
668             fprintf(tickyfile, "\n");
669
670         } else {
671             fprintf(tickyfile, "\t%s\t%s\n",
672                 p->wrap_str,
673                 p->wrap_arg_kinds);
674         }
675     }
676 }
677 \end{code}
678
679 That's all, folks.
680 \begin{code}
681 #endif /* DO_REDN_COUNTING */
682 \end{code}