96 #include "opto/indexSet.hpp" |
96 #include "opto/indexSet.hpp" |
97 #include "opto/runtime.hpp" |
97 #include "opto/runtime.hpp" |
98 #endif |
98 #endif |
99 |
99 |
100 |
100 |
101 #ifndef PRODUCT |
|
102 |
|
103 // Statistics printing (method invocation histogram) |
|
104 |
|
105 GrowableArray<Method*>* collected_invoked_methods; |
|
106 |
|
107 void collect_invoked_methods(Method* m) { |
|
108 if (m->invocation_count() + m->compiled_invocation_count() >= 1 ) { |
|
109 collected_invoked_methods->push(m); |
|
110 } |
|
111 } |
|
112 |
|
113 |
|
114 GrowableArray<Method*>* collected_profiled_methods; |
101 GrowableArray<Method*>* collected_profiled_methods; |
|
102 |
|
103 int compare_methods(Method** a, Method** b) { |
|
104 // %%% there can be 32-bit overflow here |
|
105 return ((*b)->invocation_count() + (*b)->compiled_invocation_count()) |
|
106 - ((*a)->invocation_count() + (*a)->compiled_invocation_count()); |
|
107 } |
115 |
108 |
116 void collect_profiled_methods(Method* m) { |
109 void collect_profiled_methods(Method* m) { |
117 Thread* thread = Thread::current(); |
110 Thread* thread = Thread::current(); |
118 // This HandleMark prevents a huge amount of handles from being added |
111 // This HandleMark prevents a huge amount of handles from being added |
119 // to the metadata_handles() array on the thread. |
112 // to the metadata_handles() array on the thread. |
123 (PrintMethodData || CompilerOracle::should_print(mh))) { |
116 (PrintMethodData || CompilerOracle::should_print(mh))) { |
124 collected_profiled_methods->push(m); |
117 collected_profiled_methods->push(m); |
125 } |
118 } |
126 } |
119 } |
127 |
120 |
128 |
121 void print_method_profiling_data() { |
129 int compare_methods(Method** a, Method** b) { |
122 if (ProfileInterpreter COMPILER1_PRESENT(|| C1UpdateMethodData)) { |
130 // %%% there can be 32-bit overflow here |
123 ResourceMark rm; |
131 return ((*b)->invocation_count() + (*b)->compiled_invocation_count()) |
124 HandleMark hm; |
132 - ((*a)->invocation_count() + (*a)->compiled_invocation_count()); |
125 collected_profiled_methods = new GrowableArray<Method*>(1024); |
133 } |
126 ClassLoaderDataGraph::methods_do(collect_profiled_methods); |
|
127 collected_profiled_methods->sort(&compare_methods); |
|
128 |
|
129 int count = collected_profiled_methods->length(); |
|
130 int total_size = 0; |
|
131 if (count > 0) { |
|
132 for (int index = 0; index < count; index++) { |
|
133 Method* m = collected_profiled_methods->at(index); |
|
134 ttyLocker ttyl; |
|
135 tty->print_cr("------------------------------------------------------------------------"); |
|
136 m->print_invocation_count(); |
|
137 tty->print_cr(" mdo size: %d bytes", m->method_data()->size_in_bytes()); |
|
138 tty->cr(); |
|
139 // Dump data on parameters if any |
|
140 if (m->method_data() != NULL && m->method_data()->parameters_type_data() != NULL) { |
|
141 tty->fill_to(2); |
|
142 m->method_data()->parameters_type_data()->print_data_on(tty); |
|
143 } |
|
144 m->print_codes(); |
|
145 total_size += m->method_data()->size_in_bytes(); |
|
146 } |
|
147 tty->print_cr("------------------------------------------------------------------------"); |
|
148 tty->print_cr("Total MDO size: %d bytes", total_size); |
|
149 } |
|
150 } |
|
151 } |
|
152 |
|
153 |
|
154 #ifndef PRODUCT |
|
155 |
|
156 // Statistics printing (method invocation histogram) |
|
157 |
|
158 GrowableArray<Method*>* collected_invoked_methods; |
|
159 |
|
160 void collect_invoked_methods(Method* m) { |
|
161 if (m->invocation_count() + m->compiled_invocation_count() >= 1 ) { |
|
162 collected_invoked_methods->push(m); |
|
163 } |
|
164 } |
|
165 |
|
166 |
134 |
167 |
135 |
168 |
136 void print_method_invocation_histogram() { |
169 void print_method_invocation_histogram() { |
137 ResourceMark rm; |
170 ResourceMark rm; |
138 HandleMark hm; |
171 HandleMark hm; |
171 tty->print_cr("\t%9d (%4.1f%%) accessor", acces_total, 100.0 * acces_total / total); |
204 tty->print_cr("\t%9d (%4.1f%%) accessor", acces_total, 100.0 * acces_total / total); |
172 tty->cr(); |
205 tty->cr(); |
173 SharedRuntime::print_call_statistics(comp_total); |
206 SharedRuntime::print_call_statistics(comp_total); |
174 } |
207 } |
175 |
208 |
176 void print_method_profiling_data() { |
|
177 ResourceMark rm; |
|
178 HandleMark hm; |
|
179 collected_profiled_methods = new GrowableArray<Method*>(1024); |
|
180 SystemDictionary::methods_do(collect_profiled_methods); |
|
181 collected_profiled_methods->sort(&compare_methods); |
|
182 |
|
183 int count = collected_profiled_methods->length(); |
|
184 int total_size = 0; |
|
185 if (count > 0) { |
|
186 for (int index = 0; index < count; index++) { |
|
187 Method* m = collected_profiled_methods->at(index); |
|
188 ttyLocker ttyl; |
|
189 tty->print_cr("------------------------------------------------------------------------"); |
|
190 //m->print_name(tty); |
|
191 m->print_invocation_count(); |
|
192 tty->print_cr(" mdo size: %d bytes", m->method_data()->size_in_bytes()); |
|
193 tty->cr(); |
|
194 // Dump data on parameters if any |
|
195 if (m->method_data() != NULL && m->method_data()->parameters_type_data() != NULL) { |
|
196 tty->fill_to(2); |
|
197 m->method_data()->parameters_type_data()->print_data_on(tty); |
|
198 } |
|
199 m->print_codes(); |
|
200 total_size += m->method_data()->size_in_bytes(); |
|
201 } |
|
202 tty->print_cr("------------------------------------------------------------------------"); |
|
203 tty->print_cr("Total MDO size: %d bytes", total_size); |
|
204 } |
|
205 } |
|
206 |
|
207 void print_bytecode_count() { |
209 void print_bytecode_count() { |
208 if (CountBytecodes || TraceBytecodes || StopInterpreterAt) { |
210 if (CountBytecodes || TraceBytecodes || StopInterpreterAt) { |
209 tty->print_cr("[BytecodeCounter::counter_value = %d]", BytecodeCounter::counter_value()); |
211 tty->print_cr("[BytecodeCounter::counter_value = %d]", BytecodeCounter::counter_value()); |
210 } |
212 } |
211 } |
213 } |
279 #endif // ASSERT |
281 #endif // ASSERT |
280 #endif // COMPILER2 |
282 #endif // COMPILER2 |
281 if (CountCompiledCalls) { |
283 if (CountCompiledCalls) { |
282 print_method_invocation_histogram(); |
284 print_method_invocation_histogram(); |
283 } |
285 } |
284 if (ProfileInterpreter COMPILER1_PRESENT(|| C1UpdateMethodData)) { |
286 |
285 print_method_profiling_data(); |
287 print_method_profiling_data(); |
286 } |
288 |
287 if (TimeCompiler) { |
289 if (TimeCompiler) { |
288 COMPILER2_PRESENT(Compile::print_timers();) |
290 COMPILER2_PRESENT(Compile::print_timers();) |
289 } |
291 } |
290 if (TimeCompilationPolicy) { |
292 if (TimeCompilationPolicy) { |
291 CompilationPolicy::policy()->print_time(); |
293 CompilationPolicy::policy()->print_time(); |