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