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