< prev index next >

src/hotspot/share/runtime/java.cpp

Print this page

  5  * This code is free software; you can redistribute it and/or modify it
  6  * under the terms of the GNU General Public License version 2 only, as
  7  * published by the Free Software Foundation.
  8  *
  9  * This code is distributed in the hope that it will be useful, but WITHOUT
 10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *
 23  */
 24 

 25 #include "cds/aotMetaspace.hpp"
 26 #include "cds/cds_globals.hpp"
 27 #include "cds/cdsConfig.hpp"
 28 #include "cds/classListWriter.hpp"
 29 #include "cds/dynamicArchive.hpp"

 30 #include "classfile/classLoader.hpp"
 31 #include "classfile/classLoaderDataGraph.hpp"
 32 #include "classfile/javaClasses.hpp"
 33 #include "classfile/stringTable.hpp"
 34 #include "classfile/symbolTable.hpp"
 35 #include "classfile/systemDictionary.hpp"

 36 #include "code/codeCache.hpp"
 37 #include "compiler/compilationMemoryStatistic.hpp"
 38 #include "compiler/compilationPolicy.hpp"
 39 #include "compiler/compileBroker.hpp"
 40 #include "compiler/compilerOracle.hpp"
 41 #include "gc/shared/collectedHeap.hpp"
 42 #include "gc/shared/stringdedup/stringDedup.hpp"
 43 #include "interpreter/bytecodeHistogram.hpp"

 44 #include "jfr/jfrEvents.hpp"
 45 #include "jfr/support/jfrThreadId.hpp"
 46 #include "jvm.h"
 47 #include "logging/log.hpp"
 48 #include "logging/logStream.hpp"
 49 #include "memory/metaspaceUtils.hpp"
 50 #include "memory/oopFactory.hpp"
 51 #include "memory/resourceArea.hpp"
 52 #include "memory/universe.hpp"
 53 #include "nmt/memMapPrinter.hpp"
 54 #include "nmt/memTracker.hpp"
 55 #include "oops/constantPool.hpp"
 56 #include "oops/generateOopMap.hpp"
 57 #include "oops/instanceKlass.hpp"
 58 #include "oops/instanceOop.hpp"
 59 #include "oops/klassVtable.hpp"
 60 #include "oops/method.inline.hpp"
 61 #include "oops/objArrayOop.hpp"
 62 #include "oops/oop.inline.hpp"
 63 #include "oops/symbol.hpp"

 64 #include "prims/jvmtiAgentList.hpp"
 65 #include "prims/jvmtiExport.hpp"

 66 #include "runtime/continuation.hpp"
 67 #include "runtime/deoptimization.hpp"
 68 #include "runtime/flags/flagSetting.hpp"

 69 #include "runtime/handles.inline.hpp"
 70 #include "runtime/init.hpp"
 71 #include "runtime/interfaceSupport.inline.hpp"
 72 #include "runtime/java.hpp"
 73 #include "runtime/javaThread.hpp"
 74 #include "runtime/os.hpp"
 75 #include "runtime/sharedRuntime.hpp"
 76 #include "runtime/stubRoutines.hpp"
 77 #include "runtime/task.hpp"
 78 #include "runtime/threads.hpp"
 79 #include "runtime/timer.hpp"
 80 #include "runtime/trimNativeHeap.hpp"
 81 #include "runtime/vm_version.hpp"
 82 #include "runtime/vmOperations.hpp"
 83 #include "runtime/vmThread.hpp"
 84 #include "sanitizers/leak.hpp"
 85 #include "utilities/dtrace.hpp"
 86 #include "utilities/events.hpp"
 87 #include "utilities/globalDefinitions.hpp"
 88 #include "utilities/macros.hpp"

144 
145         ss.print_cr("------------------------------------------------------------------------");
146         m->print_invocation_count(&ss);
147         ss.print_cr("  mdo size: %d bytes", m->method_data()->size_in_bytes());
148         ss.cr();
149         // Dump data on parameters if any
150         if (m->method_data() != nullptr && m->method_data()->parameters_type_data() != nullptr) {
151           ss.fill_to(2);
152           m->method_data()->parameters_type_data()->print_data_on(&ss);
153         }
154         m->print_codes_on(&ss);
155         tty->print("%s", ss.as_string()); // print all at once
156         total_size += m->method_data()->size_in_bytes();
157       }
158       tty->print_cr("------------------------------------------------------------------------");
159       tty->print_cr("Total MDO size: %d bytes", total_size);
160     }
161   }
162 }
163 


















































































