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