2a40b363ed89cd358bc8295ca5dad48d88a6bb2f
[cacao.git] / src / vmcore / statistics.c
1 /* src/vmcore/statistics.c - global varables for statistics
2
3    Copyright (C) 1996-2005, 2006, 2007 R. Grafl, A. Krall, C. Kruegel,
4    C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
5    E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
6    J. Wenninger, Institut f. Computersprachen - TU Wien
7
8    This file is part of CACAO.
9
10    This program is free software; you can redistribute it and/or
11    modify it under the terms of the GNU General Public License as
12    published by the Free Software Foundation; either version 2, or (at
13    your option) any later version.
14
15    This program is distributed in the hope that it will be useful, but
16    WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18    General Public License for more details.
19
20    You should have received a copy of the GNU General Public License
21    along with this program; if not, write to the Free Software
22    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23    02110-1301, USA.
24
25    $Id: statistics.c 8199 2007-07-13 00:39:49Z michi $
26
27 */
28
29
30 #include "config.h"
31
32 #include <string.h> 
33
34 #if defined(HAVE_TIME_H)
35 # include <time.h>
36 #endif
37
38 #if defined(HAVE_SYS_TIME_H)
39 # include <sys/time.h>
40 #endif
41
42 #if defined(HAVE_SYS_RESOURCE_H)
43 # include <sys/resource.h>
44 #endif
45
46 #include "vm/types.h"
47
48 #include "mm/gc-common.h"
49
50 #include "toolbox/logging.h"
51
52 #include "vm/global.h"
53
54 #include "vm/jit/code.h"
55
56 #include "vmcore/class.h"
57 #include "vmcore/field.h"
58 #include "vmcore/method.h"
59 #include "vmcore/options.h"
60 #include "vmcore/statistics.h"
61
62
63 /* global variables ***********************************************************/
64
65 static s8 loadingtime = 0;              /* accumulated loading time           */
66 static s8 loadingstarttime = 0;
67 static s8 loadingstoptime = 0;
68 static s4 loadingtime_recursion = 0;
69
70 static s8 compilingtime = 0;            /* accumulated compile time           */
71 static s8 compilingstarttime = 0;
72 static s8 compilingstoptime = 0;
73 static s4 compilingtime_recursion = 0;
74
75 s4 codememusage = 0;
76 s4 maxcodememusage = 0;
77
78 s4 memoryusage = 0;
79 s4 maxmemusage = 0;
80
81 s4 maxdumpsize = 0;
82
83 s4 globalallocateddumpsize = 0;
84 s4 globaluseddumpsize = 0;
85
86
87 /* variables for measurements *************************************************/
88
89 s4 size_classinfo        = 0;
90 s4 size_fieldinfo        = 0;
91 s4 size_methodinfo       = 0;
92 s4 size_lineinfo         = 0;
93 s4 size_codeinfo         = 0;
94
95 s4 size_stub_native      = 0;
96
97 s4 size_stack_map        = 0;
98 s4 size_string           = 0;
99
100 s4 size_threadobject     = 0;
101
102 s4 size_lock_record      = 0;
103 s4 size_lock_hashtable   = 0;
104 s4 size_lock_waiter      = 0;
105
106 s4 size_patchref         = 0;
107
108 u8 count_calls_java_to_native = 0;
109 u8 count_calls_native_to_java = 0;
110
111 int count_const_pool_len = 0;
112 int count_classref_len = 0;
113 int count_parsed_desc_len = 0;
114 int count_vftbl_len = 0;
115 int count_all_methods = 0;
116 int count_methods_marked_used = 0;  /* RTA */
117
118 int count_vmcode_len = 0;
119 int count_extable_len = 0;
120 int count_class_loads = 0;
121 int count_class_inits = 0;
122
123 int count_utf_len = 0;                  /* size of utf hash                   */
124 int count_utf_new = 0;                  /* calls of utf_new                   */
125 int count_utf_new_found  = 0;           /* calls of utf_new with fast return  */
126
127 int count_locals_conflicts = 0;         /* register allocator statistics */
128 int count_locals_spilled = 0;
129 int count_locals_register = 0;
130 int count_ss_spilled = 0;
131 int count_ss_register = 0;
132 int count_methods_allocated_by_lsra = 0;
133 int count_mem_move_bb = 0;
134 int count_interface_size = 0;
135 int count_argument_mem_ss = 0;
136 int count_argument_reg_ss = 0;
137 int count_method_in_register = 0;
138 int count_mov_reg_reg = 0;
139 int count_mov_mem_reg = 0;
140 int count_mov_reg_mem = 0;
141 int count_mov_mem_mem = 0;
142
143 int count_jit_calls = 0;
144 int count_methods = 0;
145 int count_spills_read_ila = 0;
146 int count_spills_read_flt = 0;
147 int count_spills_read_dbl = 0;
148 int count_spills_write_ila = 0;
149 int count_spills_write_flt = 0;
150 int count_spills_write_dbl = 0;
151 int count_pcmd_activ = 0;
152 int count_pcmd_drop = 0;
153 int count_pcmd_zero = 0;
154 int count_pcmd_const_store = 0;
155 int count_pcmd_const_alu = 0;
156 int count_pcmd_const_bra = 0;
157 int count_pcmd_load = 0;
158 int count_pcmd_move = 0;
159 int count_load_instruction = 0;
160 int count_pcmd_store = 0;
161 int count_pcmd_store_comb = 0;
162 int count_dup_instruction = 0;
163 int count_pcmd_op = 0;
164 int count_pcmd_mem = 0;
165 int count_pcmd_met = 0;
166 int count_pcmd_bra = 0;
167 int count_pcmd_table = 0;
168 int count_pcmd_return = 0;
169 int count_pcmd_returnx = 0;
170 int count_check_null = 0;
171 int count_check_bound = 0;
172 int count_max_basic_blocks = 0;
173 int count_basic_blocks = 0;
174 int count_javainstr = 0;
175 int count_max_javainstr = 0;
176 int count_javacodesize = 0;
177 int count_javaexcsize = 0;
178 int count_calls = 0;
179 int count_tryblocks = 0;
180 int count_code_len = 0;
181 int count_data_len = 0;
182 int count_cstub_len = 0;
183 int count_max_new_stack = 0;
184 int count_upper_bound_new_stack = 0;
185
186 int count_emit_branch = 0;
187 int count_emit_branch_8bit = 0;
188 int count_emit_branch_16bit = 0;
189 int count_emit_branch_32bit = 0;
190 int count_emit_branch_64bit = 0;
191
192 s4 count_branches_resolved   = 0;
193 s4 count_branches_unresolved = 0;
194
195 u8 count_jni_callXmethod_calls=0;
196 u8 count_jni_calls=0;
197
198
199 static int count_block_stack_init[11] = {
200         0, 0, 0, 0, 0, 
201         0, 0, 0, 0, 0, 
202         0
203 };
204 int *count_block_stack = count_block_stack_init;
205 static int count_analyse_iterations_init[5] = {
206         0, 0, 0, 0, 0
207 };
208 int *count_analyse_iterations = count_analyse_iterations_init;
209 static int count_method_bb_distribution_init[9] = {
210         0, 0, 0, 0, 0,
211         0, 0, 0, 0
212 };
213 int *count_method_bb_distribution = count_method_bb_distribution_init;
214 static int count_block_size_distribution_init[18] = {
215         0, 0, 0, 0, 0,
216         0, 0, 0, 0, 0,
217         0, 0, 0, 0, 0,
218         0, 0, 0
219 };
220 int *count_block_size_distribution = count_block_size_distribution_init;
221 static int count_store_length_init[21] = {
222         0, 0, 0, 0, 0,
223         0, 0, 0, 0, 0,
224         0, 0, 0, 0, 0,
225         0, 0, 0, 0, 0,
226         0
227 };
228 int *count_store_length = count_store_length_init;
229 static int count_store_depth_init[11] = {
230         0, 0, 0, 0, 0,
231         0, 0, 0, 0, 0,
232         0
233 };
234 int *count_store_depth = count_store_depth_init;
235
236
237 /* instruction scheduler statistics *******************************************/
238
239 s4 count_schedule_basic_blocks = 0;
240 s4 count_schedule_nodes = 0;
241 s4 count_schedule_leaders = 0;
242 s4 count_schedule_max_leaders = 0;
243 s4 count_schedule_critical_path = 0;
244
245
246 /* jnicallXmethodinvokation ***************************************************
247
248    increments the jni CallXMethod invokation count by one
249         
250 *******************************************************************************/
251
252 void jnicallXmethodnvokation(void)
253 {
254         /* XXX do locking here */
255         count_jni_callXmethod_calls++;
256 }
257
258
259 /* jniinvokation *************************************************************
260
261    increments the jni overall  invokation count by one
262         
263 *******************************************************************************/
264
265 void jniinvokation(void)
266 {
267         /* XXX do locking here */
268         count_jni_calls++;
269 }
270
271
272 /* getcputime *********************************** ******************************
273
274    Returns the used CPU time in microseconds
275         
276 *******************************************************************************/
277
278 s8 getcputime(void)
279 {
280 #if defined(HAVE_GETRUSAGE)
281         struct rusage ru;
282         int sec, usec;
283
284         getrusage(RUSAGE_SELF, &ru);
285
286         sec  = ru.ru_utime.tv_sec + ru.ru_stime.tv_sec;
287         usec = ru.ru_utime.tv_usec + ru.ru_stime.tv_usec;
288
289         return sec * 1000000 + usec;
290 #else
291         /* If we don't have getrusage, simply return 0. */
292
293         return 0;
294 #endif
295 }
296
297
298 /* loadingtime_stop ************************************************************
299
300    XXX
301
302 *******************************************************************************/
303
304 void loadingtime_start(void)
305 {
306         loadingtime_recursion++;
307
308         if (loadingtime_recursion == 1)
309                 loadingstarttime = getcputime();
310 }
311
312
313 /* loadingtime_stop ************************************************************
314
315    XXX
316
317 *******************************************************************************/
318
319 void loadingtime_stop(void)
320 {
321         if (loadingtime_recursion == 1) {
322                 loadingstoptime = getcputime();
323                 loadingtime += (loadingstoptime - loadingstarttime);
324         }
325
326         loadingtime_recursion--;
327 }
328
329
330 /* compilingtime_stop **********************************************************
331
332    XXX
333
334 *******************************************************************************/
335
336 void compilingtime_start(void)
337 {
338         compilingtime_recursion++;
339
340         if (compilingtime_recursion == 1)
341                 compilingstarttime = getcputime();
342 }
343
344
345 /* compilingtime_stop **********************************************************
346
347    XXX
348
349 *******************************************************************************/
350
351 void compilingtime_stop(void)
352 {
353         if (compilingtime_recursion == 1) {
354                 compilingstoptime = getcputime();
355                 compilingtime += (compilingstoptime - compilingstarttime);
356         }
357
358         compilingtime_recursion--;
359 }
360
361
362 /* print_times *****************************************************************
363
364    Prints a summary of CPU time usage.
365
366 *******************************************************************************/
367
368 void print_times(void)
369 {
370         s8 totaltime;
371         s8 runtime;
372
373         totaltime = getcputime();
374         runtime = totaltime - loadingtime - compilingtime;
375
376 #if SIZEOF_VOID_P == 8
377         dolog("Time for loading classes: %6ld ms", loadingtime / 1000);
378         dolog("Time for compiling code:  %6ld ms", compilingtime / 1000);
379         dolog("Time for running program: %6ld ms", runtime / 1000);
380         dolog("Total time:               %6ld ms", totaltime / 1000);
381 #else
382         dolog("Time for loading classes: %6lld ms", loadingtime / 1000);
383         dolog("Time for compiling code:  %6lld ms", compilingtime / 1000);
384         dolog("Time for running program: %6lld ms", runtime / 1000);
385         dolog("Total time:               %6lld ms", totaltime / 1000);
386 #endif
387 }
388
389
390 /* print_stats *****************************************************************
391
392    outputs detailed compiler statistics
393
394 *******************************************************************************/
395
396 void print_stats(void)
397 {
398         s4    i;
399         float f;
400         s4    sum;
401
402
403         dolog("Number of JIT compiler calls: %6d", count_jit_calls);
404         dolog("Number of compiled methods:   %6d", count_methods);
405
406         dolog("Number of compiled basic blocks:               %6d",
407                   count_basic_blocks);
408         dolog("Number of max. basic blocks per method:        %6d",
409                   count_max_basic_blocks);
410
411         dolog("Number of compiled JavaVM instructions:        %6d",
412                   count_javainstr);
413         dolog("Number of max. JavaVM instructions per method: %6d",
414                   count_max_javainstr);
415         dolog("Size of compiled JavaVM instructions:          %6d(%d)",
416                   count_javacodesize, count_javacodesize - count_methods * 18);
417
418         dolog("Size of compiled Exception Tables:      %d", count_javaexcsize);
419         dolog("Number of Machine-Instructions: %d", count_code_len >> 2);
420         dolog("Number of Spills (write to memory) <all [i/l/a|flt|dbl]>: %d [%d|%d|%d]",
421                 count_spills_write_ila + count_spills_write_flt + count_spills_write_dbl,
422                 count_spills_write_ila, count_spills_write_flt, count_spills_write_dbl);
423         dolog("Number of Spills (read from memory) <all [i/l/a|flt|dbl]>: %d [%d|%d|%d]",
424                 count_spills_read_ila + count_spills_read_flt + count_spills_read_dbl,
425                 count_spills_read_ila, count_spills_read_flt, count_spills_read_dbl);
426         dolog("Number of Activ    Pseudocommands: %6d", count_pcmd_activ);
427         dolog("Number of Drop     Pseudocommands: %6d", count_pcmd_drop);
428         dolog("Number of Const    Pseudocommands: %6d (zero:%5d)",
429                   count_pcmd_load, count_pcmd_zero);
430         dolog("Number of ConstAlu Pseudocommands: %6d (cmp: %5d, store:%5d)",
431                   count_pcmd_const_alu, count_pcmd_const_bra, count_pcmd_const_store);
432         dolog("Number of Move     Pseudocommands: %6d", count_pcmd_move);
433         dolog("Number of Load     Pseudocommands: %6d", count_load_instruction);
434         dolog("Number of Store    Pseudocommands: %6d (combined: %5d)",
435                   count_pcmd_store, count_pcmd_store - count_pcmd_store_comb);
436         dolog("Number of OP       Pseudocommands: %6d", count_pcmd_op);
437         dolog("Number of DUP      Pseudocommands: %6d", count_dup_instruction);
438         dolog("Number of Mem      Pseudocommands: %6d", count_pcmd_mem);
439         dolog("Number of Method   Pseudocommands: %6d", count_pcmd_met);
440         dolog("Number of Branch   Pseudocommands: %6d (rets:%5d, Xrets: %5d)",
441                   count_pcmd_bra, count_pcmd_return, count_pcmd_returnx);
442         log_println("                resolved branches: %6d", count_branches_resolved);
443         log_println("              unresolved branches: %6d", count_branches_unresolved);
444         dolog("Number of Table    Pseudocommands: %6d", count_pcmd_table);
445         dolog("Number of Useful   Pseudocommands: %6d", count_pcmd_table +
446                   count_pcmd_bra + count_pcmd_load + count_pcmd_mem + count_pcmd_op);
447         dolog("Number of Null Pointer Checks:     %6d", count_check_null);
448         dolog("Number of Array Bound Checks:      %6d", count_check_bound);
449         dolog("Number of Try-Blocks: %d", count_tryblocks);
450
451         dolog("Number of branch_emit (total, 8bit/16bit/32bit/64bit offset): %d, %d/%d/%d/%d",
452                 count_emit_branch,  count_emit_branch_8bit,  count_emit_branch_16bit, 
453                                                         count_emit_branch_32bit, count_emit_branch_64bit);
454
455         dolog("Maximal count of stack elements:   %d", count_max_new_stack);
456         dolog("Upper bound of max stack elements: %d", count_upper_bound_new_stack);
457         dolog("Distribution of stack sizes at block boundary");
458         dolog("     0     1     2     3     4     5     6     7     8     9  >=10");
459         dolog("%6d%6d%6d%6d%6d%6d%6d%6d%6d%6d%6d",
460                   count_block_stack[0], count_block_stack[1], count_block_stack[2],
461                   count_block_stack[3], count_block_stack[4], count_block_stack[5],
462                   count_block_stack[6], count_block_stack[7], count_block_stack[8],
463                   count_block_stack[9], count_block_stack[10]);
464         dolog("Distribution of store stack depth");
465         dolog("     0     1     2     3     4     5     6     7     8     9  >=10");
466         dolog("%6d%6d%6d%6d%6d%6d%6d%6d%6d%6d%6d",
467                   count_store_depth[0], count_store_depth[1], count_store_depth[2],
468                   count_store_depth[3], count_store_depth[4], count_store_depth[5],
469                   count_store_depth[6], count_store_depth[7], count_store_depth[8],
470                   count_store_depth[9], count_store_depth[10]);
471         dolog("Distribution of store creator chains first part");
472         dolog("     0     1     2     3     4     5     6     7     8     9");
473         dolog("%6d%6d%6d%6d%6d%6d%6d%6d%6d%6d",
474                   count_store_length[0], count_store_length[1], count_store_length[2],
475                   count_store_length[3], count_store_length[4], count_store_length[5],
476                   count_store_length[6], count_store_length[7], count_store_length[8],
477                   count_store_length[9]);
478         dolog("Distribution of store creator chains second part");
479         dolog("    10    11    12    13    14    15    16    17    18    19  >=20");
480         dolog("%6d%6d%6d%6d%6d%6d%6d%6d%6d%6d%6d",
481                   count_store_length[10], count_store_length[11],
482                   count_store_length[12], count_store_length[13],
483                   count_store_length[14], count_store_length[15],
484                   count_store_length[16], count_store_length[17],
485                   count_store_length[18], count_store_length[19],
486                   count_store_length[20]);
487         dolog("Distribution of analysis iterations");
488         dolog("     1     2     3     4   >=5");
489         dolog("%6d%6d%6d%6d%6d",
490                   count_analyse_iterations[0], count_analyse_iterations[1],
491                   count_analyse_iterations[2], count_analyse_iterations[3],
492                   count_analyse_iterations[4]);
493
494
495         /* Distribution of basic blocks per method ********************************/
496
497         log_println("Distribution of basic blocks per method:");
498         log_println("   <=5  <=10  <=15  <=20  <=30  <=40  <=50  <=75   >75");
499
500         log_start();
501         for (i = 0; i <= 8; i++)
502                 log_print("%6d", count_method_bb_distribution[i]);
503         log_finish();
504
505         /* print ratio */
506
507         f = (float) count_methods;
508
509         log_start();
510         for (i = 0; i <= 8; i++)
511                 log_print("%6.2f", (float) count_method_bb_distribution[i] / f);
512         log_finish();
513
514         /* print cumulated ratio */
515
516         log_start();
517         for (i = 0, sum = 0; i <= 8; i++) {
518                 sum += count_method_bb_distribution[i];
519                 log_print("%6.2f", (float) sum / f);
520         }
521         log_finish();
522
523
524         /* Distribution of basic block sizes **************************************/
525
526         log_println("Distribution of basic block sizes:");
527         log_println("     0     1     2     3     4     5     6     7     8     9   <13   <15   <17   <19   <21   <26   <31   >30");
528
529         /* print block sizes */
530
531         log_start();
532         for (i = 0; i <= 17; i++)
533                 log_print("%6d", count_block_size_distribution[i]);
534         log_finish();
535
536         /* print ratio */
537
538         f = (float) count_basic_blocks;
539
540         log_start();
541         for (i = 0; i <= 17; i++)
542                 log_print("%6.2f", (float) count_block_size_distribution[i] / f);
543         log_finish();
544
545         /* print cumulated ratio */
546
547         log_start();
548         for (i = 0, sum = 0; i <= 17; i++) {
549                 sum += count_block_size_distribution[i];
550                 log_print("%6.2f", (float) sum / f);
551         }
552         log_finish();
553
554         statistics_print_memory_usage();
555
556         dolog("Number of class loads:    %6d", count_class_loads);
557         dolog("Number of class inits:    %6d", count_class_inits);
558         dolog("Number of loaded Methods: %6d\n", count_all_methods);
559
560         dolog("Calls of utf_new:                 %6d", count_utf_new);
561         dolog("Calls of utf_new (element found): %6d\n", count_utf_new_found);
562
563
564         /* LSRA statistics ********************************************************/
565
566         dolog("Moves reg -> reg:     %6d", count_mov_reg_reg);
567         dolog("Moves mem -> reg:     %6d", count_mov_mem_reg);
568         dolog("Moves reg -> mem:     %6d", count_mov_reg_mem);
569         dolog("Moves mem -> mem:     %6d", count_mov_mem_mem);
570
571         dolog("Methods allocated by LSRA:         %6d",
572                   count_methods_allocated_by_lsra);
573         dolog("Conflicts between local Variables: %6d", count_locals_conflicts);
574         dolog("Local Variables held in Memory:    %6d", count_locals_spilled);
575         dolog("Local Variables held in Registers: %6d", count_locals_register);
576         dolog("Stackslots held in Memory:         %6d", count_ss_spilled);
577         dolog("Stackslots held in Registers:      %6d", count_ss_register);
578         dolog("Memory moves at BB Boundaries:     %6d", count_mem_move_bb);
579         dolog("Number of interface slots:         %6d\n", count_interface_size);
580         dolog("Number of Argument stack slots in register:  %6d",
581                   count_argument_reg_ss);
582         dolog("Number of Argument stack slots in memory:    %6d\n",
583                   count_argument_mem_ss);
584         dolog("Number of Methods kept in registers:         %6d\n",
585                   count_method_in_register);
586
587
588         /* instruction scheduler statistics ***************************************/
589
590 #if defined(USE_SCHEDULER)
591         dolog("Instruction scheduler statistics:");
592         dolog("Number of basic blocks:       %7d", count_schedule_basic_blocks);
593         dolog("Number of nodes:              %7d", count_schedule_nodes);
594         dolog("Number of leaders nodes:      %7d", count_schedule_leaders);
595         dolog("Number of max. leaders nodes: %7d", count_schedule_max_leaders);
596         dolog("Length of critical path:      %7d\n", count_schedule_critical_path);
597 #endif
598
599
600         /* call statistics ********************************************************/
601
602         dolog("Function call statistics:");
603         dolog("Number of jni->CallXMethod function invokations: %ld",
604                   count_jni_callXmethod_calls);
605         dolog("Overall number of jni invokations:               %ld",
606                   count_jni_calls);
607
608         log_println("java-to-native calls:   %10ld", count_calls_java_to_native);
609         log_println("native-to-java calls:   %10ld", count_calls_native_to_java);
610
611
612         /* now print other statistics ********************************************/
613
614 #if defined(ENABLE_INTRP)
615         print_dynamic_super_statistics();
616 #endif
617 }
618
619
620 /* statistics_print_date *******************************************************
621
622    Print current date and time.
623
624 *******************************************************************************/
625
626 void statistics_print_date(void)
627 {
628   time_t t;
629   struct tm tm;
630
631 #if defined(HAVE_TIME)
632   time(&t);
633 #else
634 # error !HAVE_TIME
635 #endif
636
637 #if defined(HAVE_LOCALTIME_R)
638   localtime_r(&t, &tm);
639 #else
640 # error !HAVE_LOCALTIME_R
641 #endif
642
643   log_println("%d-%02d-%02d %02d:%02d:%02d",
644                           1900 + tm.tm_year, tm.tm_mon + 1, tm.tm_mday,
645                           tm.tm_hour, tm.tm_min, tm.tm_sec);
646 }
647
648
649 /* statistics_print_memory_usage ***********************************************
650
651    Print current memory usage.
652
653 *******************************************************************************/
654
655 void statistics_print_memory_usage(void)
656 {
657         s4 sum;
658
659         log_println("memory usage ----------------------");
660         log_println("");
661         log_println("code:                   %10d", count_code_len);
662         log_println("data:                   %10d", count_data_len);
663         log_println("                         ----------");
664
665         sum =
666                 count_code_len +
667                 count_data_len;
668
669         log_println("                        %10d", sum);
670         log_println("");
671         log_println("classinfo  (%3d B):     %10d", (int) sizeof(classinfo), size_classinfo);
672         log_println("fieldinfo  (%3d B):     %10d", (int) sizeof(fieldinfo), size_fieldinfo);
673         log_println("methodinfo (%3d B):     %10d", (int) sizeof(methodinfo), size_methodinfo);
674         log_println("lineinfo   (%3d B):     %10d", (int) sizeof(lineinfo), size_lineinfo);
675         log_println("codeinfo   (%3d B):     %10d", (int) sizeof(codeinfo), size_codeinfo);
676         log_println("                         ----------");
677
678         sum =
679                 size_classinfo +
680                 size_fieldinfo +
681                 size_methodinfo +
682                 size_lineinfo +
683                 size_codeinfo;
684
685         log_println("                        %10d", sum);
686         log_println("");
687         log_println("constant pool:          %10d", count_const_pool_len);
688         log_println("classref:               %10d", count_classref_len);
689         log_println("parsed descriptors:     %10d", count_parsed_desc_len);
690         log_println("vftbl:                  %10d", count_vftbl_len);
691         log_println("compiler stubs:         %10d", count_cstub_len);
692         log_println("native stubs:           %10d", size_stub_native);
693         log_println("utf:                    %10d", count_utf_len);
694         log_println("vmcode:                 %10d", count_vmcode_len);
695         log_println("exception tables:       %10d", count_extable_len);
696         log_println("stack map:              %10d", size_stack_map);
697         log_println("string:                 %10d", size_string);
698         log_println("threadobject:           %10d", size_threadobject);
699         log_println("lock record:            %10d", size_lock_record);
700         log_println("lock hashtable:         %10d", size_lock_hashtable);
701         log_println("lock waiter:            %10d", size_lock_waiter);
702         log_println("patcher references:     %10d", size_patchref);
703         log_println("                         ----------");
704
705         sum =
706                 count_const_pool_len +
707                 count_classref_len +
708                 count_parsed_desc_len + 
709                 count_vftbl_len +
710                 count_cstub_len +
711                 size_stub_native +
712                 count_utf_len +
713                 count_vmcode_len +
714                 count_extable_len +
715                 size_stack_map +
716                 size_string +
717                 size_threadobject +
718                 size_lock_record +
719                 size_lock_hashtable +
720                 size_lock_waiter +
721                 size_patchref;
722
723         log_println("                        %10d", sum);
724         log_println("");
725         log_println("max. code memory:       %10d", maxcodememusage);
726         log_println("max. heap memory:       %10d", maxmemusage);
727         log_println("max. dump memory:       %10d", maxdumpsize);
728         log_println("");
729         log_println("heap memory not freed:  %10d", (s4) memoryusage);
730         log_println("dump memory not freed:  %10d", (s4) globalallocateddumpsize);
731         log_println("");
732 }
733
734
735 /* statistics_print_gc_memory_usage ********************************************
736
737    Print current GC memory usage.
738
739 *******************************************************************************/
740
741 void statistics_print_gc_memory_usage(void)
742 {
743         static int64_t count = 0;
744         int64_t max;
745         int64_t size;
746         int64_t free;
747         int64_t used;
748         int64_t total;
749
750         count++;
751
752         max   = gc_get_max_heap_size();
753         size  = gc_get_heap_size();
754         free  = gc_get_free_bytes();
755         used  = size - free;
756         total = gc_get_total_bytes();
757
758         if (opt_ProfileMemoryUsageGNUPlot) {
759                 if (count == 1)
760                         fprintf(opt_ProfileMemoryUsageGNUPlot, "plot \"profile.dat\" using 1:2 with lines title \"max. Java heap size\", \"profile.dat\" using 1:3 with lines title \"Java heap size\", \"profile.dat\" using 1:4 with lines title \"used\", \"profile.dat\" using 1:5 with lines title \"free\"\n");
761
762 #if SIZEOF_VOID_P == 8
763                 fprintf(opt_ProfileMemoryUsageGNUPlot, "%ld %ld %ld %ld %ld\n", count, max, size, used, free);
764 #else
765                 fprintf(opt_ProfileMemoryUsageGNUPlot, "%lld %lld %lld %lld %lld\n", count, max, size, used, free);
766 #endif
767
768                 fflush(opt_ProfileMemoryUsageGNUPlot);
769         }
770         else {
771                 log_println("GC memory usage -------------------");
772                 log_println("");
773                 log_println("max. Java heap size: %10lld", max);
774                 log_println("");
775                 log_println("Java heap size:      %10lld", size);
776                 log_println("used:                %10lld", used);
777                 log_println("free:                %10lld", free);
778                 log_println("totally used:        %10lld", total);
779                 log_println("");
780         }
781 }
782
783
784 /*
785  * These are local overrides for various environment variables in Emacs.
786  * Please do not remove this and leave it at the end of the file, where
787  * Emacs will automagically detect them.
788  * ---------------------------------------------------------------------
789  * Local variables:
790  * mode: c
791  * indent-tabs-mode: t
792  * c-basic-offset: 4
793  * tab-width: 4
794  * End:
795  * vim:noexpandtab:sw=4:ts=4:
796  */