164 #ifndef PRODUCT
165 
166 // Statistics printing (method invocation histogram)
167 
168 GrowableArray<Method*>* collected_invoked_methods;
169 
170 static void collect_invoked_methods(Method* m) {
171   if (m->invocation_count() + m->compiled_invocation_count() >= 1) {
172     collected_invoked_methods->push(m);
173   }
174 }
175 
176 
177 // Invocation count accumulators should be unsigned long to shift the
178 // overflow border. Longer-running workloads tend to create invocation
179 // counts which already overflow 32-bit counters for individual methods.
180 static void print_method_invocation_histogram() {
181   ResourceMark rm;
182   collected_invoked_methods = new GrowableArray<Method*>(1024);
183   SystemDictionary::methods_do(collect_invoked_methods);

211     if (m->is_synchronized()) synch_total  += iic + cic;
212     if (m->is_native())       native_total += iic + cic;
213     if (m->is_accessor())     access_total += iic + cic;
214   }
215   tty->cr();
216   total = int_total + comp_total;
217   special_total = final_total + static_total +synch_total + native_total + access_total;
218   tty->print_cr("Invocations summary for %d methods:", collected_invoked_methods->length());
219   double total_div = (double)total;
220   tty->print_cr("\t" UINT64_FORMAT_W(12) " (100%%)  total",           total);
221   tty->print_cr("\t" UINT64_FORMAT_W(12) " (%4.1f%%) |- interpreted", int_total,     100.0 * (double)int_total    / total_div);
222   tty->print_cr("\t" UINT64_FORMAT_W(12) " (%4.1f%%) |- compiled",    comp_total,    100.0 * (double)comp_total   / total_div);
223   tty->print_cr("\t" UINT64_FORMAT_W(12) " (%4.1f%%) |- special methods (interpreted and compiled)",
224                                                                          special_total, 100.0 * (double)special_total/ total_div);
225   tty->print_cr("\t" UINT64_FORMAT_W(12) " (%4.1f%%)    |- synchronized",synch_total,   100.0 * (double)synch_total  / total_div);
226   tty->print_cr("\t" UINT64_FORMAT_W(12) " (%4.1f%%)    |- final",       final_total,   100.0 * (double)final_total  / total_div);
227   tty->print_cr("\t" UINT64_FORMAT_W(12) " (%4.1f%%)    |- static",      static_total,  100.0 * (double)static_total / total_div);
228   tty->print_cr("\t" UINT64_FORMAT_W(12) " (%4.1f%%)    |- native",      native_total,  100.0 * (double)native_total / total_div);
229   tty->print_cr("\t" UINT64_FORMAT_W(12) " (%4.1f%%)    |- accessor",    access_total,  100.0 * (double)access_total / total_div);
230   tty->cr();
231   SharedRuntime::print_call_statistics(comp_total);
232 }
233 
234 static void print_bytecode_count() {
235   if (CountBytecodes || TraceBytecodes || StopInterpreterAt) {
236     tty->print_cr("[BytecodeCounter::counter_value = %zu]", BytecodeCounter::counter_value());
237   }
238 }
239 
240 #else
241 
242 static void print_method_invocation_histogram() {}
243 static void print_bytecode_count() {}
244 
245 #endif // PRODUCT
246 
247 
248 // General statistics printing (profiling ...)
249 void print_statistics() {





250   if (CITime) {
251     CompileBroker::print_times();
252   }
253 
254 #ifdef COMPILER1
255   if ((PrintC1Statistics || LogVMOutput || LogCompilation) && UseCompiler) {
256     FlagSetting fs(DisplayVMOutput, DisplayVMOutput && PrintC1Statistics);
257     Runtime1::print_statistics();
258     SharedRuntime::print_statistics();
259   }
260 #endif /* COMPILER1 */
261 
262 #ifdef COMPILER2
263   if ((PrintOptoStatistics || LogVMOutput || LogCompilation) && UseCompiler) {
264     FlagSetting fs(DisplayVMOutput, DisplayVMOutput && PrintOptoStatistics);
265     Compile::print_statistics();
266     Deoptimization::print_statistics();
267 #ifndef COMPILER1
268     SharedRuntime::print_statistics();
269 #endif //COMPILER1
270   }
271 
272   if (PrintLockStatistics) {
273     OptoRuntime::print_named_counters();
274   }
275 #ifdef ASSERT
276   if (CollectIndexSetStatistics) {
277     IndexSet::print_statistics();

304   if (PrintSymbolTableSizeHistogram) {
305     SymbolTable::print_histogram();
306   }
307   if (CountBytecodes || TraceBytecodes || StopInterpreterAt) {
308     BytecodeCounter::print();
309   }
310   if (PrintBytecodePairHistogram) {
311     BytecodePairHistogram::print();
312   }
313 
314   if (PrintCodeCache) {
315     MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
316     CodeCache::print();
317   }
318 
319   // CodeHeap State Analytics.
320   if (PrintCodeHeapAnalytics) {
321     CompileBroker::print_heapinfo(nullptr, "all", 4096); // details
322   }
323 






324 #ifndef PRODUCT
325   if (PrintCodeCache2) {
326     MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
327     CodeCache::print_internals();
328   }
329 #endif
330 
331   if (VerifyOops && Verbose) {
332     tty->print_cr("+VerifyOops count: %d", StubRoutines::verify_oop_count());
333   }
334 
335   print_bytecode_count();
336 
337   if (PrintVMInfoAtExit) {
338     // Use an intermediate stream to prevent deadlocking on tty_lock
339     stringStream ss;
340     VMError::print_vm_info(&ss);
341     tty->print_raw(ss.base());
342   }
343 

351     ResourceMark rm;
352     MutexLocker mcld(ClassLoaderDataGraph_lock);
353     ClassLoaderDataGraph::print();
354   }
355 
356   // Native memory tracking data
357   if (PrintNMTStatistics) {
358     MemTracker::final_report(tty);
359   }
360 
361   if (PrintMetaspaceStatisticsAtExit) {
362     MetaspaceUtils::print_basic_report(tty, 0);
363   }
364 
365   if (PrintCompilerMemoryStatisticsAtExit) {
366     CompilationMemoryStatistic::print_final_report(tty);
367   }
368 
369   ThreadsSMRSupport::log_statistics();
370 


371   if (log_is_enabled(Info, perf, class, link)) {
372     LogStreamHandle(Info, perf, class, link) log;
373     log.print_cr("At VM exit:");
374     ClassLoader::print_counters(&log);
375   }
376 }
377 
378 // Note: before_exit() can be executed only once, if more than one threads
379 //       are trying to shutdown the VM at the same time, only one thread
380 //       can run before_exit() and all other threads must wait.
381 void before_exit(JavaThread* thread, bool halt) {
382   #define BEFORE_EXIT_NOT_RUN 0
383   #define BEFORE_EXIT_RUNNING 1
384   #define BEFORE_EXIT_DONE    2
385   static jint volatile _before_exit_status = BEFORE_EXIT_NOT_RUN;
386 
387   Events::log(thread, "Before exit entered");
388 
389   // Note: don't use a Mutex to guard the entire before_exit(), as
390   // JVMTI post_thread_end_event and post_vm_death_event will run native code.

416 
417   // Do not add any additional shutdown logic between the above mutex logic and
418   // leak sanitizer logic below. Any additional shutdown code which performs some
419   // cleanup should be added after the leak sanitizer logic below.
420 
421 #ifdef LEAK_SANITIZER
422   // If we are built with LSan, we need to perform leak checking. If we are
423   // terminating normally, not halting and no VM error, we perform a normal
424   // leak check which terminates if leaks are found. If we are not terminating
425   // normally, halting or VM error, we perform a recoverable leak check which
426   // prints leaks but will not terminate.
427   if (!halt && !VMError::is_error_reported()) {
428     LSAN_DO_LEAK_CHECK();
429   } else {
430     // Ignore the return value.
431     static_cast<void>(LSAN_DO_RECOVERABLE_LEAK_CHECK());
432   }
433 #endif
434 
435 #if INCLUDE_CDS

436   // Dynamic CDS dumping must happen whilst we can still reliably
437   // run Java code.
438   DynamicArchive::dump_at_exit(thread);
439   assert(!thread->has_pending_exception(), "must be");
440 #endif
441 
442   // Actual shutdown logic begins here.
443 
444 #if INCLUDE_JVMCI
445   if (EnableJVMCI) {
446     JVMCI::shutdown(thread);
447   }
448 #endif
449 
450 #if INCLUDE_CDS
451   ClassListWriter::write_resolved_constants();
452 

453   if (CDSConfig::is_dumping_preimage_static_archive()) {
454     AOTMetaspace::dump_static_archive(thread);
455   }
456 #endif
457 
458   // Hang forever on exit if we're reporting an error.
459   if (ShowMessageBoxOnError && VMError::is_error_reported()) {
460     os::infinite_sleep();
461   }
462 
463   EventThreadEnd event;
464   if (event.should_commit()) {
465     event.set_thread(JFR_JVM_THREAD_ID(thread));
466     event.commit();
467   }
468 
469   JFR_ONLY(Jfr::on_vm_shutdown(false, halt);)
470 
471   // Stop the WatcherThread. We do this before disenrolling various
472   // PeriodicTasks to reduce the likelihood of races.
473   WatcherThread::stop();
474 
475   NativeHeapTrimmer::cleanup();
476 
477   if (JvmtiExport::should_post_thread_life()) {
478     JvmtiExport::post_thread_end(thread);
479   }
480 
481   // Always call even when there are not JVMTI environments yet, since environments
482   // may be attached late and JVMTI must track phases of VM execution.
483   JvmtiExport::post_vm_death();
484   JvmtiAgentList::unload_agents();
485 
486   // No user code can be executed in the current thread after this point.
487 
488   // Run before exit and then stop concurrent GC threads.
489   Universe::before_exit();
490 
491   if (PrintBytecodeHistogram) {
492     BytecodeHistogram::print();
493   }
494 
495 #ifdef LINUX
496   if (DumpPerfMapAtExit) {
497     CodeCache::write_perf_map(nullptr, tty);
498   }
499   if (PrintMemoryMapAtExit) {
500     MemMapPrinter::print_all_mappings(tty);
501   }
502 #endif
503 
504   // Terminate the signal thread
505   // Note: we don't wait until it actually dies.
506   os::terminate_signal_thread();
507 
508   #if INCLUDE_CDS
509   if (AOTVerifyTrainingData) {
510     TrainingData::verify();
511   }
512   #endif

  5  * This code is free software; you can redistribute it and/or modify it
  6  * under the terms of the GNU General Public License version 2 only, as
  7  * published by the Free Software Foundation.
  8  *
  9  * This code is distributed in the hope that it will be useful, but WITHOUT
 10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *
 23  */
 24 
 25 #include "cds/aotLinkedClassBulkLoader.hpp"
 26 #include "cds/aotMetaspace.hpp"
 27 #include "cds/cds_globals.hpp"
 28 #include "cds/cdsConfig.hpp"
 29 #include "cds/classListWriter.hpp"
 30 #include "cds/dynamicArchive.hpp"
 31 #include "cds/methodProfiler.hpp"
 32 #include "classfile/classLoader.hpp"
 33 #include "classfile/classLoaderDataGraph.hpp"
 34 #include "classfile/javaClasses.hpp"
 35 #include "classfile/stringTable.hpp"
 36 #include "classfile/symbolTable.hpp"
 37 #include "classfile/systemDictionary.hpp"
 38 #include "code/aotCodeCache.hpp"
 39 #include "code/codeCache.hpp"
 40 #include "compiler/compilationMemoryStatistic.hpp"
 41 #include "compiler/compilationPolicy.hpp"
 42 #include "compiler/compileBroker.hpp"
 43 #include "compiler/compilerOracle.hpp"
 44 #include "gc/shared/collectedHeap.hpp"
 45 #include "gc/shared/stringdedup/stringDedup.hpp"
 46 #include "interpreter/bytecodeHistogram.hpp"
 47 #include "interpreter/interpreterRuntime.hpp"
 48 #include "jfr/jfrEvents.hpp"
 49 #include "jfr/support/jfrThreadId.hpp"
 50 #include "jvm.h"
 51 #include "logging/log.hpp"
 52 #include "logging/logStream.hpp"
 53 #include "memory/metaspaceUtils.hpp"
 54 #include "memory/oopFactory.hpp"
 55 #include "memory/resourceArea.hpp"
 56 #include "memory/universe.hpp"
 57 #include "nmt/memMapPrinter.hpp"
 58 #include "nmt/memTracker.hpp"
 59 #include "oops/constantPool.hpp"
 60 #include "oops/generateOopMap.hpp"
 61 #include "oops/instanceKlass.hpp"
 62 #include "oops/instanceOop.hpp"
 63 #include "oops/klassVtable.hpp"
 64 #include "oops/method.inline.hpp"
 65 #include "oops/objArrayOop.hpp"
 66 #include "oops/oop.inline.hpp"
 67 #include "oops/symbol.hpp"
 68 #include "oops/trainingData.hpp"
 69 #include "prims/jvmtiAgentList.hpp"
 70 #include "prims/jvmtiExport.hpp"
 71 #include "prims/methodHandles.hpp"
 72 #include "runtime/continuation.hpp"
 73 #include "runtime/deoptimization.hpp"
 74 #include "runtime/flags/flagSetting.hpp"
 75 #include "runtime/globals_extension.hpp"
 76 #include "runtime/handles.inline.hpp"
 77 #include "runtime/init.hpp"
 78 #include "runtime/interfaceSupport.inline.hpp"
 79 #include "runtime/java.hpp"
 80 #include "runtime/javaThread.hpp"
 81 #include "runtime/os.hpp"
 82 #include "runtime/sharedRuntime.hpp"
 83 #include "runtime/stubRoutines.hpp"
 84 #include "runtime/task.hpp"
 85 #include "runtime/threads.hpp"
 86 #include "runtime/timer.hpp"
 87 #include "runtime/trimNativeHeap.hpp"
 88 #include "runtime/vm_version.hpp"
 89 #include "runtime/vmOperations.hpp"
 90 #include "runtime/vmThread.hpp"
 91 #include "sanitizers/leak.hpp"
 92 #include "utilities/dtrace.hpp"
 93 #include "utilities/events.hpp"
 94 #include "utilities/globalDefinitions.hpp"
 95 #include "utilities/macros.hpp"

151 
152         ss.print_cr("------------------------------------------------------------------------");
153         m->print_invocation_count(&ss);
154         ss.print_cr("  mdo size: %d bytes", m->method_data()->size_in_bytes());
155         ss.cr();
156         // Dump data on parameters if any
157         if (m->method_data() != nullptr && m->method_data()->parameters_type_data() != nullptr) {
158           ss.fill_to(2);
159           m->method_data()->parameters_type_data()->print_data_on(&ss);
160         }
161         m->print_codes_on(&ss);
162         tty->print("%s", ss.as_string()); // print all at once
163         total_size += m->method_data()->size_in_bytes();
164       }
165       tty->print_cr("------------------------------------------------------------------------");
166       tty->print_cr("Total MDO size: %d bytes", total_size);
167     }
168   }
169 }
170 
171 void perf_jvm_print_on(outputStream* st);
172 
173 void log_vm_init_stats() {
174   LogStreamHandle(Info, init) log;
175   if (log.is_enabled()) {
176     SharedRuntime::print_counters_on(&log);
177     ClassLoader::print_counters(&log);
178     AOTLinkedClassBulkLoader::print_counters_on(&log);
179     log.cr();
180     // FIXME: intermittent crashes
181 //    if (CountBytecodesPerThread) {
182 //      log.print_cr("Thread info:");
183 //      class PrintThreadInfo : public ThreadClosure {
184 //        outputStream* _st;
185 //      public:
186 //        PrintThreadInfo(outputStream* st) : ThreadClosure(), _st(st) {}
187 //        void do_thread(Thread* thread) {
188 //          JavaThread* jt = JavaThread::cast(thread);
189 //          if (jt->bc_counter_value() > 0) {
190 //            _st->print_cr("  Thread " INTPTR_FORMAT ": %ld bytecodes executed (clinit: %ld)",
191 //                          p2i(jt), /*jt->name(),*/ jt->bc_counter_value(), jt->clinit_bc_counter_value());
192 //          }
193 //        }
194 //      };
195 //      PrintThreadInfo cl(&log);
196 //      Threads::java_threads_do(&cl);
197 //    }
198 //    log.cr();
199     log.print_cr("Deoptimization events: ");
200     Deoptimization::print_statistics_on(&log);
201     log.cr();
202 
203     log.print("Compilation statistics: ");
204     CompileBroker::print_statistics_on(&log);
205     log.cr();
206 
207     {
208       MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
209       log.print("Code cache statistics: ");
210       CodeCache::print_nmethod_statistics_on(&log);
211       log.cr();
212     }
213 
214     if (AOTCodeCache::is_on_for_use()) {
215       log.print_cr("Startup Code Cache: ");
216       AOTCodeCache::print_statistics_on(&log);
217       log.cr();
218       AOTCodeCache::print_timers_on(&log);
219     }
220 
221     VMThread::print_counters_on(&log);
222     log.cr();
223     MutexLockerImpl::print_counters_on(&log);
224     log.cr();
225     log.print("Runtime events for thread \"main\"");
226     if (ProfileRuntimeCalls) {
227       log.print_cr(" (%d nested events):", ProfileVMCallContext::nested_runtime_calls_count());
228 
229       InterpreterRuntime::print_counters_on(&log);
230 #ifdef COMPILER1
231       Runtime1::print_counters_on(&log);
232 #endif
233 #ifdef COMPILER2
234       OptoRuntime::print_counters_on(&log);
235       Deoptimization::print_counters_on(&log);
236 #endif
237     } else {
238       log.print_cr(": no info (%s is disabled)", (UsePerfData ? "ProfileRuntimeCalls" : "UsePerfData"));
239     }
240     log.cr();
241     perf_jvm_print_on(&log);
242     log.cr();
243     MethodHandles::print_counters_on(&log);
244   }
245 }
246 
247 void print_bytecode_count() {
248   if (CountBytecodes || TraceBytecodes || StopInterpreterAt) {
249     tty->print_cr("[BytecodeCounter::counter_value = %zu]", BytecodeCounter::counter_value());
250   }
251 }
252 
253 #ifndef PRODUCT
254 
255 // Statistics printing (method invocation histogram)
256 
257 GrowableArray<Method*>* collected_invoked_methods;
258 
259 static void collect_invoked_methods(Method* m) {
260   if (m->invocation_count() + m->compiled_invocation_count() >= 1) {
261     collected_invoked_methods->push(m);
262   }
263 }
264 
265 
266 // Invocation count accumulators should be unsigned long to shift the
267 // overflow border. Longer-running workloads tend to create invocation
268 // counts which already overflow 32-bit counters for individual methods.
269 static void print_method_invocation_histogram() {
270   ResourceMark rm;
271   collected_invoked_methods = new GrowableArray<Method*>(1024);
272   SystemDictionary::methods_do(collect_invoked_methods);

300     if (m->is_synchronized()) synch_total  += iic + cic;
301     if (m->is_native())       native_total += iic + cic;
302     if (m->is_accessor())     access_total += iic + cic;
303   }
304   tty->cr();
305   total = int_total + comp_total;
306   special_total = final_total + static_total +synch_total + native_total + access_total;
307   tty->print_cr("Invocations summary for %d methods:", collected_invoked_methods->length());
308   double total_div = (double)total;
309   tty->print_cr("\t" UINT64_FORMAT_W(12) " (100%%)  total",           total);
310   tty->print_cr("\t" UINT64_FORMAT_W(12) " (%4.1f%%) |- interpreted", int_total,     100.0 * (double)int_total    / total_div);
311   tty->print_cr("\t" UINT64_FORMAT_W(12) " (%4.1f%%) |- compiled",    comp_total,    100.0 * (double)comp_total   / total_div);
312   tty->print_cr("\t" UINT64_FORMAT_W(12) " (%4.1f%%) |- special methods (interpreted and compiled)",
313                                                                          special_total, 100.0 * (double)special_total/ total_div);
314   tty->print_cr("\t" UINT64_FORMAT_W(12) " (%4.1f%%)    |- synchronized",synch_total,   100.0 * (double)synch_total  / total_div);
315   tty->print_cr("\t" UINT64_FORMAT_W(12) " (%4.1f%%)    |- final",       final_total,   100.0 * (double)final_total  / total_div);
316   tty->print_cr("\t" UINT64_FORMAT_W(12) " (%4.1f%%)    |- static",      static_total,  100.0 * (double)static_total / total_div);
317   tty->print_cr("\t" UINT64_FORMAT_W(12) " (%4.1f%%)    |- native",      native_total,  100.0 * (double)native_total / total_div);
318   tty->print_cr("\t" UINT64_FORMAT_W(12) " (%4.1f%%)    |- accessor",    access_total,  100.0 * (double)access_total / total_div);
319   tty->cr();
320   SharedRuntime::print_call_statistics_on(tty);

