--- old/src/share/vm/runtime/java.cpp 2014-03-20 17:15:29.620313209 +0100 +++ new/src/share/vm/runtime/java.cpp 2014-03-20 17:15:29.374230241 +0100 @@ -98,21 +98,14 @@ #endif -#ifndef PRODUCT - -// Statistics printing (method invocation histogram) - -GrowableArray* collected_invoked_methods; +GrowableArray* collected_profiled_methods; -void collect_invoked_methods(Method* m) { - if (m->invocation_count() + m->compiled_invocation_count() >= 1 ) { - collected_invoked_methods->push(m); - } +int compare_methods(Method** a, Method** b) { + // %%% there can be 32-bit overflow here + return (*b)->invocation_count() - (*a)->invocation_count(); } -GrowableArray* collected_profiled_methods; - void collect_profiled_methods(Method* m) { Thread* thread = Thread::current(); // This HandleMark prevents a huge amount of handles from being added @@ -125,14 +118,54 @@ } } +void print_method_profiling_data() { + if (ProfileInterpreter COMPILER1_PRESENT(|| C1UpdateMethodData)) { + ResourceMark rm; + HandleMark hm; + collected_profiled_methods = new GrowableArray(1024); + ClassLoaderDataGraph::methods_do(collect_profiled_methods); + collected_profiled_methods->sort(&compare_methods); + + int count = collected_profiled_methods->length(); + int total_size = 0; + if (count > 0) { + for (int index = 0; index < count; index++) { + Method* m = collected_profiled_methods->at(index); + ttyLocker ttyl; + tty->print_cr("------------------------------------------------------------------------"); + m->print_invocation_count(); + tty->print_cr(" mdo size: %d bytes", m->method_data()->size_in_bytes()); + tty->cr(); + // Dump data on parameters if any + if (m->method_data() != NULL && m->method_data()->parameters_type_data() != NULL) { + tty->fill_to(2); + m->method_data()->parameters_type_data()->print_data_on(tty); + } + m->print_codes(); + total_size += m->method_data()->size_in_bytes(); + } + tty->print_cr("------------------------------------------------------------------------"); + tty->print_cr("Total MDO size: %d bytes", total_size); + } + } +} -int compare_methods(Method** a, Method** b) { - // %%% there can be 32-bit overflow here - return ((*b)->invocation_count() + (*b)->compiled_invocation_count()) - - ((*a)->invocation_count() + (*a)->compiled_invocation_count()); + +#ifndef PRODUCT + +// Statistics printing (method invocation histogram) + +GrowableArray* collected_invoked_methods; + +void collect_invoked_methods(Method* m) { + if (m->invocation_count() + m->compiled_invocation_count() >= 1 ) { + collected_invoked_methods->push(m); + } } + + void print_method_invocation_histogram() { ResourceMark rm; HandleMark hm; @@ -173,37 +206,6 @@ SharedRuntime::print_call_statistics(comp_total); } -void print_method_profiling_data() { - ResourceMark rm; - HandleMark hm; - collected_profiled_methods = new GrowableArray(1024); - SystemDictionary::methods_do(collect_profiled_methods); - collected_profiled_methods->sort(&compare_methods); - - int count = collected_profiled_methods->length(); - int total_size = 0; - if (count > 0) { - for (int index = 0; index < count; index++) { - Method* m = collected_profiled_methods->at(index); - ttyLocker ttyl; - tty->print_cr("------------------------------------------------------------------------"); - //m->print_name(tty); - m->print_invocation_count(); - tty->print_cr(" mdo size: %d bytes", m->method_data()->size_in_bytes()); - tty->cr(); - // Dump data on parameters if any - if (m->method_data() != NULL && m->method_data()->parameters_type_data() != NULL) { - tty->fill_to(2); - m->method_data()->parameters_type_data()->print_data_on(tty); - } - m->print_codes(); - total_size += m->method_data()->size_in_bytes(); - } - tty->print_cr("------------------------------------------------------------------------"); - tty->print_cr("Total MDO size: %d bytes", total_size); - } -} - void print_bytecode_count() { if (CountBytecodes || TraceBytecodes || StopInterpreterAt) { tty->print_cr("[BytecodeCounter::counter_value = %d]", BytecodeCounter::counter_value()); @@ -281,9 +283,9 @@ if (CountCompiledCalls) { print_method_invocation_histogram(); } - if (ProfileInterpreter COMPILER1_PRESENT(|| C1UpdateMethodData)) { - print_method_profiling_data(); - } + + print_method_profiling_data(); + if (TimeCompiler) { COMPILER2_PRESENT(Compile::print_timers();) } @@ -373,6 +375,10 @@ void print_statistics() { + if (PrintMethodData) { + print_method_profiling_data(); + } + if (CITime) { CompileBroker::print_times(); }