321 




322 }
323 
324 #else
325 
326 static void print_method_invocation_histogram() {}

327 
328 #endif // PRODUCT
329 
330 
331 // General statistics printing (profiling ...)
332 void print_statistics() {
333 #if INCLUDE_CDS
334   if (AOTReplayTraining && AOTPrintTrainingInfo) {
335     TrainingData::print_archived_training_data_on(tty);
336   }
337 #endif
338   if (CITime) {
339     CompileBroker::print_times();
340   }
341 
342 #ifdef COMPILER1
343   if ((PrintC1Statistics || LogVMOutput || LogCompilation) && UseCompiler) {
344     FlagSetting fs(DisplayVMOutput, DisplayVMOutput && PrintC1Statistics);
345     Runtime1::print_statistics_on(tty);
346     SharedRuntime::print_statistics();
347   }
348 #endif /* COMPILER1 */
349 
350 #ifdef COMPILER2
351   if ((PrintOptoStatistics || LogVMOutput || LogCompilation) && UseCompiler) {
352     FlagSetting fs(DisplayVMOutput, DisplayVMOutput && PrintOptoStatistics);
353     Compile::print_statistics();
354     Deoptimization::print_statistics();
355 #ifndef COMPILER1
356     SharedRuntime::print_statistics();
357 #endif //COMPILER1
358   }
359 
360   if (PrintLockStatistics) {
361     OptoRuntime::print_named_counters();
362   }
363 #ifdef ASSERT
364   if (CollectIndexSetStatistics) {
365     IndexSet::print_statistics();

392   if (PrintSymbolTableSizeHistogram) {
393     SymbolTable::print_histogram();
394   }
395   if (CountBytecodes || TraceBytecodes || StopInterpreterAt) {
396     BytecodeCounter::print();
397   }
398   if (PrintBytecodePairHistogram) {
399     BytecodePairHistogram::print();
400   }
401 
402   if (PrintCodeCache) {
403     MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
404     CodeCache::print();
405   }
406 
407   // CodeHeap State Analytics.
408   if (PrintCodeHeapAnalytics) {
409     CompileBroker::print_heapinfo(nullptr, "all", 4096); // details
410   }
411 
412   LogStreamHandle(Debug, codecache, nmethod) log;
413   if (log.is_enabled()) {
414     MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
415     CodeCache::print_nmethods_on(&log);
416   }
417 
418 #ifndef PRODUCT
419   if (PrintCodeCache2) {
420     MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag);
421     CodeCache::print_internals();
422   }
423 #endif
424 
425   if (VerifyOops && Verbose) {
426     tty->print_cr("+VerifyOops count: %d", StubRoutines::verify_oop_count());
427   }
428 
429   print_bytecode_count();
430 
431   if (PrintVMInfoAtExit) {
432     // Use an intermediate stream to prevent deadlocking on tty_lock
433     stringStream ss;
434     VMError::print_vm_info(&ss);
435     tty->print_raw(ss.base());
436   }
437 

445     ResourceMark rm;
446     MutexLocker mcld(ClassLoaderDataGraph_lock);
447     ClassLoaderDataGraph::print();
448   }
449 
450   // Native memory tracking data
451   if (PrintNMTStatistics) {
452     MemTracker::final_report(tty);
453   }
454 
455   if (PrintMetaspaceStatisticsAtExit) {
456     MetaspaceUtils::print_basic_report(tty, 0);
457   }
458 
459   if (PrintCompilerMemoryStatisticsAtExit) {
460     CompilationMemoryStatistic::print_final_report(tty);
461   }
462 
463   ThreadsSMRSupport::log_statistics();
464 
465   log_vm_init_stats();
466 
467   if (log_is_enabled(Info, perf, class, link)) {
468     LogStreamHandle(Info, perf, class, link) log;
469     log.print_cr("At VM exit:");
470     ClassLoader::print_counters(&log);
471   }
472 }
473 
474 // Note: before_exit() can be executed only once, if more than one threads
475 //       are trying to shutdown the VM at the same time, only one thread
476 //       can run before_exit() and all other threads must wait.
477 void before_exit(JavaThread* thread, bool halt) {
478   #define BEFORE_EXIT_NOT_RUN 0
479   #define BEFORE_EXIT_RUNNING 1
480   #define BEFORE_EXIT_DONE    2
481   static jint volatile _before_exit_status = BEFORE_EXIT_NOT_RUN;
482 
483   Events::log(thread, "Before exit entered");
484 
485   // Note: don't use a Mutex to guard the entire before_exit(), as
486   // JVMTI post_thread_end_event and post_vm_death_event will run native code.

512 
513   // Do not add any additional shutdown logic between the above mutex logic and
514   // leak sanitizer logic below. Any additional shutdown code which performs some
515   // cleanup should be added after the leak sanitizer logic below.
516 
517 #ifdef LEAK_SANITIZER
518   // If we are built with LSan, we need to perform leak checking. If we are
519   // terminating normally, not halting and no VM error, we perform a normal
520   // leak check which terminates if leaks are found. If we are not terminating
521   // normally, halting or VM error, we perform a recoverable leak check which
522   // prints leaks but will not terminate.
523   if (!halt && !VMError::is_error_reported()) {
524     LSAN_DO_LEAK_CHECK();
525   } else {
526     // Ignore the return value.
527     static_cast<void>(LSAN_DO_RECOVERABLE_LEAK_CHECK());
528   }
529 #endif
530 
531 #if INCLUDE_CDS
532   MethodProfiler::process_method_hotness();
533   // Dynamic CDS dumping must happen whilst we can still reliably
534   // run Java code.
535   DynamicArchive::dump_at_exit(thread);
536   assert(!thread->has_pending_exception(), "must be");
537 #endif
538 
539   // Actual shutdown logic begins here.
540 
541 #if INCLUDE_JVMCI
542   if (EnableJVMCI) {
543     JVMCI::shutdown(thread);
544   }
545 #endif
546 
547 #if INCLUDE_CDS
548   ClassListWriter::write_resolved_constants();
549   ClassListWriter::write_reflection_data();
550   ClassListWriter::write_loader_negative_lookup_cache();
551   if (CDSConfig::is_dumping_preimage_static_archive()) {
552     AOTMetaspace::dump_static_archive(thread);
553   }
554 #endif
555 
556   // Hang forever on exit if we're reporting an error.
557   if (ShowMessageBoxOnError && VMError::is_error_reported()) {
558     os::infinite_sleep();
559   }
560 
561   EventThreadEnd event;
562   if (event.should_commit()) {
563     event.set_thread(JFR_JVM_THREAD_ID(thread));
564     event.commit();
565   }
566 
567   JFR_ONLY(Jfr::on_vm_shutdown(false, halt);)
568 
569   // Stop the WatcherThread. We do this before disenrolling various
570   // PeriodicTasks to reduce the likelihood of races.
571   WatcherThread::stop();
572 
573   NativeHeapTrimmer::cleanup();
574 
575   if (JvmtiExport::should_post_thread_life()) {
576     JvmtiExport::post_thread_end(thread);
577   }
578 
579   // Always call even when there are not JVMTI environments yet, since environments
580   // may be attached late and JVMTI must track phases of VM execution.
581   JvmtiExport::post_vm_death();
582   JvmtiAgentList::unload_agents();
583 
584   // No user code can be executed in the current thread after this point.
585 
586   // Run before exit and then stop concurrent GC threads.
587   Universe::before_exit();
588 
589   if (PrintBytecodeHistogram) {
590     BytecodeHistogram::print(PrintBytecodeHistogramCutoff);
591   }
592 
593 #ifdef LINUX
594   if (DumpPerfMapAtExit) {
595     CodeCache::write_perf_map(nullptr, tty);
596   }
597   if (PrintMemoryMapAtExit) {
598     MemMapPrinter::print_all_mappings(tty);
599   }
600 #endif
601 
602   // Terminate the signal thread
603   // Note: we don't wait until it actually dies.
604   os::terminate_signal_thread();
605 
606   #if INCLUDE_CDS
607   if (AOTVerifyTrainingData) {
608     TrainingData::verify();
609   }
610   #endif
< prev index next >